0
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?

Roman R.
  • 68,205
  • 6
  • 94
  • 158
yyj
  • 15
  • 3

1 Answers1

0

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.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • thanks! As your suggest, use browser window as parent, chrome&firefox works, but IE still failed: the browser window is still front when call the jsapi first time, but the second time the it goes behind. – yyj Jul 11 '14 at 09:36
  • You can use Spy++ to inspect the effective layout of windows, then read carefully `SetWidnowPos` article to see your options of putting window into foreground (except/in addition to using parent window). – Roman R. Jul 11 '14 at 09:38
  • use the SetForegroundWindow(hwnd) I can bring the window front, but cannot keep it front when press ctrl+tab, this problem just comes on IE – yyj Jul 11 '14 at 12:00