|
The WM_CLOSE will probably only affect the window to which it was targeted. If you are truly posting messages to the thread's message queue, then they are processed independant of a window being opened or not. Messages posted to a thread queue will have a HWND parameter of 0.
|
|
|
|
|
Sorry for not expressing it clearly.The exact meaning is posting message to a window, What I want to know is that if other messages can be post to a window after WM_CLOSE message was already queued, there may be memory leak when message parameters wParam or lParam is really a pointer and must be deleted in the message handling function.
The background of this question is:there is an object created in the heap and there are more than one window need to process this object.We post this object as
a pointer in the parameter wParam and decrease the object reference after processing it.If message was post to the window's message queue but not processed by the window, then reference counter will never be decreased and the object will
never be deleted.So memory leak happens!
Anybody knows how to process this kind of problem?
|
|
|
|
|
You'll need to handle the WM_DESTROY [^] notification, which is sent to your window when it is destroyed. In that handler, use PeekMessage [^] to look for occurrences of your user-defined message. Using the returned WPARAM and LPARAM values for the message(s), free the memory. As a final bit of cleanup, set the last parameter to PeekMessage to PM_REMOVE to remove the messages from the queue.
Software Zen: delete this;
|
|
|
|
|
All,
I have created a MDI application. In that, I have created many child frames and able to display/show during the application startup.
But, whenever a child window is created, the system automatically appends a new menu item to the window menu. The text of the menu item is the same as the text on the menu bar of the new child window. By clicking the menu item, the user can activate the corresponding child window. When a child window is destroyed, the system automatically removes the corresponding menu item from the window menu.
It seems that, the system can add up to ten menu items to the window menu. When the tenth child window is created, the system adds the More Windows item to the window menu. Clicking this item displays the Select Window dialog box. The dialog box contains a list box with the titles of all MDI child windows currently available. The user can activate a child window by clicking its title in the list box.
How to avoid this and I don't want the system or the framework automatically appends a new menu item to the window menu. I want to restrict this urgently.
Is there any way to restrict this ?
Any suggestions ?
Regards,
Siva
|
|
|
|
|
any suggestions or tricks from anybody from the forum ?
|
|
|
|
|
Hi,
I implemented an XP theme into my application which was orignially written in visual C++ 6.0. I followed the steps recommended here
http://www.codeproject.com/w2k/xptheme.asp
What I have found is that the combo boxes in read only form have not turned out as they should. They should be greyed out with the drop down button on the right of the combo box. But instead they look like edit boxes that are greyed out. Anyone know how to get the button back to the right of the combo box (so that it looks like a combo box and not an edit box)?
Many thanks !
|
|
|
|
|
why don't you directly ask in the article message bord at the bottom of the article ?
the author will certainly be able to answer better than anyone
|
|
|
|
|
Actually, it's probably better to ask here since this question doesn't really address the article as much as it addresses standard windows control behavior.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Options:
1) The button is a window, so if you can get a hwnd to that button, you should be able to disable it. Create a basic dialog-based app with a single combo box control in it, and use Spy++ to see if you can get the necessary info about the various parts of the control.
2) You may have to set the control to be owner-drawn so you can handle the disabled appearnce manually.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
And googling found this article right here on CodeProject:
http://www.codeproject.com/cs/miscctrl/disabledcombodisplay.asp[^]
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
Try this
typedef HRESULT (__stdcall *DllRegSvr)();<br />
HMODULE hModule = LoadLibrary("dll path");
|
|
|
|
|
Thanks. Got it working
|
|
|
|
|
Welcome .
|
|
|
|
|
Just try not to do it in the DllMain handler for your DLL.
You can run into locking issues - Windows only wants to load a single DLL within your process at a time and process the DllMain.
|
|
|
|
|
Hello all,
I have List Box and rich edit box in my Dialog IDC_SLIST & IDC_FILECONT
List Box contains the text file names , When the user double click on the list box that file content should be displayed in the rich edit box.
Can u please tell me what all the changes I have to make and how to do the double click event in Api application ??
<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam))<br />
{ <br />
case LBN_DBLCLK:<br />
{<br />
HWND hwndListBox = GetDlgItem(hwnd, IDC_SLIST);<br />
int iCurSel =::SendMessage(hwndListBox,LB_GETCURSEL,0,0);<br />
TCHAR FName[25];<br />
SendMessage(hwndListBox,LB_GETTEXT,(WPARAM)iCurSel,(LPARAM)FName);<br />
<br />
<br />
CStdioFile file(FName, CFile::modeRead);<br />
DWORD dwSize = file.GetLength();<br />
char *pBuffer = new char[dwSize + 1];<br />
UINT uRead = file.Read(pBuffer, dwSize);<br />
pBuffer[uRead] = '\0';<br />
file.Close();<br />
<br />
HWND hwndRichEdit = GetDlgItem(hwnd, IDC_FILECONT);<br />
SendMessage(hwndRichEdit,EM_SETTEXTMODE, pBuffer,0);<br />
delete [] pBuffer;<br />
}<br />
<br />
Thanking you,<br />
Suresh HC<br />
<br />
<br />
-- modified at 5:37 Friday 16th February, 2007
|
|
|
|
|
Suresh H wrote: SendMessage(hwndRichEdit,EM_SETTEXTMODE, pBuffer,0);
Use ,
::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)pBuffer);
|
|
|
|
|
Hi Prasad,
Thank you very much for the response.
I tried with this code but no response list box double click event is not working.
<br />
case LBN_DBLCLK:<br />
{<br />
MessageBox(hwnd, "DB click!","DB click event", MB_ICONEXCLAMATION | MB_OK);<br />
}<br />
break;
and also I am not able to use CFile , this works in MFC but I am using win 32 api, what changes I have to make ???
<br />
CStdioFile file(FName, CFile::modeRead);<br />
DWORD dwSize = file.GetLength();<br />
char *pBuffer = new char[dwSize + 1];<br />
UINT uRead = file.Read(pBuffer, dwSize);<br />
pBuffer[uRead] = '\0';<br />
file.Close();<br />
|
|
|
|
|
Do you have LBS_NOTIFY on your listbox?
From the MSDN
Only a list box that has the LBS_NOTIFY style will send this message.
|
|
|
|
|
Hi WhiteSky,
Thanks for the responce.
How to check ????
|
|
|
|
|
Insert LBS_NOTIFY when create listbox
<br />
hList=CreateWindowW(_T("LISTBOX"),NULL,LBS_NOTIFY|WS_BORDER|WS_CHILD|WS_VISIBLE,0,0,100,200,hWnd,(HMENU)IDC_SLIST,hInst,0); <br />
|
|
|
|
|
Hi whiteSky,
I did that in the
<br />
BOOL CALLBACK SDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch(Message)<br />
{<br />
case WM_INITDIALOG:<br />
{<br />
<br />
HWND hwndListBox = GetDlgItem(hwnd, IDC_SLIST);<br />
hwndListBox=CreateWindowW(_T("LISTBOX"),NULL,LBS_NOTIFY|WS_BORDER|WS_CHILD|WS_VISIBLE,0,0,100,200,hwnd,(HMENU)IDC_SLIST,hwndListBox,0);<br />
<br />
i am getting error
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'char [8]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
|
|
|
|
|
I wanted to said insert LBS_NOTIFY when create your listbox
|
|
|
|
|
WhiteSky I am using wizard for creating dialog and dialog controls , I am not using any code to create the dialog.
|
|
|
|
|
He has created list box, shown in above post.
|
|
|
|
|