|
-
January 14th, 2006, 10:48 AM
#1
How to create/display a modal window? And surplus of win32 code
Hello,
I actually have two problems, but will start with a simple one.
I'm writing a usual but very raw win32 application, i.e. with:
#define WIN32_LEAN_AND_MEAN
and without any MFC (well, just a wish to use plain WinAPI along with C++).
My frist problem is I can't find info on how to create/display a modal window? I'm creating all my windows use "CreateWindowEx" and display my windows using "ShowWindow". In Delphi, I would simply write instead of FormX.Show, FormX.ShowModal. How can I do that with WinAPI?
And problem number 2:
This program's code becomes HUGE because of using WinAPI functions. The thing is, I have a lot of windows, and all those windows have many controls, which are also "windows" in terms of Windows as OS. So, for example, to create one button I have to write this:
Code:
// Create "Update Resolution" Button for UI
if (!(hButtonUpdateUI = CreateWindowEx
(
NULL,
"button",
"Update Resolution",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
225,65,
150, 24,
hMainWindow,
HMENU(CHANGE_UI_RESOLUTION_BTN),
(HINSTANCE) GetWindowLong(hMainWindow, GWL_HINSTANCE),
NULL
)
)
)
{
MessageBox(hMainWindow,"Could not create button control","Button creation failed",MB_OK | MB_ICONEXCLAMATION);
exit(0);
}
And I have a lot of buttons, edit controls, comboboxes, etc. on forms. For instance, one of my forms contains 32 (!) controls, now multiply 32 by 20 (LOC to create one control) == 640 lines of code (!) for just creating the controls Am I doing something wrong? Is there a way to avoid writing so much code? I'm just going to be lost in the code, the program will look very complicated while not being complicated at all! In fact, that's the reason I stopped writing the code for awhile, because I'm feeling that it's NOT done this way.
Any suggestions or help would be greatly appreciated.
Last edited by Xatrix; January 14th, 2006 at 10:51 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|