MenuBar和窗口尺寸计算的问题,一直没找到资料,求教
下面的代码,是样例工程MiniPIE中的代码,测试后,发现一个问题,就是menubar的尺寸不对。下面的代码执行后,在menubar上方,会多出一个,高度一样的控件,左边白色,右边深色,却又不能点击和处理。想改进代码去除,却发现去除后,会导致那块的内容无法浏览,被“盖住”了。
// Create a menubar
// (mbi was initialized above)
mbi.hwndParent = m_hWnd;
mbi.nToolBarId = IDR_MAIN_MENUBAR; // ID of toolbar resource
mbi.hInstRes = _AtlBaseModule.GetResourceInstance();
CBR(SHCreateMenuBar(&mbi));
m_menuBar = mbi.hwndMB; // save menu bar HWND
// Compute RECT for initial size and position.
// The following code should compute RECT appropriately
// on both Pocket PC and Smartphone. It should function correctly
// whether SIP is on or off, and
// whether device is in portrait or landscape mode.
// (rcMainWindow was initialized above)
VERIFY(SystemParametersInfo(SPI_GETWORKAREA, 0, &rcMainWindow, 0));
// (rcMenuBar was initialized above)
m_menuBar.GetWindowRect(&rcMenuBar);
rcMainWindow.bottom = rcMenuBar.top;
// SIP state - SIP 这段去除,颜色不一的“bar”消失,但是显示网页不全
// (si was initialized above)
if (SHSipInfo(SPI_GETSIPINFO, 0, &si, 0) &&
(si.fdwFlags & SIPF_ON) && (si.fdwFlags & SIPF_DOCKED))
{
rcMainWindow.bottom = si.rcVisibleDesktop.bottom;
}
MoveWindow(&rcMainWindow);