Home > Software engineering >  Ontouch and OnNcPaint pick up to the client area is different, why?
Ontouch and OnNcPaint pick up to the client area is different, why?

Time:10-04

NewsView. CPP (1258) : [15] ec OnNcPaint () : the rect. Left: 2, the rect. Top: 20, the rect. Right: 539, the rect. Bottom: 270
NewsView. CPP (1259) : [15] ec OnNcPaint () : rect_window. Left: 2, rect_window. Top: 2, rect_window. Right: 549, rect_window. Bottom: 270
NewsView. CPP (1271) : [15] ec OnNcPaint () : nTabHeigh: 42
NewsView. CPP (1278) : [15] ec OnNcPaint () : bShowVScrollBar: 1, the rect. Height: 250, the rect. Width: 537
NewsView. CPP (1301) : [15] ec OnNcPaint () : m_bItemOn: 0, m_bShowTab: 1
NewsView. CPP (2562) : [15] ec SetPosBmpBtn () : Start
NewsView. CPP (2567) : [15] ec SetPosBmpBtn () : the rect. Left: 2, the rect. Top: 20, the rect. Right: 539, the rect. Bottom: 270
NewsView. CPP (2575) : [15] ec SetPosBmpBtn () : End
NewsView. CPP (206) : [15] ec ontouch () : the rect. Left: 0, the rect. Top: 0, the rect. Right: 537, the rect. Bottom: 250

These are the TRACE output, found ontouch and OnNcPianit into the client area is different,
And then the phenomenon of bug is a view of the client area have been described, but has been painted is not successful, please everyone a great god save

CodePudding user response:

The rect. Left: 2, the rect. Top: 20, the rect. Right: 539, the rect. Bottom: 270
Ontouch () : the rect. Left: 0, the rect. Top: 0, the rect. Right: 537, the rect. Bottom: 250

the rect, OffsetRect (- the rect. Left - the rect. Top);//539-2=537; 270-20=250
Is the same!

CodePudding user response:

@ schlafenhamster thank you, but after tried to offset or not, the client area still drawing is not complete, ontouch and OnNcPaint is not why he could get to the client area is different

CodePudding user response:

Take a look at your code!

CodePudding user response:

 void CNewsView: : OnNcPaint () 
{
//TODO: Add your message handler code here
CRect the rect, rect_window;
GetClientRect (& amp; The rect);
GetWindowRect (& amp; Rect_window);//get the window frame size
ClientToScreen (& amp; The rect);
The GetParent () - & gt; The ScreenToClient (& amp; The rect);
The GetParent () - & gt; The ScreenToClient (& amp; Rect_window);
TRACE (" OnNcPaint () : the rect. Left: % d, the rect. Top: % d, the rect. Right: % d, the rect. Bottom: % d \ n ", the rect. Left, the rect. The top, the rect. Right, the rect, bottom);
TRACE (" OnNcPaint () : rect_window. Left: % d, rect_window. Top: % d, rect_window. Right: % d, rect_window. Bottom: % d \ n ", rect_window. Left, rect_window. Top, rect_window. Right, rect_window, bottom);

//SetPosBmpBtn ();
Int nRows=m_pNewTab - & gt; GetRowCount ();//get the current TAB order lines
Int nTabHeigh=20;
If (nRows & gt; 1 & amp; & NRows{
CRect tabRc;
M_pNewTab - & gt; GetItemRect (0, tabRc);//a single TAB area

NTabHeigh=nRows * tabRc Height ();//set to draw all the height of the TAB area
}
TRACE (" OnNcPaint () : nTabHeigh: % d \ n ", nTabHeigh);
Int nScrollMove=0;
//nScrollMove=nTabHeigh - the rect. Top;

/////////////end
If ((m_pvScrollBar!=NULL) & amp; & (IsWindow (m_pvScrollBar - & gt; M_hWnd)))
{
TRACE (" OnNcPaint () : bShowVScrollBar: % d, the rect. Height: % d, the rect. Width: % d \ n ", bShowVScrollBar, the rect. Height (), the rect. The Width ());
If (the rect. Height () & gt; 10 & amp; & BShowVScrollBar) {
M_pvScrollBar - & gt; SetWindowPos (& amp; WndTop, the rect. Right, the rect. Top + 2,//
10 and the rect. Height (), SWP_DRAWFRAME | SWP_SHOWWINDOW | SWP_FRAMECHANGED);
}
The else//10
M_pvScrollBar - & gt; ShowWindow (SW_HIDE);

If (the rect. Width () & gt; 10 & amp; & BShowHScrollBar)
{
M_phScrollBar - & gt; SetWindowPos (
& WndTop, the rect. Left, the rect. Bottom,
The rect. Width () + 10, 10, 10
//SWP_DRAWFRAME | SWP_SHOWWINDOW | SWP_FRAMECHANGED);
}
The else
{
M_phScrollBar - & gt; ShowWindow (SW_HIDE);

}
//if the rect. Height () & gt; 3)
//{
//if (m_pNewTab - & gt; GetSafeHwnd ())
TRACE (" OnNcPaint () : m_bItemOn: % d, m_bShowTab: % d \ n ", m_bItemOn, m_bShowTab);
If (the rect. Height () & gt; 10 & amp; & M_pNewTab - & gt; GetSafeHwnd ())
{
If (m_bItemOn)
{
M_pNewTab - & gt; ShowWindow (SW_HIDE);
}
The else
{
If (m_bShowTab)
{
//m_pNewTab - & gt; SetWindowPos (
//& amp; WndTop, rect_window. Left - 2, rect_window. Top,//rect_top - 20,
//the rect. Width () + 10, nTabHeigh,
//SWP_DRAWFRAME | SWP_SHOWWINDOW);
M_pNewTab - & gt; SetWindowPos (& amp; WndTop, the rect. Left - 2, 0, the rect. The Width () + 10, nTabHeigh, SWP_DRAWFRAME | SWP_SHOWWINDOW | SWP_FRAMECHANGED);
}
The else
{
M_pNewTab - & gt; ShowWindow (SW_HIDE);
}
}
}

}
//the Do not call CScrollView: : OnNcPaint () for painting the messages
}




CodePudding user response:

Please specify which NC code!

CodePudding user response:

M_pNewTab - & gt; SetWindowPos (& amp; WndTop, the rect. Left - 2, 0, the rect. The Width () + 10, nTabHeigh, SWP_DRAWFRAME | SWP_SHOWWINDOW | SWP_FRAMECHANGED);
This passage is to draw the TAB, and two is to draw the scrollBar, main is to draw the TAB has a problem

CodePudding user response:

TAB in the client area, why not ontouch (painting the client area), and the client area closed (NC)?

CodePudding user response:

M_pNewTab - & gt; SetWindowPos (& amp; WndTop, the rect. Left - 2, 0, the rect. The Width () + 10, nTabHeigh, SWP_DRAWFRAME | SWP_SHOWWINDOW | SWP_FRAMECHANGED);

Y=0 shop here, not on the client area is in the client area

CodePudding user response:

Y
nullnullnullnull
  • Related