I am writing a browser helper object and want to show a child window inside the internet explorer window to show the user some messages. I use DS_CONTROL and WS_CHILDWINDOW and want to get a behaviour similar to the message in this image:
I succeeded in inserting and showing a child window, but the window is flickering and sometimes it's visible and sometimes the website content is above the window in the z coordinate. I tried to set the child window as topmost window, but that didn't change anything. How can I get the child window to be always visible until it is closed? Here is some source code I use:
resource.rc:
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"
//
// Dialog resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_NOTIFICATIONBAR DIALOG 0, 0, 186, 95
STYLE DS_3DLOOK | DS_CONTROL | DS_MODALFRAME | DS_SYSMODAL | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
EXSTYLE WS_EX_TOPMOST
FONT 8, "Ms Shell Dlg"
{
DEFPUSHBUTTON "OK", IDOK, 129, 7, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 129, 24, 50, 14
LTEXT "Static", IDC_STATIC, 25, 16, 68, 21, SS_LEFT
}
Dialog class:
#include "atlbase.h"
#include "atlwin.h"
#include "resources/resource.h"
class CMyDialog : public CDialogImpl<CMyDialog>
{
public:
enum { IDD = IDD_NOTIFICATIONBAR };
BEGIN_MSG_MAP(CMyDialog)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnBnClickedCancel)
END_MSG_MAP()
CMyDialog() {Create(::GetActiveWindow());}
~CMyDialog() {DestroyWindow();}
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,
BOOL& /*bHandled*/)
{
// ::MessageBox(NULL,_T("OnInit"),_T("OnInit"),MB_ICONINFORMATION|MB_OK);
// Do some initialization code
return 1;
}
static CMyDialog &getInstance()
{
static CMyDialog dlg;
return dlg;
}
public:
LRESULT OnBnClickedCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
ShowWindow(SW_HIDE);
return 0;
}
};
Call:
CMyDialog &bar=CMyDialog::getInstance();
bar.ShowWindow(SW_SHOWNORMAL);