Click here to Skip to main content
15,917,455 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Linking error in VC++.NET Pin
Mike Nordell2-Apr-02 22:14
Mike Nordell2-Apr-02 22:14 
GeneralRe: Linking error in VC++.NET Pin
Adam Clauss3-Apr-02 2:39
Adam Clauss3-Apr-02 2:39 
GeneralRe: Linking error in VC++.NET Pin
Tim Smith3-Apr-02 2:23
Tim Smith3-Apr-02 2:23 
GeneralRe: Linking error in VC++.NET Pin
Adam Clauss3-Apr-02 2:38
Adam Clauss3-Apr-02 2:38 
QuestionDoes this cause the memory leak when I draw on a view? Pin
Feng Qin2-Apr-02 15:58
Feng Qin2-Apr-02 15:58 
AnswerRe: Does this cause the memory leak when I draw on a view? Pin
Paul M Watt2-Apr-02 16:41
mentorPaul M Watt2-Apr-02 16:41 
GeneralRe: Does this cause the memory leak when I draw on a view? Pin
Feng Qin2-Apr-02 18:02
Feng Qin2-Apr-02 18:02 
GeneralRe: Does this cause the memory leak when I draw on a view? Pin
Paul M Watt2-Apr-02 19:19
mentorPaul M Watt2-Apr-02 19:19 
qf0421 wrote:
1.I have tried your method, Now, if I send the WM_PAINT to view on mouse click, it seems no effect, but if I delete the clause, it can work properly.

Do not send a WM_PAINT message directly, instead do either one of these two things to force a repaint.

//choice 1
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);


//choice 2
RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);



qf0421 wrote:
2.If you choose a new object for CDC, for example CPen, CBrush, etc, must you do the DeleteObject() on exit?

Yes, if you create a new brush, pen, palette or bitmap, you must select the original GDI Object back into the DC, and then delete your GDI Object that you allocated.


qf0421 wrote:
3.If I use the this->GetDC() to draw directly, does it cause memory leak or allocated but not freed? I notice the memory is increasing when use the view's CDC directly.

You should not call GetDC from inside of your paint handler. You should use BeginPaint, or the CPaintDC (Which internally calls BeginPaint). Then when you are done with a DC you need to release the DC, otherwise it will use up system resources. If you call BeginPaint to get the DC, then you will need to call EndPaint to release the Dc. If you call GetDC, GetWindowDC, or GetDCEx then you will need to call ReleaseDC to free the DC resource.
GeneralRe: Does this cause the memory leak when I draw on a view? Pin
Feng Qin2-Apr-02 23:10
Feng Qin2-Apr-02 23:10 
AnswerRe: Does this cause the memory leak when I draw on a view? Pin
Roger Allen2-Apr-02 23:33
Roger Allen2-Apr-02 23:33 
QuestionHow Can I get MFC support in ATL EXE COM Server project! Pin
wabc2-Apr-02 15:49
wabc2-Apr-02 15:49 
GeneralCreating custom types Pin
2-Apr-02 15:31
suss2-Apr-02 15:31 
GeneralRe: Creating custom types Pin
Christian Graus2-Apr-02 15:45
protectorChristian Graus2-Apr-02 15:45 
GeneralRe: Creating custom types Pin
2-Apr-02 20:31
suss2-Apr-02 20:31 
GeneralRe: Creating custom types Pin
alex.barylski2-Apr-02 23:17
alex.barylski2-Apr-02 23:17 
GeneralDialogs in MDI app have gray titlebar Pin
Jack Handy2-Apr-02 15:20
Jack Handy2-Apr-02 15:20 
GeneralRe: Dialogs in MDI app have gray titlebar Pin
Shog92-Apr-02 20:29
sitebuilderShog92-Apr-02 20:29 
GeneralRe: Dialogs in MDI app have gray titlebar Pin
Jack Handy2-Apr-02 21:26
Jack Handy2-Apr-02 21:26 
GeneralCreate DialogBar from CDialog Pin
2-Apr-02 13:56
suss2-Apr-02 13:56 
Generalset<int>::find crashing Pin
Cathy2-Apr-02 12:47
Cathy2-Apr-02 12:47 
GeneralRe: set<int>::find crashing Pin
Paul M Watt2-Apr-02 13:08
mentorPaul M Watt2-Apr-02 13:08 
GeneralRe: set<int>::find crashing Pin
Cathy2-Apr-02 13:15
Cathy2-Apr-02 13:15 
GeneralRe: set<int>::find crashing Pin
Paul M Watt2-Apr-02 14:06
mentorPaul M Watt2-Apr-02 14:06 
GeneralRe: set<int>::find crashing Pin
Cathy3-Apr-02 7:19
Cathy3-Apr-02 7:19 
GeneralRe: set<int>::find crashing Pin
Mike Nordell2-Apr-02 22:28
Mike Nordell2-Apr-02 22:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.