Archived

This topic is now archived and is closed to further replies.

Squeejee

I need help on using controls.

Recommended Posts

I am learning the windows api id my book does not do a good job at explaining controls. It says I need to create a ''dialog template'' an it gives me this as an example:
  
hDefPushbutton = CreateWindow(
                 _T("button"),
                 _T("OK"),
                 WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                 100,
                 200,
                 30,
                 15,
                 hwnd,
                 (HMENU) IDOK,
                 hinstance,
                 NULL);
  
Now what does that all mean and where do I put that?

Share this post


Link to post
Share on other sites
You can either create buttons on the fly (meaning in the code) or you can make a template and call it, the way you code looks you are creating it in the code. Since this is a child window, it should probably go inside your main procedure code (WndProc most likely). Possibly under WM_CREATE (when a window is created, and you want to do specific things with the window, put code in the create section)
what this is doing:
    
// returning a handle to a window

hDefPushbutton = CreateWindow(
// this is the window class, "button" is a predefined class

// _T() macro i don't remember, might be unicode

_T("button"),
// text to appear on the button

_T("OK"),
// bits to set about the window, child, visible and default button

WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
// x coord to appear on screen

100,
// y coord to appear on screen

200,
// width of window

30,
// height of window

15,
// parent of window, of type HWND

hwnd,
// menu of a window, for a button i would use NULL

(HMENU) IDOK,
// instance of the program, used if more than one is running

hinstance,
// extra data u want to send along

NULL);


if i'm being too basic, or not answering your question, respond and i'll try again

edit - } instead of ] *stupid sticky shift*

Edited by - Skibum on November 5, 2001 12:33:25 PM

Share this post


Link to post
Share on other sites
Ok, I put:

    
WNDCLASS hDefPushbutton;
hDefPushbutton = CreateWindow(
_T("button"),
_T("OK"),
WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
100,
200,
30,
15,
hwnd,
NULL,
hinstance,
NULL);



when a WM_CREATE message appears, and it gives me an error saying '_T' is an undeclared identifier.

Edited by - Squeejee on November 5, 2001 1:18:27 PM

Share this post


Link to post
Share on other sites