Making two Windows using CreateWindowsEx() - C

Posted by Jamie Keeling on Stack Overflow See other posts from Stack Overflow or by Jamie Keeling
Published on 2010-04-05T22:37:01Z Indexed on 2010/04/07 11:53 UTC
Read the original article Hit count: 372

Filed under:
|
|

Hello,

I have a windows form that has a simple menu and performs a simple operation, I want to be able to create another windows form with all the functionality of a menu bar, message pump etc.. as a separate thread so I can then share the results of the operation to the second window.

I.E.

1) Form A opens Form B opens as a separate thread

2)Form A performs operation

3)Form A passes results via memory to Form B

4)Form B display results

I'm confused as to how to go about it, the main app runs fine but i'm not sure how to add a second window if the first one already exists. I think that using CreateWindow will allow me to make another window but again i'm not sure how to access the message pump so I can respond to certain events like WM_CREATE on the second window.

I hope it makes sense.

Thanks!

Edit:

I've attempted to make a second window and although this does compile, no windows show atall on build.

//////////////////////
// WINDOWS FUNCTION //
//////////////////////
LRESULT CALLBACK WindowFunc(HWND hMainWindow, UINT message, 
                            WPARAM wParam, LPARAM lParam)
{
    //Fields
    WCHAR buffer[256];
    struct DiceData storage;
    HWND hwnd;

    // Act on current message
    switch(message)    
    {
    case WM_CREATE:
        AddMenus(hMainWindow);

        hwnd = CreateWindowEx(
            0,
            "ChildWClass",
            (LPCTSTR) NULL,
            WS_CHILD | WS_BORDER | WS_VISIBLE,
            0,
            0,
            0,
            0,
            hMainWindow,
            NULL,
            NULL,
            NULL);

        ShowWindow(hwnd, SW_SHOW);

        break;

Any suggestions as to why this happens?

© Stack Overflow or respective owner

Related posts about winapi

Related posts about forms