Click here to Skip to main content
15,889,216 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: socket copy Pin
sunit518-Oct-05 20:32
sunit518-Oct-05 20:32 
GeneralRe: socket copy Pin
vikas amin19-Oct-05 1:33
vikas amin19-Oct-05 1:33 
Questionprocessing ESC key Pin
Ann6618-Oct-05 14:06
sussAnn6618-Oct-05 14:06 
AnswerRe: processing ESC key Pin
Christian Graus18-Oct-05 14:23
protectorChristian Graus18-Oct-05 14:23 
QuestionRe: processing ESC key Pin
David Crow19-Oct-05 3:40
David Crow19-Oct-05 3:40 
QuestionCPaintDC resource Pin
LighthouseJ18-Oct-05 13:30
LighthouseJ18-Oct-05 13:30 
AnswerRe: CPaintDC resource Pin
Christian Graus18-Oct-05 13:36
protectorChristian Graus18-Oct-05 13:36 
GeneralRe: CPaintDC resource Pin
LighthouseJ18-Oct-05 13:53
LighthouseJ18-Oct-05 13:53 
The code is complex, but here's the short of it:

try {<br />
  CPaintDC dc(this);<br />
  if ((thread == NULL) && (files != NULL)) {<br />
    dc.Rectangle(x, y, x + 300, y + nTextHeight + 4);<br />
    COLORREF OldColor = dc.SetTextColor (RGB(192, 192, 192));<br />
    dc.SelectObject (new CBrush(RGB(192, 192, 192)));<br />
    sMsg.Format("%s, %s", obj->GetName(), obj->GetStringFilesize());<br />
    dc.TextOut(x + 2, y + 2, (LPCTSTR) sMsg);<br />
    dc.SetTextColor(OldColor);<br />
    dc.SelectObject (new CBrush (RGB(255, 255, 255)));<br />
  }<br />
  <2 more sections like the above exist with different if statement tests><br />
} catch (CResourceException * e) {<br />
  e->Delete();<br />
  thread->SuspendThread();<br />
  char * lpszMessage = new char[128];<br />
  e->GetErrorMessage(lpszMessage, 128, NULL);<br />
  MessageBox(lpszMessage, "Critical Error", MB_ICONSTOP);<br />
  delete[] lpszMessage;<br />
  thread->ResumeThread();<br />
}


That's the gist (and most complex) part of it. I have 3 blocks like the if statement above, the first two are rarely used, but the third is heavily used when a particular thread is running. The heavily used if statement is similar in layout to the above but it draws a text element and pie, both correspond to a progress display of the thread the code mentions. I was handling the CBrush's by new'ing and delete'ing them manually but it threw runtime errors when delete'ing the CBrush's, it said a "pure virtual function call" or something like that. I don't do any clean up, I just get the dc from CPaintDC and then draw, that's it. I figured I didn't need to deallocate the drawing context because I was using it in this method, instead of using a handle to a drawing context with GetDC/ReleaseDC.
GeneralRe: CPaintDC resource Pin
Christian Graus18-Oct-05 13:57
protectorChristian Graus18-Oct-05 13:57 
GeneralRe: CPaintDC resource Pin
LighthouseJ18-Oct-05 14:22
LighthouseJ18-Oct-05 14:22 
GeneralRe: CPaintDC resource Pin
Christian Graus18-Oct-05 14:29
protectorChristian Graus18-Oct-05 14:29 
GeneralRe: CPaintDC resource Pin
LighthouseJ18-Oct-05 14:34
LighthouseJ18-Oct-05 14:34 
GeneralRe: CPaintDC resource Pin
Christian Graus18-Oct-05 15:02
protectorChristian Graus18-Oct-05 15:02 
GeneralRe: CPaintDC resource Pin
PJ Arends18-Oct-05 15:44
professionalPJ Arends18-Oct-05 15:44 
GeneralRe: CPaintDC resource Pin
LighthouseJ18-Oct-05 15:51
LighthouseJ18-Oct-05 15:51 
Questionhow to insert byte array to sql? Pin
GoodQuestion18-Oct-05 12:10
GoodQuestion18-Oct-05 12:10 
QuestionVisual C++ Heap error Pin
Tam98765432118-Oct-05 11:32
Tam98765432118-Oct-05 11:32 
QuestionRe: Visual C++ Heap error Pin
David Crow19-Oct-05 3:43
David Crow19-Oct-05 3:43 
AnswerRe: Visual C++ Heap error Pin
Tam98765432119-Oct-05 8:38
Tam98765432119-Oct-05 8:38 
QuestionBool data type issue Pin
Anonymous18-Oct-05 10:17
Anonymous18-Oct-05 10:17 
AnswerRe: Bool data type issue Pin
Dezhi Zhao18-Oct-05 10:52
Dezhi Zhao18-Oct-05 10:52 
AnswerRe: Bool data type issue Pin
John M. Drescher18-Oct-05 11:11
John M. Drescher18-Oct-05 11:11 
GeneralRe: Bool data type issue Pin
itkid18-Oct-05 11:41
itkid18-Oct-05 11:41 
Questionconfusion with memory mapped files Pin
Chintoo72318-Oct-05 7:20
Chintoo72318-Oct-05 7:20 
AnswerRe: confusion with memory mapped files Pin
Joe Woodbury18-Oct-05 7:59
professionalJoe Woodbury18-Oct-05 7:59 

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.