Create 2 Forms with the API32

Windows specific questions.
Post Reply
Tolo68
Posts: 105
Joined: Mar 30, 2020 18:18
Location: Spain

Create 2 Forms with the API32

Post by Tolo68 »

Hello everyone, one question.

In VB6, a project that has 2 Forms
In Form1 there is a button, which shows Form2 with Form2.show

To do this with the API, I need a WNDCLASS class for each form ??
And the message loop, is it the same for the 2 forms??

What would a simple example look like with the CreateWindowEX API?

Thank you!!
Lothar Schirm
Posts: 438
Joined: Sep 28, 2013 15:08
Location: Germany

Re: Create 2 Forms with the API32

Post by Lothar Schirm »

Here is an example (in German, maybe Google can help you to translate?): https://www.freebasic-portal.de/tutoria ... 4-s11.html
Tolo68
Posts: 105
Joined: Mar 30, 2020 18:18
Location: Spain

Re: Create 2 Forms with the API32

Post by Tolo68 »

Thank you Lothar.
I know this website, there are very good examples, but I had not seen this one, I will try it. Best regards
Tolo68
Posts: 105
Joined: Mar 30, 2020 18:18
Location: Spain

Re: Create 2 Forms with the API32

Post by Tolo68 »

Hello Lothar.

I tried the example of the web, and I liked it, but I don't know how to capture messages from non-main windows.
It only captures messages from the main window.

For example, the message WM_MOUSEMOVE

Thank you
Lothar Schirm
Posts: 438
Joined: Sep 28, 2013 15:08
Location: Germany

Re: Create 2 Forms with the API32

Post by Lothar Schirm »

Hello Tolo68,
I have only some basic knowlege of Windows API and do not use it often, only to create some simple controls on one window, so I cannot answer your question. I did not test the code. Maybe you can post your code here so that somebody else can help you?
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: Create 2 Forms with the API32

Post by kcvinu »

@Tolo68,
You only need a single Window class and a single WndProc function for this. You can handle all the messages from both window in that single wndproc. But remember one thing. When, handling WM_DESTROY message, check whether the hWnd parameter is the handle of the main window or not. If it is the handle of the main window, just call PostMessage(0) to close the entire program. Otherwise, just return, Windows will close the secondary window.
Lothar Schirm
Posts: 438
Joined: Sep 28, 2013 15:08
Location: Germany

Re: Create 2 Forms with the API32

Post by Lothar Schirm »

Here is a nice example by dodicat ("custom message box"): viewtopic.php?t=27725
Another example with multiple windows by bojan.dosen: https://freebasic.net/forum/viewtopic.php?t=20537
Post Reply