Hi everyone.

I already know how to create a program using just one window.. but I'm having trouble creating a program with 2 windows.

I used CreateWindow() to create my second window, however, my second window displays exactly what is on my main window!

I figured the reason was because my WinProc function was handling messages for all windows (including the second window), and so on WM_PAINT, everything intended to be painted on the main window.. also gets displayed on the second window as well.

What I would like to know is how I would get my second window to have its window messages handled by a SEPERATE handling function (aside from WinProc).

Note: I've already managed to create a second WndProc function, the problem is.. I do not know how to set my second window.. to USE that second WndProc function. Even though there is a second WndProc function created.. my second window still utilizes the first WndProc function for all of its window messages!

Thank you for your help.

Recommended Answers

All 2 Replies

The idea with the WinProc function is that the first parameter "hwnd" is the handle of the window whose message belongs to. So what you need to do is have a simple conditional inside the WinProc to redirect the message handling depending if the hwnd is for the first or second window.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.