Click here to Skip to main content
15,918,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSimple operation with window minimized... Pin
Anonymous25-Sep-03 13:30
Anonymous25-Sep-03 13:30 
GeneralC and memory help Pin
Sirrius25-Sep-03 12:39
Sirrius25-Sep-03 12:39 
GeneralRe: C and memory help Pin
Larry J. Siddens25-Sep-03 13:03
Larry J. Siddens25-Sep-03 13:03 
GeneralRe: C and memory help Pin
Sirrius25-Sep-03 14:46
Sirrius25-Sep-03 14:46 
GeneralRe: C and memory help Pin
Larry J. Siddens25-Sep-03 15:02
Larry J. Siddens25-Sep-03 15:02 
GeneralID of a child dialog Pin
Antti Keskinen25-Sep-03 11:42
Antti Keskinen25-Sep-03 11:42 
GeneralRe: ID of a child dialog Pin
Antti Keskinen25-Sep-03 11:49
Antti Keskinen25-Sep-03 11:49 
GeneralApp is crashing when trying to restore Brushes and Fonts Pin
Terry O'Nolley25-Sep-03 9:56
Terry O'Nolley25-Sep-03 9:56 
I have the following code to draw something:

void pteTable::Draw(CPaintDC* dc)<br />
{<br />
   // declare/initialize brushes<br />
   CBrush  Brush;<br />
   CBrush* OldBrush;<br />
<br />
   Brush.CreateSolidBrush(RGB(0, 0, 0)); <br />
<br />
   // The docs say that this method returns a pointer to the previously CGDIObject<br />
   OldBrush = (CBrush*)dc->SelectObject(Brush); //OldBrush should be valid?<br />
<br />
   dc->Rectangle(1, 1, 100, 100);<br />
<br />
   // clean-up<br />
   dc.SelectObject(OldBrush);  //THIS IS WHERE IT CRASHES<br />
   Brush.DeleteObject();<br />
}


I have simply commented out the line where it crashes and stressed it by calling this function hundreds of times and my resource indicator doesn't show me losing any available resources.

Is it safe to simply not select the old brush back into the CPaintDC?

If not, does anyone know why this code is crashing?

The debugger showed that OldBrush was not NULL.








GeneralRe: App is crashing when trying to restore Brushes and Fonts Pin
Alvaro Mendez25-Sep-03 10:19
Alvaro Mendez25-Sep-03 10:19 
GeneralRe: App is crashing when trying to restore Brushes and Fonts Pin
Terry O'Nolley25-Sep-03 10:46
Terry O'Nolley25-Sep-03 10:46 
GeneralRe: App is crashing when trying to restore Brushes and Fonts Pin
Michael Dunn25-Sep-03 10:32
sitebuilderMichael Dunn25-Sep-03 10:32 
GeneralRe: App is crashing when trying to restore Brushes and Fonts Pin
Terry O'Nolley25-Sep-03 11:06
Terry O'Nolley25-Sep-03 11:06 
QuestionConversion from DB_NUMERIC to double? Pin
Rene De La Garza25-Sep-03 9:50
Rene De La Garza25-Sep-03 9:50 
AnswerRe: Conversion from DB_NUMERIC to double? Pin
Steve S25-Sep-03 22:45
Steve S25-Sep-03 22:45 
Generalspeaker volume too low Pin
Binayak25-Sep-03 9:40
Binayak25-Sep-03 9:40 
GeneralRe: speaker volume too low Pin
David Crow25-Sep-03 9:45
David Crow25-Sep-03 9:45 
GeneralRe: speaker volume too low Pin
Binayak25-Sep-03 10:14
Binayak25-Sep-03 10:14 
GeneralRe: speaker volume too low Pin
David Crow25-Sep-03 10:19
David Crow25-Sep-03 10:19 
GeneralRe: speaker volume too low Pin
Binayak25-Sep-03 10:22
Binayak25-Sep-03 10:22 
GeneralRe: speaker volume too low Pin
David Crow25-Sep-03 10:25
David Crow25-Sep-03 10:25 
GeneralRe: speaker volume too low Pin
Binayak25-Sep-03 10:27
Binayak25-Sep-03 10:27 
GeneralRe: speaker volume too low Pin
David Crow25-Sep-03 10:31
David Crow25-Sep-03 10:31 
GeneralRe: speaker volume too low Pin
Alvaro Mendez25-Sep-03 11:05
Alvaro Mendez25-Sep-03 11:05 
GeneralRe: speaker volume too low Pin
Binayak25-Sep-03 11:06
Binayak25-Sep-03 11:06 
GeneralRe: speaker volume too low Pin
73Zeppelin26-Sep-03 6:12
73Zeppelin26-Sep-03 6:12 

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.