Peter Below's Threaded Splash Screen and Modal Dialogs

前端 未结 3 478
说谎
说谎 2021-02-06 19:45

I\'m using Peter Below\'s PBThreadedSplashForm to display during application startup. It gets updated as various databases are opened during the creation of the data module (jus

相关标签:
3条回答
  • 2021-02-06 20:30

    If you're looking for an explanation, I can't help you.

    If you're looking for a solution, you're not the first. Eddie Shipman encountered this same problem in May. His proposed solution was to make the other dialog (the one hidden by the splash screen) be a topmost window, but he ultimately avoided the issue by hiding the splash screen before the application needed to display any other windows.

    Another suggestion was to post commands to the splash screen and have it display the message box. The dialog could be parented to the splash screen. It's tricky, though, because you're not afforded any of the luxuries of the VCL anymore since it doesn't work outside the main thread.

    0 讨论(0)
  • 2021-02-06 20:39

    You should be able to fix this by parenting the dialog to the splash screen. Assign the splash screen's HWND to a global variable, and override the dialog's CreateParams method. If the global HWND has a value assign it to the Params.WndParent variable that CreateParams passes in. The fact that they're from different threads shouldn't matter, since it's just dealing with the HWND, not a VCL object, and Windows will handle the synchronization.

    0 讨论(0)
  • 2021-02-06 20:43

    Ok. Finally got the problem solved. It appears to be caused by the WS_EX_NOACTIVATE flag in the call to CreateWindowEx(). Changing it to remove that seems to solve the problem; the modal dialog displays above the splash screen, and because it's modal the splash screen can't be brought above it.

    The working code is:

    
      FWnd := CreateWindowEx(
                TopmostStyle[ FTopmost ] or WS_EX_TOOLWINDOW
                or WS_EX_STATICEDGE or WS_EX_CLIENTEDGE,
                MakeIntResource( FWndClass ),
                nil,
                WS_POPUP or WS_BORDER,
                Forigin.x, Forigin.y,
                wsize.cx, wsize.cy,
                0, 0, hInstance, self );
    

    Thanks, Rob and Craig, for the efforts.

    0 讨论(0)
提交回复
热议问题