Win32-Controls
as i read from MSDN that with the Win32-API function CreateWindowEx() i can create standard-controls like buttons, comboboxes and other i tried this out. Up till now everthing works well but how can i react on the events and messages such a standard-control gets? Exists there a standard-Callback function or something other technique? What i want to develop is a Generic-Dialog which is generated at runtime depending on some parameters. Does anybody know how to do this?
Thanks
Peter Gmeiner
If you create a control on a window, the control will send notification messages to the parent window which should be handled in that window''s window procedure.
I wanna work for Microsoft!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam){ switch(message) { ... case WM_COMMAND: // this message received from most controls { // here figure out which control and what message specifically. // procedure varies depending on control type } return 0; ... }}
I wanna work for Microsoft!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Try searching for super-classing or sub-classing in MSDN.
It might be the one u r looking for.
It might be the one u r looking for.
In line with DerekSaw''s post, if you have a control that is not a child of any other control or window, then you can give it a window procedure by using SetWindowLong() and the GWL_WNDPROC index:
You can then handle messages to the window in ControlProc.
I wanna work for Microsoft!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
hwnd = CreateWindowEx(0, "BUTTON", ...);SetWindowLong(hwnd, GWL_WNDPROC, ControlProc);
You can then handle messages to the window in ControlProc.
I wanna work for Microsoft!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Thanks for the hints and tips.
But one more question to Oluseyi:
You wrote that this Messages of the controls were sended to the WindowProcedure of the parentwindow. How can I distinguish when a WM_COMMAND-Messages comes in from which control this message comes??
Thanks
Peter Gmeiner
But one more question to Oluseyi:
You wrote that this Messages of the controls were sended to the WindowProcedure of the parentwindow. How can I distinguish when a WM_COMMAND-Messages comes in from which control this message comes??
Thanks
Peter Gmeiner
quote:Original post by PGmeiner
How can I distinguish when a WM_COMMAND-Messages comes in from which control this message comes?
case WM_COMMAND;{ wNotifyCode = HIWORD(wParam); // notification code wID = LOWORD(wParam); // item, control, or accelerator identifier hwndCtl = (HWND) lParam; // handle of control switch(wNotifyCode) { case BN_CLICKED: // a button was clicked ... }}
MSDN is your friend.
I wanna work for Microsoft!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement