Search code examples
windowatlfirebreathwtl

firebreath plugin create a full screen window, but the window always under the browser window when it appers, how can I bring it to top


CaptureScreenApp app;

int MyPluginAPI::captureScreen(const FB::JSObjectPtr& callback)
{
    boost::thread cs(boost::bind(&CaptureScreenApp ::captureScreen,
        app, callback));
    return 1;
}

class CaptureScreenApp {
public:
    CaptureScreenApp() {
        HRESULT hRes;
        hRes = OleInitialize(NULL);
        ATLASSERT(SUCCEEDED(hRes));
        AtlInitCommonControls(ICC_WIN95_CLASSES);
        g_Module.Init(NULL, NULL);
    };
    ~CaptureScreenApp() {
        g_Module.Term();
        OleUninitialize();
    };

    bool captureScreen() {
        CMessageLoop theLoop;
        CMainDialog g_MainDlg;
        g_Module.AddMessageLoop(&theLoop);
        if (NULL == g_MainDlg.Create(NULL)){
            DWORD ret = GetLastError();
            return FALSE; 
        } 
        g_MainDlg.ShowWindow(SW_SHOW);
        g_MainDlg.UpdateWindow();

        int nRet = theLoop.Run();
        g_Module.RemoveMessageLoop();
        return TRUE;    
    };
};

class CMainDialog : public CDialogImpl<CMainDialog>
{
public:
    enum {IDD = IDD_MAIN};
    ....    
}

the window(the new window is a full screen window with a desktop pic as the background) I create in CaptureScreenApp::captureScreen always under the browser window when it appears(browser window always actived in other word), what ever how I set the HWND_TOPMOST for the new window. like this:

enter link description here

how can i bring the full screen window to top when it appers?


Solution

  • SetWindowPos API lets you change Z order (make sure to read Remarks there). You create your window with NULL parent, so your window is completely independent from browser window, so there is nothing to push it to the front: it would be either you or interactive user.