// JP opened flex table

Click to See Complete Forum and Search --> : Button problems


jonny_mac_99
January 16th, 2008, 06:58 AM
Im trying to create a button using the windows defined BUTTON class. However, once the button is created I cannot find the WndProc where I detect the WM_COMMAND message which has the notification code of BN_CLICKED.

I was of the understanding that it goes in the Proc of the parent window which in this case is a Dialog. Therfore I have placed the BN_CLICKED within the WM_COMMAND case of the DlgProc.

code for creating button:

m_hWnd = CreateWindow( L"BUTTON",
L"GUI Button",
WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_BITMAP,
m_xPos, m_yPos,
24, 24,
m_hParentHWND,
NULL,
m_hInst,
NULL );
hr = GetLastError();

m_hImage = LoadImage( m_hInst, m_bitmap, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
SendMessage( m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)m_hImage );



I've also trued creating my own WNDCLASSEX and registering it using Register class. The class is registered fine but then when I call CreateWindow its says it cannot find the window class????

Anyone any ideas?

Krishnaa
January 16th, 2008, 07:02 AM
WM_COMMAND is for the parent windows which hosts the BUTTON, in BUTTON's WndProc you will get the WM_MOUSEDOWN, WM_MOUSEUP messages, which in turn create WM_COMMAND for it's parent.

jonny_mac_99
January 16th, 2008, 07:50 AM
Where is the WndProc for BUTTON???

I havent created it and I dont know where it has been implemented?

MikeAThon
January 16th, 2008, 10:27 AM
Please tell us what you are trying to do. With respect to the description you provided so far, the windows framework will do all it automatically. In other words, when the button's wndproc gets mouse down followed by mouse up, the windows framework (actually, it's in the button wndproc again) will automatically send the parent of the button a BN_CLICKED notification. You don't need to do anything.

Are you perhaps trying to simulate a button click notification in code?

Mike

kirants
January 16th, 2008, 12:21 PM
In addition, please paste all code.

Where in your code is the CreateWindow call ?
What is the m_hParentHWND handle ?
Post your DlgProc code.
Curious, if you are having a dialog box, you most likely have a dialog template. If that is the case, why are you creating button at runtime instead of adding it to the dialog resource ?

srelu
January 17th, 2008, 12:17 AM
The 9-th parameter of the CreateWindow should be the control's identifier, in your case is NULL. I don't think Windows will bother to send any message if you don't provide a valid identifier. The presence of a valid identifier is mandatory, Windows needs it to set up the parameters of the WM_COMMAND message.

//JP added flex table