0
我有一個對話框,在其上用控件添加資源編輯器。但我試圖在WM_INITGDIALOG消息中動態創建一個工具欄,但工具欄不可見。還有其他事情要做嗎?(我不這麼認爲,但是......)。如果這是不可能的,如何在資源編輯器中添加一個工具欄。使用Win32 API添加工具欄對話框
正如你猜我使用VS 2008
CreateButtons(HWND hwnd)
{
HIMAGELIST m_hTBImageList;
HIMAGELIST m_hTBHottrack;
HWND hwndSysButtonTB = CreateWindowEx(0,
TOOLBARCLASSNAME,
_T(""),
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | CCS_NORESIZE | CCS_NOPARENTALIGN,
toolbarRect.left, toolbarRect.top, toolbarRect.right-toolbarRect.left, toolbarRect.bottom-toolbarRect.top,
hwnd,
(HMENU)IDR_TOOLBAR,
(HINSTANCE)hAppInstance,
NULL);
m_hTBImageList = ImageList_LoadImage((HINSTANCE)hAppInstance,
MAKEINTRESOURCE(IDB_BITMAP_ICONS), toolbarButtonSize.cx, 1,
0, IMAGE_BITMAP, LR_CREATEDIBSECTION|LR_SHARED);
m_hTBHottrack = ImageList_LoadImage((HINSTANCE)hAppInstance,
MAKEINTRESOURCE(IDB_MOUSEOVER), toolbarButtonSize.cx, 1,
0, IMAGE_BITMAP, LR_CREATEDIBSECTION|LR_SHARED);
SendMessage(hwndSysButtonTB, (UINT) TB_SETIMAGELIST, 0, (LPARAM)m_hTBImageList);
SendMessage(hwndSysButtonTB, (UINT) TB_SETHOTIMAGELIST, 0, (LPARAM)m_hTBHottrack);
SendMessage(hwndSysButtonTB, (UINT) TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
// win2k: set color of hot tracking frame
COLORSCHEME scheme;
scheme.dwSize = sizeof(scheme);
scheme.clrBtnHighlight = RGB(175,175,175);
scheme.clrBtnShadow = RGB(175,175,175);
SendMessage(hwndSysButtonTB, (UINT) TB_SETCOLORSCHEME, 0, (LPARAM)&scheme);
TBBUTTON ButtonEnd = {0,ID_BUTTON_END,TBSTATE_ENABLED,TBSTYLE_BUTTON};
TBBUTTON ButtonRefresh = {1,ID_BUTTON_REFRESH,TBSTATE_ENABLED,TBSTYLE_BUTTON};
TBBUTTON ButtonOptions = {2,ID_BUTTON_PROPERTIES,TBSTATE_ENABLED,TBSTYLE_BUTTON};
SendMessage(hwndSysButtonTB, (UINT) TB_ADDBUTTONS, 1, (LPARAM)&ButtonEnd);
SendMessage(hwndSysButtonTB, (UINT) TB_ADDBUTTONS, 1, (LPARAM)&ButtonRefresh);
SendMessage(hwndSysButtonTB, (UINT) TB_ADDBUTTONS, 1, (LPARAM)&ButtonOptions);
}
謝謝,它現在工作 – whoi