我已经用工具栏编写了一个MDI应用程序,但子窗口覆盖了框架窗口的工具栏。这是效果,我必须单击左上角才能看到工具栏图标。
我使用以下代码创建工具栏:
CToolBar::CToolBar(HINSTANCE hInst, HWND hParent, LPCTSTR lpszWindowName) :
CWindow(hInst, hParent, lpszWindowName)
{
INITCOMMONCONTROLSEX icex;
// Ensure that the common control DLL is loaded.
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
lstrcpy(m_szClassName, TOOLBARCLASSNAME);
}
BOOL CToolBar::Create()
{
//create the toolbar
m_hWnd = CreateWindowEx(0, TOOLBARCLASSNAME, (LPCTSTR) NULL,
WS_CHILD, 0, 0, 0, 0, m_hParent,
(HMENU) ID_TOOLBAR, m_hInst, NULL);
//for backword compatibility
SendMessage(m_hWnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
if (m_hWnd == NULL)
return FALSE;
return TRUE;
}
BOOL CToolBar::Init()
{
TBBUTTON tbb[3];
TBADDBITMAP tbab;
if (! Create() )
return FALSE;
//Add standard toolbar bitmaps
tbab.hInst = HINST_COMMCTRL;
tbab.nID = IDB_STD_SMALL_COLOR;
SendMessage(m_hWnd, TB_ADDBITMAP, 0, (LPARAM)&tbab);
//Add buttons
ZeroMemory(tbb, sizeof(tbb));
tbb[0].iBitmap = STD_CUT;
tbb[0].idCommand = IDS_CUT;
tbb[0].fsState = TBSTATE_ENABLED;
tbb[0].fsStyle = TBSTYLE_BUTTON;
tbb[1].iBitmap = STD_COPY;
tbb[1].idCommand = IDS_COPY;
tbb[1].fsState = TBSTATE_ENABLED;
tbb[1].fsStyle = TBSTYLE_BUTTON;
tbb[2].iBitmap = STD_PASTE;
tbb[2].idCommand = IDS_PASTE;
tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_BUTTON;
SendMessage(m_hWnd, TB_ADDBUTTONS, (WPARAM) 3, (LPARAM) (LPTBBUTTON) &tbb);
ShowWindow(m_hWnd, SW_NORMAL);
return TRUE;
}
我使用SDI窗口测试它,它运行良好,但在我创建MDICLIENT(客户端)窗口后,它很糟糕。
请帮助我解决这个特殊的问题。 您可以在https://code.google.com/p/jcyangs-code/source/browse/trunk/com/lib/
获取所有源代码感谢。
答案 0 :(得分:0)
处理框架窗口的WM_SIZE消息。