Win32 hell :( pls help :(

Started by
6 comments, last by Pav 22 years, 3 months ago
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
Advertisement
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 coursechar *text;int x, y, width, height, ID;HWND parentwindow;HINSTANCE instance;//Actually create the buttonCreateWindow ((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...

Kippesoep
and how do i receive messgaes from this push button? i mean which message should i check for if i click on it for example?
WM_COMMAND in your wndProc.
Simple put, look in MSDN to find which message the "BUTTON" window send
ok, iv''e managed to show the button on the main window of the app, but i can''t seem to find a way to get its messages...
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!
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... )
Anything you can do with MFC, you can do without it as well. MFC is just a helper library for C++ users.

Edited by - Kylotan on January 16, 2002 2:13:24 PM

This topic is closed to new replies.

Advertisement