Home > Software engineering >  MFC TAB label display problems
MFC TAB label display problems

Time:09-17

Use TAB control dynamically add page, under the condition of increased a lot of pages, delete the page will cause the TAB is empty, need to manually click on the scroll bar to refresh tag, according to my idea is to obtain the currently displayed tag number of 0 in the code for the scroll bar rolling, but don't know whether the two has a function of the whole

The mouse point in the past had the label out

Scroll bars can be normal shows


Is there any way to solve the problem of the display?

CodePudding user response:

If your child dialogs on the Tab control blocking the Tab label size is too big?

CodePudding user response:

reference 1/f, 7-eleven's response:
does your child dialogs on the Tab control blocking the Tab label size is too big?
should not be, do my dialog box and the dialog box can be stretched, the location of controls also is normal, should not be stopped, the mouse moved to each TAB click on can appear a again, also can appear a, remove the click another, appear and disappear, original, but click on the buttons of the scroll bar, can brush, so I am wondering there is no good solution, it gets the current display the number of labels in code click on the scroll bar, but today the TAB of the scroll bar rolling news didn't effect, also get access to the scroll bar is empty,
//CScrollBar * tabSc=m_Tab GetScrollBarCtrl (SB_HORZ);//SB_HORZ SB_VERT SB_CTL SB_BOTH
: : SendMessage (m_Tab m_hWnd, WM_HSCROLL MAKEWPARAM (SB_PAGELEFT, 0), NULL);

CodePudding user response:

After adding the page according to the coordinates of the Tab control to adjust the following page location try

 
CRect rcRect;
M_tab. GetClientRect (& amp; RcRect);
M_tab. AdjustRect (FALSE, & amp; RcRect);
//child parent window the current window of the page?
If (m_Page GetParent () & amp; & M_Page. GetParent () - & gt; M_hWnd==m_hWnd)
{
M_tab. ClientToScreen (& amp; RcRect);//into screen coordinates
The ScreenToClient (& amp; RcRect);//go to the to the current window's client area location
}
//mobile page
M_Page. MoveWindow (rcRect);


CodePudding user response:

reference zgl7903 reply: 3/f
after adding the page Tab controls the coordinates of the position adjustment following page try

 
CRect rcRect;
M_tab. GetClientRect (& amp; RcRect);
M_tab. AdjustRect (FALSE, & amp; RcRect);
//child parent window the current window of the page?
If (m_Page GetParent () & amp; & M_Page. GetParent () - & gt; M_hWnd==m_hWnd)
{
M_tab. ClientToScreen (& amp; RcRect);//into screen coordinates
The ScreenToClient (& amp; RcRect);//go to the to the current window's client area location
}
//mobile page
M_Page. MoveWindow (rcRect);

Still appear this kind of phenomenon, the test code has not been form tensile, so clearly see the shift

CodePudding user response:

Very obvious shift described in the parent window not

CRect rcRect;
M_tab. GetClientRect (& amp; RcRect);
M_tab. AdjustRect (FALSE, & amp; RcRect);
If (m_Page GetParent ())
{
M_tab. ClientToScreen (& amp; RcRect);//into screen coordinates
M_Page. GetParent () - & gt; The ScreenToClient (& amp; RcRect);//go to the to the current window's client area location
}
//mobile page
M_Page. MoveWindow (rcRect);

CodePudding user response:

reference 5 floor zgl7903 reply:
very obvious shift described in the parent window not

CRect rcRect;
M_tab. GetClientRect (& amp; RcRect);
M_tab. AdjustRect (FALSE, & amp; RcRect);
If (m_Page GetParent ())
{
M_tab. ClientToScreen (& amp; RcRect);//into screen coordinates
M_Page. GetParent () - & gt; The ScreenToClient (& amp; RcRect);//go to the to the current window's client area location
}
//mobile page
M_Page. MoveWindow (rcRect);

I press you changed the code, or shift happened again, the reason of the displacement should be a pair with a dialog box set the parent form is
PTabPage - & gt; Create (nID, GetDlgItem (IDC_TABDB));//IDC_TABDB is TAB control ID
If the change to the main dialog, there is no displacement, but failed to solve,
In view of all speculation is likely to be held up by the child dialogs, so I just changed the code, not create a dialog box, only keep the TAB label, nature doesn't exist the problem of blocking, but remove the TAB label still appeared the same problem as before, so I think the problem should be in the TAB control itself

CodePudding user response:

In view of the possibility of child dialogs, I got a test program, and contains only two buttons and a TAB control, no child dialog interface, the results still have the problem, and disappear TAB and then click the TAB is in the former label location, click on the scroll bar after refresh the right label, so I think it should be a TAB control itself, where or in this case set, or is there any function can access to the TAB with the scroll bar, code trigger rolling,
The test code:
 void CTABtestDlg: : OnBnClickedButtonAdd () 
{
//TODO: add the control notification handler code
Int iTabCount=m_Tab. GetItemCount ();
Char titlebuf [32]={0};
Sprintf (titlebuf, % d "PAGE", iTabCount);

M_Tab. InsertItem (iTabCount titlebuf);
M_Tab. SetCurSel (iTabCount);
}


Void CTABtestDlg: : OnBnClickedButtonDel ()
{
//TODO: add the control notification handler code
Int iRemoveTab=m_Tab. GetCurSel ();

M_Tab. Called DeleteItem (iRemoveTab);
Int tabcount=m_Tab. GetItemCount ();

If (tabcount==0)
{
M_Tab. SetCurSel (1);
}
Else if (iRemoveTab==tabcount)//delete is the last page
{
M_Tab. SetCurSel (iRemoveTab - 1);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related