|
Did some debuging and at turns out the imagelist is created correctly with this code
HINSTANCE hDLL = LoadLibrary(_T("Resource.dll"));
if(hDLL){
CImageList imgList;
imgList.Create(16, 16, ILC_MASK, 16, 0);
imgList.Add(LoadBitmap(hDLL, MAKEINTRESOURCE(104)), RGB(255,0,255)));
ctrlTree.SetImageList(imgList);
FreeLibrary(hDLL);
}
So it's the ctrlTree that's not moving forwards in the image list. I made it move through the image list using TVIF_IMAGE, tvi.item.iImage, TVIF_SELECTEDIMAGE and tvi.item.iSelectedImage when constructing the CTreeViewCtrl items and.
|
|
|
|
|
class MyDlg
: public CDialogImpl<MyDlg>,
public CUpdateUI<MyDlg>,
public CIdleHandler,
{
BEGIN_UPDATE_UI_MAP(MyDlg)
UPDATE_ELEMENT(ID_FILE_PAUSE, UPDUI_MENUPOPUP)
UPDATE_ELEMENT(ID_FILE_CANCEL, UPDUI_MENUPOPUP)
END_UPDATE_UI_MAP()
BEGIN_MSG_MAP(MyDlg)
COMMAND_ID_HANDLER_EX(ID_FILE_PAUSE, OnPopupFileMenu)
COMMAND_ID_HANDLER_EX(ID_FILE_CANCEL, OnPopupFileMenu)
CHAIN_MSG_MAP(CUpdateUI<MyDlg>)
END_MSG_MAP
Here's the improtant part ofOnPopuFileMenu:
LRESULT MyDlg::OnPopupFileMenu(UINT , int , HWND )
{
UIEnable(ID_FILE_SEND, nEnableSend);
UIEnable(ID_FILE_PAUSE, nEnablePause);
UIEnable(ID_FILE_CANCEL, nEnableCancel);
UIEnable(ID_FILE_REMOVE, nEnableRemove);
return 0;
}
My goal is to call the OnPopupFileMenu when the head of the File menu is clicked (File) and to enable/disable some items from the file menu. But this does not happen.
What happens is that when I click File->Cancel (for example) the OnPopupFileMenu method is called and only then.
I achieved my goal by handling the raw WM_ENTERMENULOOP, but I don't like it this way, I want to use WTL's functionallity instead.
P.S.: I'm not sure whether I should have UPDATE_ELEMENT(and a corresponding COMMAND_ID_HANLER_EX) for each menu item I want to update, or a single one can do the job (because at each call of OnPopupFileMenu I know the state of all items in the menu).
Thanks for _any_ pointers.
|
|
|
|
|
itzuke wrote: What happens is that when I click File->Cancel (for example) the OnPopupFileMenu method is called and only then.
That's not so surprising - you 've declared OnPopupFileMenu as a handler for the menu's commands.
The BEGIN_UPDATE_UI_MAP defines what UI elements (menu, toolbar etc) should be updated when using functions like UIEnable. You call functions like UIEnable when the state that defines the UI state changes - WTL does not call UI update handlers like MFC.
See these two[^] articles[^] by Mike Dunn - in fact, see all of his WTL articles, they're all good!
[edit]You probably want to handle the WM_INITMENUPOPUP message and check what menu's being popped up to set menu item statuses like that.[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Do you know the values of nEnable* before the menu is accessed? If so, call UIEnable when you know those values. CUpdateUI handles WM_INITMENUPOPUP and will set the menu item states accordingly.
If you must do this processing when the menu is accessed, handle WM_INITMENUPOPUP and call UIEnable in that handler. Be sure to call SetMsgHandled(false) so that the message is passed on to CUpdateUI.
--Mike--
Dunder-Mifflin, this is Pam.
|
|
|
|
|
Hi
Here is sample code....
LocoDetails *locoValue = new LocoDetails(str1, ltime, latitude, longitude, speed, direction,
trackPos, trackNum, alarmsNum, failsNum);
Later i just add this to a STL map
locoDetailsList.insert(pair<std::wstring,LocoDetails*>(locoValue->GetLocoID(),locoValue));
for(pastIterater = locoDetailsList.begin();pastIterater != locoDetailsList.end();pastIterater++)
{
locoDetailsList.erase(pastIterater++);
}
Will the memory occupied by locoValue get removed or there a memory leak.
How can i solve this........
Thanks
|
|
|
|
|
The map only holds a pointer to the object. You're responsible for deleting the object itself.
--Mike--
Dunder-Mifflin, this is Pam
|
|
|
|
|
You are responsible for deleting the pointer objects yourself.
Another approach is to use a reference-counted smart pointer like boost::shared_ptr.
Pax Domini sit semper vobiscum
|
|
|
|
|
Hi
Can anyone tell how to compare systemtime.
SYSTEMTIME t1;
SYSTEMTIME t2;
GetSystemTime(&t1);
GetSystemTime(&t2);
Is this a good approach
t1==t2
Thanks
|
|
|
|
|
No. Because SYSTEMTIME doesn't have an operator== defined for it. You can define one.
bool operator==(const SYSTEMTIME& left, const SYSTEMTIME& right)
{
}
BTW - wrong forum - SYSTEMTIME has nopthing to do with ATL, WTL or STL
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
SYSTEMTIME t1;
SYSTEMTIME t2;
GetSystemTime(&t1);
GetSystemTime(&t2);
CTime tme1(&t1);
CTime tme2(&t2);
tme1 == tme2 ? TRUE : FALSE;
|
|
|
|
|
Hi
I had two diffrent
class Student
{
public:
string name;
int age;
};
list<student*> _studentList1;
list<student*> _studentList2;
I just want to compare wheather the content of two list are same.
Can any one tell me how to do that.....
Below i have implemented one example
for(std::list<student*>::iterator iterator1 =_studentList1.begin();studentList1.end() != iterator1; ++iterator1)
{
for(std::list<student*>::iterator iterator2 =_studentList2.begin();studentList2.end() != iterator2; ++iterator2)
{
Student* studentDetails1 = *iterator1;
Student* studentDetails2 = *iterator2;
if(!strcmp(studentDetails1->name ,studentDetails2->name)
if(studentDetails1->age== studentDetails2->age)
}
}
Is this is best approach to compare List
++iterator)
Thanks in advance
|
|
|
|
|
No, it's not the best way - the best way would be to define an operator== for Student, then use the operator== defined for std::list. Also - isn't the 'name' member a std::string? In which case that has an operator==
Anyway - I'd do this:
class Student
{
public:
std::string name;
int age;
friend bool operator==(Student const& left, Student const& right)
{ return left.age==right.age && left.name==right.name; }
};
std::list<Student> _studentList1;
std::list<Student> _studentList2;
Then in code, I could do
if (_studentList1 == _studentList2)
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi
I am building a out of proc COM Server, which would be registered as service. I want my server to be a singleton, so I have declared DELCARE_CLASSFACTORY_SINGLETON in my coclass. My server startup code RegisterClassObjects with REGCLS_MULTIPLEUSE flag. However, it is possible to launch 2 instances of my server process; one that is launched by the service manager and running under the system account; the second one can be launched from the current user's account.
How do I prevent mutiple instances of my COM server, irrespective of the user accounts?
Thanks in advance
Vivek Ragunathan
|
|
|
|
|
You can create a global named mutex to prevent running multiple instances of an EXE across multiple use accounts.
Prefix the mutex name with "Global\"
Use CreateMutex[^] to create the object.
If calling GetLastError[^] after this returns ERROR_ALREADY_EXISTS the EXE can quit itself using PostQuitMessage[^].
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks. That is one way to solve the problem.
But what I am really looking for is a way that COM infrastructure would take care of. What this means is I should not report error to the user, instead return the reference of the already created COM object.
If the COM server is launched as service and all users connect to it using CoCreateInstance, they get the same reference. But when the COM server is launched using the current user account, things are screwed up as a second instance is created. Instead COM should not create the second instance, instead return the reference of the COM object hosted in the service.
Thanks
|
|
|
|
|
The syatem scrollbar is overrided, but it shows both of system amd myself. Can I kill the system's or hide it? Help me, please! Thank you!
|
|
|
|
|
Hi,guys!
I want to develop a COM control that can be used by other people.
First, i want develop a MenuBar using ATL,and then this MenuBar can be drag in other frame window.
I'm using vs 2005,how can i get this? Any tutorial articles or source code for this ?
Any help would be appreciate !
modified on Wednesday, August 12, 2009 1:48 AM
|
|
|
|
|
Hi, guys, I'm writing simple tool for interest, like managing softwares, file association or IE history.
But when I get into this field, I find there are many information stored in files or registry. Like "index.dat" or "HKLM\SOFTWARE\Clients".
So I want to know, where I can get more information about such thing( registry about shell )?
Thanks in advance.
|
|
|
|
|
You could start here for information on the Windows Registry. But please take note of the warnings about changing values inside the Registry, as it is easy to get it wrong and make your system unusable. Also try searching CodeProject and Google.
modified on Tuesday, September 8, 2009 5:58 PM
|
|
|
|
|
Thank you very much.
I'm one developer.
I try to MSDN/Google/CodeProject etc, when I encounter problems.
But I want one way to know what registry keys and values mean, such as how to set default browsers, how to change advanced UI of windows etc.
So I can solve problems more professional.
|
|
|
|
|
SpringLion wrote: I want one way to know what registry keys and values mean
Your question is beyond the scope of these forums. There are hundreds of registry keys and values but no standard work of reference to describe them all. Try this site for a start, and then when you have a single question about a specific registry key, come back here and post your question.
|
|
|
|
|
|
|
how to find Textbox value in the DirectUI
I did not find the use of API GetWindowText
|
|
|
|
|
DirectUI is completely undocumented, all you can hope for is that someone has reverse-engineered how that control works and posted about it on the net.
--Mike--
Dunder-Mifflin, this is Pam.
|
|
|
|