Advertisement

When do you create child windows?

Started by November 06, 2000 08:21 PM
3 comments, last by Orpheum 24 years, 2 months ago
I was wondering if there was a reason to call CreateWindow() for child windows from outside the WndProc(). Ive been studying this in my Win32 book, and from what I can gather it looks like if you want to create a static child window, then you should create it outside the main WndProc. For other things it looks like you should call CreateWindow() during the processing of a WM_CREATE message. Theres not nearly enough examples in this book for me to come up with a rule of thumb to live by, so I thought I would ask the experts... What criteria do you use to gauge when/where you should call CreateWindow()? Thanks!
There is no spoon.
HEY MODERATOR!! We need to be able to change message titles so people will read good questions with boring titles!

For those of you who do read this, where do you call CreateWindow?? In WinMain or WndProc? What about for static clidren? Non static children? A question of style!!
There is no spoon.
Advertisement
It doesn''t matter. Do it whichever way you want.

What I usually do is if I have a static set of windows I want then I call CreateWindow for each of them in my initialization routine rather than doing it in the WM_CREATE handler. The only reason is that if one of the creates fails it''s easier to step through the code if all the calls are in the same spot.

-Mike
As Mike mentioned, it is up to you to decide where you want to put your child creation routines. It''s all about preferences. What I would do is for static controls, I would create them in WM_CREATE, and for dynamic controls I would create them wherever I see fit.

If you don''t create them in WM_CREATE, your best bet is to put the code right after the code that creates the parent window.

Hope this helps!

-------------------------------
"Mind your own damn business!!!" - Gladiator

..-=gLaDiAtOr=-..
Well the style Ive adopted from my reading is to create static windows below the main window in WinMain, then create other child windows in WM_CREATE.
There is no spoon.

This topic is closed to new replies.

Advertisement