Processing
 

Blank icon upon initial start of CDHtmlDialog window

26/07/2016 19:01#1

Hugh

Member

Joined at: 10 months ago

Post: 6

Thank: 0

Thanked: 0

I have an application written in Visual C++ 2010 I'm working on that uses CDHtmlDialog windows to create the UI. Upon first startup in Windows 8/8.1/Server 2012, if the taskbar is set to "Combine when taskbar is full" or "Never combine" taskbar buttons (whether prior to or after first startup), the taskbar will display a blank page icon for the application. If the dialog window is closed and reopened, the icon will be correct, even after a reboot; ie. this only happens on initial startup after install. This does not affect Windows XP, 7, or 10.

I at first suspected icon loading within the CDHtmlDialog windows, which includes code that seems to be widely used.

CWindowDHtmlDialog::CWindowDHtmlDialog(CWnd* pParent) :   CDHtmlDialog(CWindowDHtmlDialog::IDD, 0, pParent) {     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); }  BOOL CWindowDlg::OnInitDialog() {     CDHtmlDialog::OnInitDialog();     // Set the icon for this dialog.  The framework does this automatically     //  when the application's main window is not a dialog     SetIcon(m_hIcon, TRUE);         // Set big icon     SetIcon(m_hIcon, FALSE);        // Set small icon }  // If you add a minimize button to your dialog, you will need the code below //  to draw the icon.  For MFC applications using the document/view model, //  this is automatically done for you by the framework.  void CWindowDlg::OnPaint() {     if (IsIconic())     {         CPaintDC dc(this); // device context for painting          SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);          // Center icon in client rectangle         int cxIcon = GetSystemMetrics(SM_CXICON);         int cyIcon = GetSystemMetrics(SM_CYICON);         CRect rect;         GetClientRect(&rect);         int x = (rect.Width() - cxIcon + 1) / 2;         int y = (rect.Height() - cyIcon + 1) / 2;          // Draw the icon         dc.DrawIcon(x, y, m_hIcon);     }     else     {         CDHtmlDialog::OnPaint();     } } 

However, manipulating this code doesn't appear to have any effect on the window or icons at all.

Next, I suspected the icon order and available sizes in the .ico file, so I replaced it with a test icon that contained all available sizes (from 16x16x4bit to 256x256x32-bit) but to no avail.

I also attempted to check for a registry change immediately after first startup, since this issue only affects first startup, but there were also no changes (at least to registry entries relevant to our application). Also, an uninstall resets this behaviour so that the icon is again blank after install, so this reduces the chance that it is a registry issue.

I also checked for issues in the .rc file, particularly with the IDR_MAINFRAME icon ID, but modifications to the .rc file or to the IDs made no difference.

Changing the .ico file that IDR_MAINFRAME points to does make a difference, but this is expected and I suspect that once VS does something to load the icon, it may be difficult to find a way to control what VS does with it. Since Win XP, Win 7, and Win 10 don't exhibit the same behaviour, it may be something specific that Win 8/8.1/2012 does to taskbar icons.

Start menu and desktop icons are correct, and pinning or unpinning the taskbar icon makes no change.

The issue may very well have nothing to do with CDHtmlDialog, but I can't be certain of that.

Similar articles

Window Registry create key not working in java

4 months ago - Reply: 1 - Views: 74

Metro App crash on Windows 10

4 months ago - Reply: 2 - Views: 115

.dll file missing after php upgrade

5 months ago - Reply: 1 - Views: 27

Notepad++ launch multiple HTML within browser

5 months ago - Reply: 0 - Views: 2

Access 2003 freezing

5 months ago - Reply: 0 - Views: 2

Icon Handler Shell Extension not called

5 months ago - Reply: 1 - Views: 23

Border color of combox does not change - Windows 8

5 months ago - Reply: 3 - Views: 140

VB.NET error DatagridViewCellValueChanged Windows 8

6 months ago - Reply: 1 - Views: 40

I made a mistake when installing Hyper-V [on hold]

6 months ago - Reply: 0 - Views: 7

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re