我的Win32应用程序中有一个制表符控件。该控件具有多行功能。当我调整窗口大小以使标签控件的宽度减小时,会显示多行。问题是,当我单击其中一行时,上面一行中的选项卡被当前选项卡的窗口阻止(选项卡控件没有正确调整当前选项卡的内容窗口的大小,以便上面的行可见) 。我如何解决这个问题?
以下是我调整大小功能的代码:
RECT cr;
GetClientRect( pHdr->hWndTab, &cr );
TabCtrl_AdjustRect( pHdr->hWndTab, FALSE, &cr );
OffsetRect( &cr, cxMargin - cr.left, cyMargin - cr.top );
SetWindowPos( pHdr->hWndDisplay, 0, cr.left, cr.top, cr.right, cr.bottom, SWP_SHOWWINDOW );
此代码来自Microsoft网站...
pHdr-> hWndTab是制表符控件的窗口句柄
pHdr-> hWndDisplay是当前标签内容窗口的窗口句柄
编辑:实际上,点击下方标签后,上方标签移动到控件顶部...但是,它们仍被内容窗口阻止...
答案 0 :(得分:0)
我通过在抵消后调整显示矩形来解决问题:
typedef struct tag_dlghdr
{
HWND hWndTab;
HWND hWndDisplay;
RECT rcDisplay;
DLGTEMPLATE *apRes[ MAX_PAGES ];
DLGPROC MsgProc[ MAX_PAGES ];
}DLGHDR
Resize( HWND hWndDlg )
{
DLGHDR *pHdr = ( DLGHDR * )GetWindowLong( hWndDlg, GWL_USERDATA );
DWORD dwDlgBase = GetDialogBaseUnits();
int cxMargin = LOWORD( dwDlgBase ) / 4;
int cyMargin = HIWORD( dwDlgBase ) / 8;
m_niCurTabSel = TabCtrl_GetCurSel( pHdr->hWndTab );
RECT cr;
GetClientRect( pHdr->hWndTab, &cr );
TabCtrl_AdjustRect( pHdr->hWndTab, FALSE, &cr );
OffsetRect( &cr, cxMargin - cr.left, cyMargin - cr.top );
CopyRect( &pHdr->rcDisplay, &cr );
TabCtrl_AdjustRect( pHdr->hWndTab, FALSE, &pHdr->rcDisplay );
SetWindowPos( pHdr->hWndDisplay, 0, pHdr->rcDisplay.left, pHdr->rcDisplay.top, pHdr->rcDisplay.right, pHdr->rcDisplay.bottom, SWP_SHOWWINDOW );
}