I need help on using controls.

Started by
2 comments, last by Squeejee 22 years, 5 months ago
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?
-----
Advertisement
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 windowhDefPushbutton = 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 buttonWS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,// x coord to appear on screen100,// y coord to appear on screen200,// width of window30,// height of window15,// parent of window, of type HWNDhwnd,// menu of a window, for a button i would use NULL(HMENU) IDOK,// instance of the program, used if more than one is runninghinstance,// extra data u want to send alongNULL);  


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
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
-----
  #include <tchar.h>  

This topic is closed to new replies.

Advertisement