   Win32, Dialogs or real windows?
  Hi guys,I have a question concerning pop up windows in most programs that were made using the win32 API. Are all the child windows that are usually accessed from the menu dialogs or windows created from your own class? I can create dialogs and display them, but I want to create another child window from a new window class. When would it be best to register this class? WM_CREATE of the parent window procedure? I'm really unsure as I don't like using global data, plus, if I don't define the window class in WinMain, I don't know where to get hInstance from. I'm also not sure if I should even pass hInstance to the window class of the future child window...would that be needed?Cheers,Brick   
  Well, I think if you don't need many windows (Ony one game window for example), it's best to register a WNDCLASS and create it right in your code. But if you need many of them you might use Dialogs instead (When they must contain controls).I did not notice any disadvantages of that... Or are there any?   ;  For Win32 it doesn't matter where you register a class. It just needs to be before usage ;)For the instance handle, you can also use GetModuleHandle( NULL ) to get the current process' HINSTANCE handle. So you don't need to pass it around.The differences between dialog and a "normal" window are not that big. A dialog is basically a common class derived from a normal window. Dialogs support some extra functionality for modal display. You would have to code that from scratch with a normal window, but would be doable as well.   ;  Thanks for the replies so far. Would the window class have to remain in memory throughout the entire program? I create my main window class in my WinMain function and therefore it remains in scope. Or can I define the window class in a seperate file and function, use RegisterClassEx and CreateWindowEx on it and then just let it go out of scope? Or should I put it on the heap if the windows might need it again?Cheers,Brick   ;  You refer to the WNDCLASS(EX) struct? Once RegisterClass(Ex) is called you can let it drop out of scope.Windows automatically unregisters all classes on application exit. Unless you called it from a DLL. If you use RegisterClass inside a DLL you have to manually call UnregisterClass before the DLL unloads.   ;  I'm not using a DLL, so thanks, I'll just let it go out of scope then. Thanks for the info.   