HIMAGELIST m_ImageList;
SIZE m_Size;
HFONT m_Font;
- HBITMAP m_Bitmap;
public:
CStartButton(CMessageMap *pObject, DWORD dwMsgMapID)
if (m_Font != NULL)
DeleteObject(m_Font);
-
- if (m_Bitmap != NULL)
- DeleteObject(m_Bitmap);
}
HFONT GetFont()
return m_Size;
}
- VOID UpdateSize()
+ VOID UpdateSize(IN HBITMAP hbmStart = NULL)
{
SIZE Size = { 0, 0 };
if (m_ImageList == NULL ||
- !SendMessage(BCM_GETIDEALSIZE, 0, (LPARAM) &Size))
+ !SendMessageW(BCM_GETIDEALSIZE, 0, (LPARAM) &Size))
{
Size.cx = GetSystemMetrics(SM_CXEDGE);
Size.cy = GetSystemMetrics(SM_CYEDGE);
- if (m_Bitmap == NULL)
+ if (hbmStart == NULL)
{
- m_Bitmap = (HBITMAP) SendMessage(BM_GETIMAGE, IMAGE_BITMAP, 0);
+ hbmStart = (HBITMAP) SendMessageW(BM_GETIMAGE, IMAGE_BITMAP, 0);
}
- if (m_Bitmap != NULL)
+ if (hbmStart != NULL)
{
BITMAP bmp;
- if (GetObject(m_Bitmap, sizeof(bmp), &bmp) != 0)
+ if (GetObject(hbmStart, sizeof(bmp), &bmp) != 0)
{
Size.cx += bmp.bmWidth;
Size.cy += max(bmp.bmHeight, GetSystemMetrics(SM_CYCAPTION));
IconSize.cy,
LR_SHARED | LR_DEFAULTCOLOR);
- if (hIconStart != NULL)
+ if (hIconStart == NULL)
+ return FALSE;
+
+ m_ImageList = ImageList_Create(IconSize.cx,
+ IconSize.cy,
+ ILC_COLOR32 | ILC_MASK,
+ 1, 1);
+ if (m_ImageList == NULL)
+ return FALSE;
+
+ int s = ImageList_ReplaceIcon(m_ImageList, -1, hIconStart);
+ if (s < 0)
{
- m_ImageList = ImageList_Create(IconSize.cx,
- IconSize.cy,
- ILC_COLOR32 | ILC_MASK,
- 1,
- 1);
- if (m_ImageList != NULL)
- {
- int s = ImageList_ReplaceIcon(m_ImageList, -1, hIconStart);
- if (s >= 0)
- {
- return TRUE;
- }
+ /* Failed to add the icon! */
+ ImageList_Destroy(m_ImageList);
+ m_ImageList = NULL;
- /* Failed to add the icon! */
- ImageList_Destroy(m_ImageList);
- m_ImageList = NULL;
- }
+ return FALSE;
}
- return FALSE;
+ return TRUE;
}
HBITMAP CreateBitmap()
SendMessage(WM_SETFONT, (WPARAM) m_Font, FALSE);
- BUTTON_IMAGELIST bil;
+ if (CreateImageList())
+ {
+ BUTTON_IMAGELIST bil;
- /* Try to set the start button image. this requires the Common
- Controls 6.0 to be present (XP and later) */
- bil.himl = m_ImageList;
- bil.margin.left = bil.margin.right = 1;
- bil.margin.top = bil.margin.bottom = 1;
- bil.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT;
+ /* Try to set the start button image. this requires the Common
+ Controls 6.0 to be present (XP and later) */
+ bil.himl = m_ImageList;
+ bil.margin.left = bil.margin.right = 1;
+ bil.margin.top = bil.margin.bottom = 1;
+ bil.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT;
+
+ if (SendMessageW(BCM_SETIMAGELIST, 0, (LPARAM) &bil))
+ {
+ /* We're using the image list, remove the BS_BITMAP style and
+ don't center it horizontally */
+ SetWindowStyle(m_hWnd, BS_BITMAP | BS_RIGHT, 0);
+
+ UpdateSize();
+ return;
+ }
- if (SendMessage(BCM_SETIMAGELIST, 0, (LPARAM) &bil))
- {
- /* We're using the image list, remove the BS_BITMAP style and
- don't center it horizontally */
- SetWindowStyle(m_hWnd, BS_BITMAP | BS_RIGHT, 0);
- }
- else
- {
/* Fall back to the deprecated method on older systems that don't
support Common Controls 6.0 */
ImageList_Destroy(m_ImageList);
m_ImageList = NULL;
+ }
- HBITMAP hbmOld;
+ HBITMAP hbmStart = CreateBitmap();
+ if (hbmStart != NULL)
+ {
+ UpdateSize(hbmStart);
- m_Bitmap = CreateBitmap();
- if (m_Bitmap != NULL)
- {
- hbmOld = (HBITMAP) SendMessage(BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) m_Bitmap);
+ HBITMAP hbmOld = (HBITMAP) SendMessageW(BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hbmStart);
- if (hbmOld != NULL)
- DeleteObject(hbmOld);
- }
+ if (hbmOld != NULL)
+ DeleteObject(hbmOld);
}
-
- UpdateSize();
}
};
CheckTrayWndPosition();
/* Align all controls on the tray window */
- AlignControls(
- NULL);
+ AlignControls(NULL);
InitShellServices(&(m_ShellServices));