Thread: Multiple Top Level Windows

  1. #1
    Registered User
    Join Date
    Jul 2008
    The UK

    Multiple Top Level Windows

    Hi All,

    Firstly I'm fairly new to Win32 GUI coding so please bear with me here...

    OK, I've created an application that consists of two windows, the main window implemented in winmain (RegisterClass(&wc) and CreateWindow with appropriate message loop and WndProc). I have a number of dialogs used throughout the application; these are fine. However, I have a requirement for a second form which has initially been implemented as a dialog.

    However, on doing so a number of issues have cropped up. I'm using a custom control to implement a gridview (excel, sort of), however, this control causes the CPU to hit 100% if the control is created, I assume because its message loop isn't suited to being in a dialog. Used on my main window, the control has no issues. Also, I will need to be doing some GDI work on the second form, probably as a custom control so I can see there being some further issues with using a dialog.

    With all of that in mind, what is the best way to implement my second form? I imagined it as a second top level window - I've tried two techniques - one with two message loops and one with one (in both cases I registered classes for both windows before creating with CreateWindow). In the first case, one of the message loops doesn't exit properly (which I suppose is to be expected, one message loop serves both of my top level windows in the second case). In the second case, if I call DestroyWindow for my second top-level window, the whole application is closed, which is not the idea.

    Basically, if there is a way without using dialogs, is it possible to have two top-level windows, with one being the main window whose destruction closes the application and the other being created and destroyed as needed? Am I close?

    I don't seem to be able to find any advice on the web; I've found a number of very useful Win32 tutorials that deal with creating applications of a single window and creating dialogs, as well as using most controls, but creating an application with two windows seems to be more difficult.

    Any pointers to online resources would be useful, I appreciate this could be quite complex and not easily explained in a forum. I understand there are some good books out there too; I wish I had the time to read them...

    Thanks in advance for any help you can offer,

    Last edited by quark_77; 07-13-2008 at 02:34 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  2. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  3. #Develop Question, How do i create multiple Windows?
    By Zeusbwr in forum C# Programming
    Replies: 0
    Last Post: 04-24-2005, 11:14 AM
  4. Dialog window with top level menu
    By Frandy in forum Windows Programming
    Replies: 2
    Last Post: 09-22-2004, 10:53 AM
  5. multiple console windows
    By gordy in forum A Brief History of
    Replies: 3
    Last Post: 02-13-2002, 11:05 PM