我有我使用Visual Studio 2008四CDockablePane不正確尺寸
實施這裏是我遇到的問題的圖像的單文檔MFC項目。爲了您的安全,此圖像已被編輯。
如果圖像沒有在你的網頁瀏覽器加載,這裏是它的一個ASCII渲染:
---------------------------------------------------
| Pane 1 | Pane 2 | Pane 3 | P | (Pane 4 is |
| | | | a | too small |
| | | | n | no matter |
| | | | e | what width |
| | | | 4 | I give it.)|
| | | | | |
---------------------------------------------------
的三個最左邊的窗格大小正常就好了,但第四個窗格出現相同(不正確)的大小,無論我給它多寬。
這裏是我的CMainFrame::OnCreate()
是什麼樣子:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
// Omitting lots of automatically generated code here
if (this->InitMyPane1() == FALSE) {
return -1 ;
}
if (this->InitMyPane2() == FALSE) {
return -1 ;
}
if (this->InitMyPane3() == FALSE) {
return -1 ;
}
if (this->InitMyPane4() == FALSE) {
return -1 ;
}
return 0;
}
所有這些InitMyPaneX()
函數的代碼非常相似。這是InitMyPane4()
,似乎正在產生不正確的結果。
BOOL CMainFrame::InitMyPane4()
{
CRect rect ;
this->GetClientRect (&rect) ;
int right = static_cast <int> (rect.Width()/6) ;
int bottom = rect.Height() ;
DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_ALIGN_LEFT | CBRS_FLOAT_MULTI ;
BOOL bOk = m_MyPane4.Create (
_T ("My Pane 4"), this,
CRect (0, 0, right, bottom), TRUE, IDC_MY_PANE_4, dwStyle
) ;
if (bOk == FALSE) {
return FALSE ;
}
m_MyPane4.EnableDocking (CBRS_ALIGN_ANY) ;
this->DockPane ((CBasePane *) &m_MyPane4, AFX_IDW_DOCKBAR_LEFT) ;
this->RecalcLayout() ;
return bOk ;
}
在上面的代碼right
變量是什麼應該被修改窗格的寬度,但似乎沒有影響,無論我提供什麼價值了。
什麼可能導致MFC無法正確調整窗格大小?
UPDATE
它正確地只要right <= 200
似乎大小。如果我在此之後嘗試增加尺寸,則沒有任何反應。
如果我把尺寸做得非常小(〜10),我會看到一些奇怪的分隔線出現。
該窗格似乎不希望超過此分隔線的大小。 我不確定這個分隔線來自哪裏或如何擺脫它。
你爲什麼要由6分的寬度是多少? – rrirower
@rrirower在試圖讓數學正確填充剩餘的整個可用空間之前,我想看看我是否至少可以給它與面板1和3相同的尺寸。不幸的是,它不會改變尺寸我給它什麼寬度。 – jliv902
您是否嘗試過調試RecalcLayout? – rrirower