How to create a simple dialog in win32?

Discussion in 'Win32' started by adrian, Jun 26, 2009.

  1. adrian

    adrian New Member

    Joined:
    Jun 26, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I need a simple dialog with nothing on it (can't get simpler than that). I am fighting with this antiquated system using VC++6.0/MFC and LabVIEW 7.0. When I try and create a Tooltip in the OCX that is going into LV, it doesn't show up.

    I then proceeded to do a lot of things, including a lot of swearing. I finally faked out a tooltip by way of a dialog generated by a resource, but I cannot get it to recognize the WS_EX_NOACTIVATE so that it doesn't grab focus. THIS IS THE VERY LAST THING I NEED TO DO! I will be leaving for holidays on Saturday and REALLY need this working before then.

    I got to the point where I figured that if I am going to get this working, I'm going to have to forgo the MFC crap (really old MFC crap at that) and drill down to the WIN32 layer to do this properly. But I've never been able to sucessfully generate a dialog before. I've tried to create a window class, registered that, and then tried to create the window from there without success.

    Here is the code:

    Code:
    BOOL MyCreate(HWND hwnd)
    {
        HWND       hWnd;
    
        HINSTANCE hInstance = ::AfxGetInstanceHandle();
    
        if (WndClsEx.cbSize == 0) {
            // Create the application window
            WndClsEx.cbSize        = sizeof(WNDCLASSEX);
            WndClsEx.style         = CS_HREDRAW | CS_VREDRAW;
            WndClsEx.lpfnWndProc   = CMyToolTip2::WndProc;
            WndClsEx.cbClsExtra    = 0;
            WndClsEx.cbWndExtra    = 0;
            WndClsEx.hIcon         = NULL;
            WndClsEx.hCursor       = NULL;
            WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
            WndClsEx.lpszMenuName  = NULL;
            WndClsEx.lpszClassName = ClsName;
            WndClsEx.hInstance     = hInstance;
            WndClsEx.hIconSm       = NULL;
    
            // Register the application
            RegisterClassEx(&WndClsEx);
        }
    
        // Create the window object
        hWnd = ::CreateWindow(
                ClsName,
                WndName,
                WS_POPUP,
                20,
                20,
                20,
                20,
                hwnd,
                NULL,
                hInstance,
                NULL);
        
        // Find out if the window was created
        if ( !hWnd )
        {
            int err = ::GetLastError();
            ASSERT(FALSE); // fails here with err = 0
        }
    }
    
    I pass to this the hwnd of the ActiveX container. What am I doing wrong?

    I really thank you for any help you can give me,


    Adrian
     
    Last edited by a moderator: Jun 26, 2009

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice