tags:

views:

57

answers:

2

Im trying to get a CDialog that has no border or frame to show in the task bar.

It is created in the InitInstance of CWinApp (used to update the app) and i have tried setting the WS_EX_APPWINDOW flag but it still doesnt show in the task bar.

Any ideas?

Edit: As defined in the resource:

IDD_UPDATEFORM_DIALOG DIALOGEX 0, 0, 246, 124
STYLE WS_POPUP
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
END

As used:

 UpdateForm *dlg = new UpdateForm(UPDATE_FILES, CWnd::GetDesktopWindow());
 INT_PTR nResponse = dlg->DoModal();


UpdateForm::UpdateForm(int updateType, CWnd* pParent) : CDialog(IDD_UPDATEFORM_DIALOG, pParent)
{
 m_bInit = false;
 m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON);
 m_Progress = new DesuraProgress();
 m_updateType = updateType;
}

Still Shows up like so:

http://update.goldeneyesource.net/lodle/noicon.jpg

+2  A: 

Edit #2:

To set the icon for this window (essentially a splash screen), you can send the window a WM_SETICON message along with a desired icon.

For a dialog, you can do this in OnInitDialog(). Here's a snippet that uses the default windows information icon as noted here: LoadIcon @ MSDN.

// CHelperDlg message handlers
BOOL CHelperDlg::OnInitDialog()
{
  CDialog::OnInitDialog();

  // 32516 is also known as IDI_INFORMATION
  HICON hIcon = LoadIcon(0, MAKEINTRESOURCE(32516));

  // 0 in WPARAM is 'small version'
  ::SendMessage(GetSafeHwnd(), WM_SETICON, 0, (LPARAM)hIcon);
  // 1 in WPARAM is 'large version'
  ::SendMessage(GetSafeHwnd(), WM_SETICON, 1, (LPARAM)hIcon);

  // No cleanup as HICONs are free from disposal rules.

  return TRUE;  // return TRUE unless you set the focus to a control
  // EXCEPTION: OCX Property Pages should return FALSE
}

--
Edit:

I created a second project to mimic your update, but I don't see any differences except the inclusion of DS_SHELLFONT (DS_SETFONT | DS_FIXEDSYS) in my .rc file. These dialog style definitions don't affect the display of the dialog.

I've uploaded key parts for my minimal example to http://gist.github.com/461057 for your reference, in case you'd like to try adding this dialog ahead of yours for testing.

Also, I'm using VS2010. I have VS2008 available if you'd like me to repeat this test in that version as well.

--
Original:

Try specifying the desktop window (via CWnd::GetDesktopWindow()) as the parent window when you create the dialog.

// Member Variable
CHelperDlg *dlg;

// Meanwhile, elsewhere...
dlg = new CHelperDlg();
dlg->Create(IDD_HELPERDLG, CWnd::GetDesktopWindow());
dlg->ShowWindow(SW_SHOW);
// or...
// dlg->DoModal();

Also, don't forget to destroy the dialog when you're done with it, either in the destructor of the class owner, or other convenient location.

meklarian
Hmm. Still not working
Lodle
Thanks for your help so far meklarian but i still cant get it working using your example. I uploaded it here: http://update.goldeneyesource.net/lodle/testMfcDialog.zip and when i drag it across to my second monitor it doesnt show any icon (shows default windows icon on main) where as the about dialog does
Lodle
got a copy of the download, looking at it now.
meklarian
perhaps i've misunderstood something here... it works and can also be dragged around with the snippet you added. do you also need to override/set the taskbar icon as well?
meklarian
added code to demonstrate how to set the icon.
meklarian
What windows are you using? On windows 7 it doesnt work as expected. Ill check it out on others when i get to work.
Lodle
Windows 7 Ultimate
meklarian
A: 

I figured out a hack to get this to work. Instead of disabling the toolbar/caption bar styles to get no border, i used SetWindowRgn to clip the frame and title bar. Same affect, less issues.

RECT rect;
GetWindowRect(&rect);
int w = rect.right - rect.left;
int h = rect.bottom - rect.top;

HRGN region = CreateRoundRectRgn(5, 30, w-5, h-5-30, 5, 5);
SetWindowRgn(region, true);
Lodle
Clever, but it's going to fail when someone has non-standard border sizes. Those are configurable, you know.
Mark Ransom
Hmm, any way to get the client area offset?
Lodle