Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Win32 Questions 1

Status
Not open for further replies.

Kalisto

Programmer
Feb 18, 2003
997
GB
I am playing around with Win32, and have got past the basic make a simple window, all in the c++ file.

I now want to encapsulate my window inside a class, so I can simply create different kinds of window from a common base.

Am I correct in assuming that each window I create needs it’s own wndproc to handle messages and events?

If so, I guess that all I need to do to create a type of window is to fill in a window structure with the appropriate data, and add to it a function pointer to the wndproc contained in my window class?

How then is the best way to handle multiple windows? (such as having my main frame displaying data in the form of a graph, and having other windows that are acting as dialog and text editing boxes that float above the graph.)

Would you have the main application control all the creation and deletion of these other windows, or would you delegate it to the main graph window? And if a window was active, and a message occurred that is meant for a different window, how can I control that (eg if the graph is constantly updating in the background from real time data, but the user has had a text box window open)

Thanks

K
 
As first parameter your window callback function receives the handle of message destination window.
 
So would you have all your callback functions in your winmain file, or have one associated with each window class ?
 
Callback functions belong to the .cpp file where window dialog has been implemented.

> Would you have the main application control all the
> creation and deletion of these other windows, or would
> you delegate it to the main graph window?

Creation of all subwindows is responsibility of callback function of the main window - as a responce to the WM_CREATE event. Further messages processing is responsibility of callback functions of subwindows-controls.

> And if a window was active, and a message occurred that
> is meant for a different window, how can I control that
> (eg if the graph is constantly updating in the background
> from real time data, but the user has had a text box
> window open)

Each window callback function will receive messages of its own window - graph updating message will be dispatched to graph window and text entering messages - to the edit control window.
 
OK, I think I understand. I guess the thing to do is to try it and see!

Cheers,
K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top