CodePudding user response:
CodePudding user response:
Don't direct call OnPaint, OnPaint can only call in the WM_PAINT eventsCodePudding user response:
Dialog box white?Bad start? How long after bad?
CodePudding user response:
Not bad for a start,This is a full-screen dialog, I have been Alt + TAB to switch interface can also lead to the problem of bad, once the interface appears white, main interface is loaded
CodePudding user response:
All update control shows the method I tried, I just do the MFC two months, some details, not very understand, I use redrawWindow are used in the project to update interface, there is another full screen interface is no problem, there is no bad,CodePudding user response:
Handle to a GDI leaks in the OnPaint?CodePudding user response:
Void CMhsuper: : OnPaint (){
CPaintDC dc (this);//device context for painting
//TODO: add message handler code here
//no message calls for drawing CDialog: : OnPaint ()
//the CDC * PDC=PWND - & gt; GetDC ();
Float iWidth=GetSystemMetrics (SM_CXSCREEN);
Float iHeight=GetSystemMetrics (SM_CYSCREEN);
Float biwidht=iWidth/1920;
Float biheight=iHeight/1080;
//CBrush hBrush=CreateSolidBrush (RGB (206, 217, 237));
CBrush brush2 (RGB (206, 217, 237));
Biheight CRect the rect (0, 80 *, 2000, 2000);//
Dc. FillRect (& amp; The rect, & amp; Brush2);
CBrush brush3 (RGB (130, 167, 209));
CRect rect2 (0, 0, 2000, 80 * biheight);//
Dc. FillRect (& amp; Rect2, & amp; Brush3);
If (m_addzero==1)
{
M_addzerobutton. LoadBitmaps (IDB_zidongjialingdown);
M_addzerobutton. SizeToContent ();
}
The else
{
M_addzerobutton. LoadBitmaps (IDB_zidongjialingup);
M_addzerobutton. SizeToContent ();
}
If (sendflag==0)
{
M_phonemodern. LoadBitmaps (IDB_allscrphonemodern);
M_phonemodern. SizeToContent ();
}
The else
{
M_phonemodern. LoadBitmaps (IDB_allscrguhuamodern);
M_phonemodern. SizeToContent ();
}
M_nextpagetwo. LoadBitmaps (IDB_nextpageup AFX_IDS_FONT_PPG);
M_nextpagetwo. SizeToContent ();
M_lastpagetwo. LoadBitmaps (IDB_shangyiyeupup IDB_shangyiyedown);
M_lastpagetwo. SizeToContent ();
M_dianhuamodern. LoadBitmaps (IDB_guhuamoshi2up IDB_guhuamoderndown);
M_dianhuamodern. SizeToContent ();
M_add0modern. LoadBitmaps (IDB_guhuaadd0up IDB_guhuaADD0odown);
M_add0modern. SizeToContent ();
M_qunfa. LoadBitmaps (IDB_zaiciqunfaup IDB_zaiciqunfadown);
M_qunfa. SizeToContent ();
M_allmsg. LoadBitmaps (IDB_allmsgup IDB_suoyouduanxindown);
M_allmsg. SizeToContent ();
Brush2. DeleteObject ();
Brush3. DeleteObject ();
}
This is a problem onpaint function interface
CodePudding user response:
1 all. LoadBitmaps put initialization in2 use redrawWindow to update the interface, bad habits! With this Invalidate ()!
CodePudding user response:
The CPaintDC dc (this) the code behind the blocked will appear white?CodePudding user response:
M_addzerobutton. LoadBitmaps (IDB_zidongjialingdown);, in the pictures loaded on initialization, and avoid every refresh loading!!!!!!
CodePudding user response:
One way to check whether resource leaks:In the process of the task manager to see inside the column selection: memory, virtual memory size, handle number, number of threads, the USER object, GDI objects
Make your program (process) don't quit, cycle through main process many times, the more the better, like 1000000 times or even an infinite loop, record the above numerical, it through at least one hour, as long as possible, such as a month, to record more than the value, if the above two groups of numerical differential is bigger or increasing over time, will certainly have a corresponding resources resource leaks!
Search "GDI leak detection"
CodePudding user response:
Only one control, other all deleted, debugging to see againCodePudding user response:
Then add CDialogEx: : OnPaint (); Have a tryCodePudding user response:
You can see the onsize function, because your dialog box not only white and layout is also changed, and in addition to redawwindow, estimates elsewhere with another refresh,CodePudding user response: