NO

Author Topic: Working with multiple windows  (Read 3255 times)

Xeon

  • Guest
Working with multiple windows
« on: August 23, 2014, 04:33:46 AM »
I often see examples with just a single window and a few child dialogs but how would someone go about creating a multiple window application, with each window able to do things at the same time?

Would I need to use threading? Is there a good example of this somewhere?

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Working with multiple windows
« Reply #1 on: August 23, 2014, 05:27:38 PM »
That's normally named MDI (multiple documents interface) programming.
Detailed info can be found here.
They are used also in many sample codes in PellesC, see here.
About the single or multithreading execution it is just your choice dependent on what you need. You can create as many windows as you need in both cases, the difference is that with a single execution thread all the actions will be executed one at time (serialized) in a multithreaded environment you can execute more actions concurrently.
Be aware that window interface pose some limitations in multithreading, a window created in a thread cannot be fully managed in another thread! For each window API look carefully in the documentation if there is any thread limitation when you use them.
The normal coding practice is to use one thread for the GUI (creates all windows and manages all graphical interface) while the other threads are created for a specific purpose (take care of comms, I/O, long math calculation, etc.).
« Last Edit: August 23, 2014, 05:35:55 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Xeon

  • Guest
Re: Working with multiple windows
« Reply #2 on: August 26, 2014, 03:29:06 AM »
That's normally named MDI (multiple documents interface) programming.
Detailed info can be found here.
They are used also in many sample codes in PellesC, see here.
About the single or multithreading execution it is just your choice dependent on what you need. You can create as many windows as you need in both cases, the difference is that with a single execution thread all the actions will be executed one at time (serialized) in a multithreaded environment you can execute more actions concurrently.
Be aware that window interface pose some limitations in multithreading, a window created in a thread cannot be fully managed in another thread! For each window API look carefully in the documentation if there is any thread limitation when you use them.
The normal coding practice is to use one thread for the GUI (creates all windows and manages all graphical interface) while the other threads are created for a specific purpose (take care of comms, I/O, long math calculation, etc.).

Ohh ok, I don't know why it didn't click before. I didn't realize the message loop sent messages to all the appropriate window procs. I thought you had to have a message loop for each window.