Archived

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

Pav

Win32 hell :( pls help :(

Recommended Posts

hi..PLEASE help me Iv'e been using Visual C++ 6 for more than a year now, but until today i only used it for OpenGL, and never thouched the "Win32 programming" of it. ok, here's the thing... I create a window..overlapped and everything...all ok. i set all the brushes,styles and whatever and get an empty cool window. all ok. Now i'm trying to put controls in it (such as command buttons, radio boxes and checkboxes), but all iv'e been able to accomplish is that a stupid dialog box appears like a message box, and the controls i wanted to be in the main window , appear in it please help me! how do i make a command button appear in the main window? (o, and i'm not using OOP or MFC, just pure Top-Down Win32 programming) (in Visual Basic it took about half a second to make a window with a button in it and it seems imposible in VC HELP! Edited by - Pav on January 16, 2002 7:32:42 AM

Share this post


Link to post
Share on other sites
It sounds like you''re mixing up the dialog editor and the CreateWindow/CreateWindowEx stuff. To you, they are separate entities. If you create a window using CreateWindow*, you can add controls to it using more calls to CreateWindow. A nice example would be to add a pushbutton:

//These should all have sensible values, of course
char *text;
int x, y, width, height, ID;
HWND parentwindow;
HINSTANCE instance;

//Actually create the button
CreateWindow ((LPSTR)"BUTTON", text, WS_CHILD | WS_VISIBLE, x, y, width, height, parentwindow, (HMENU)ID, instance, NULL);


If you use the dialog editor, the form you place the controls on is also a window. If you only use standard controls, it''s probably easiest to use only dialogs. If you create a dialog with its type set to "Child", you can use it inside another window...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
WM_COMMAND in your wndProc.
Simple put, look in MSDN to find which message the "BUTTON" window send

Share this post


Link to post
Share on other sites
quote:
From MSDN: CreateWindow
The following predefined control classes can be specified in the lpClassName parameter. Note the corresponding control styles you can use in the dwStyle parameter.

Class: BUTTON
Meaning:
BUTTON Designates a small rectangular child window that represents a button the user can click to turn it on or off. Button controls can be used alone or in groups, and they can either be labeled or appear without text. Button controls typically change appearance when the user clicks them. For more information, see Buttons.

For a table of the button styles you can specify in the dwStyle parameter, see Button Styles.



quote:
From MSDN: WM_COMMAND

WM_COMMAND


The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.
WM_COMMAND 
wNotifyCode = HIWORD(wParam); // notification code
wID = LOWORD(wParam); // item, control, or accelerator identifier
hwndCtl = (HWND) lParam; // handle of control


Parameters


wNotifyCode
Value of the high-order word of wParam. Specifies the notification code if the message is from a control. If the message is from an accelerator, this parameter is 1. If the message is from a menu, this parameter is 0.

wID
Value of the low-order word of wParam. Specifies the identifier of the menu item, control, or accelerator.

hwndCtl
Value of lParam. Handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL.


Return Values


If an application processes this message, it should return zero.

Remarks


Accelerator keystrokes that select items from the window menu are translated into WM_SYSCOMMAND messages.

If an accelerator keystroke occurs that corresponds to a menu item when the window that owns the menu is minimized, no WM_COMMAND message is sent. However, if an accelerator keystroke occurs that does not match any of the items in the window''s menu or in the window menu, a WM_COMMAND message is sent, even if the window is minimized.

If an application enables a menu separator, the system sends a WM_COMMAND message with the low-word of the wParam parameter set to zero when the user selects the separator.

The moral of the story? RTFM - Read The Fucking Manual. (If you don''t have it installed, it''s available online here

(No offence, but people who say "Okay, I''ve done A; now what?" without looking around and trying to do B on their own make me sick).

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi, I thought using editor-created windows inside self-created windows was not possible ( at least without mfc ). I would be very happy if you said I''m wrong ( and possibly gave some more details if possible... )

Share this post


Link to post
Share on other sites