I'm learning Win32 api I know how to add pushbutton on the fly now I have a resource file (rse.rc) I'm trying to add a pushbutton using Below is my res.rc file definition:
IDB_B1 pushbutton "toggle", 7, 20, 180, 200, 30
and I created evn Is a source.h file for inclusion in the source. The problem I am facing now is how do I add this button to my main window? I tried to add a cursor and an icon using the .rc file which is easy but my head can not be found around this button.
I think it should be below:
WM_CREATE:
But how to fix it with .rc file?
This does not work in this way.
The resources in Win32 are used to create many things: menus, accelerators and dialogs, among others; But not single control
What you want to do, a main window with a button can be obtained by using two techniques:
- Become a dialogue of your main window you complete For the dialogue, write the resource with the button and everyone, and from
WinMain ()
you call CreateDialog ()
. dialog box ()
or similar. - Your main window is a normal window, and you manually create a child copy as an answer to
WM_CREATE
, as you guessed, the class name With WC_BUTTON
, these controls are created in the CreateWindowEx ()
call.
In addition to this, you can make a child a child of the main window, but I do not suggest that, especially if you are still learning.
No comments:
Post a Comment