Click here to Skip to main content
15,887,442 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
General[Message Deleted] Pin
Andre Smalling2-Aug-09 7:45
Andre Smalling2-Aug-09 7:45 
GeneralRe: cannot get program to work can someone tell me what I am doing wrong Pin
Richard Andrew x642-Aug-09 7:50
professionalRichard Andrew x642-Aug-09 7:50 
General[Message Deleted] Pin
Andre Smalling2-Aug-09 7:57
Andre Smalling2-Aug-09 7:57 
GeneralRe: cannot get program to work can someone tell me what I am doing wrong Pin
Richard Andrew x642-Aug-09 8:02
professionalRichard Andrew x642-Aug-09 8:02 
GeneralRe: cannot get program to work can someone tell me what I am doing wrong Pin
Rozis2-Aug-09 8:34
Rozis2-Aug-09 8:34 
Questionhow use CDialog in Win32 API? Pin
bsh01281-Aug-09 7:58
bsh01281-Aug-09 7:58 
AnswerRe: how use CDialog in Win32 API? Pin
Bacon Ultimate Cheeseburger1-Aug-09 11:27
Bacon Ultimate Cheeseburger1-Aug-09 11:27 
QuestionExact type of HGDIOBJ (pen, brush, font, etc.) Pin
japcrword1-Aug-09 1:13
japcrword1-Aug-09 1:13 
Is there an easy way to find out what type of GDI object is referenced by HGDIOBJ handle i.e. is it a pen, brush, bitmap, font or region? I can't find WINAPI that does the job. Of course, I can always go the tricky way to determine the type of HGDIOBJ hTestedObj: create a dummy hDc, hPen, hBrush, hBitmap, hFont, hRegion; select these dummy objects into hDc, then compare the handle returned by SelectObject(hDc,hTestedObj) with hPen, hBrush, etc. The following code illustrates the idea.

const CHAR* GdiType(HGDIOBJ hTestedObj){
     HDC hDc=CreateCompatibleDC(GetDC(NULL));
     assert(hDc!=NULL);
     HGDIOBJ hPen=GetStockObject(DC_PEN);
     HGDIOBJ hBrush=GetStockObject(DC_BRUSH);
     HGDIOBJ hFont=GetStockObject(ANSI_FIXED_FONT);
     HGDIOBJ hBitmap=CreateCompatibleBitmap(GetDC(NULL),1,1);
     assert(hBitmap!=NULL);
     HRGN hRegion=CreateRectRgn(0,0,1,1);
     assert(hRegion);
     HGDIOBJ hTemp=NULL;
     hTemp=SelectObject(hDc,hPen);assert(hTemp!=NULL);
     hTemp=SelectObject(hDc,hBrush);assert(hTemp!=NULL);
     hTemp=SelectObject(hDc,hFont);assert(hTemp!=NULL);
     hTemp=SelectObject(hDc,hBitmap);assert(hTemp!=NULL);
     hTemp=SelectObject(hDc,hRegion);assert(hTemp!=HGDI_ERROR);
     const CHAR *szRet="?";
     hTemp=SelectObject(hDc,hTestedObj);
     assert(hTemp!=NULL && hTemp!=HGDI_ERROR);
     if(hTemp==hPen)szRet="PEN";
     else if(hTemp==hBrush)szRet="BRUSH";
     else if(hTemp==hFont)szRet="FONT";
     else if(hTemp==hBitmap)szRet="BITMAP";
     else if(hTemp==hRegion || hTemp==(HGDIOBJ)SIMPLEREGION ||
          hTemp==(HGDIOBJ)COMPLEXREGION ||
          hTemp==(HGDIOBJ)NULLREGION)szRet="REGION";
     DeleteObject(hBitmap);
     DeleteObject(hRegion);
     DeleteDC(hDc);
     return szRet;
}

But this technique seems somewhat awkward (though it works). Perhaps, there is an elegant way to do the same thing?
AnswerRe: Exact type of HGDIOBJ (pen, brush, font, etc.) Pin
Bacon Ultimate Cheeseburger1-Aug-09 1:27
Bacon Ultimate Cheeseburger1-Aug-09 1:27 
QuestionUnhandled exception occur ant points at afxcoll.inl line 306. Pin
Le@rner31-Jul-09 23:44
Le@rner31-Jul-09 23:44 
Questionicstring and VS2008 - warning Pin
achainard31-Jul-09 23:08
achainard31-Jul-09 23:08 
QuestionC++ vs. C# Pin
PankajB31-Jul-09 20:38
PankajB31-Jul-09 20:38 
AnswerRe: C++ vs. C# Pin
Rajesh R Subramanian31-Jul-09 20:40
professionalRajesh R Subramanian31-Jul-09 20:40 
GeneralRe: C++ vs. C# Pin
PankajB31-Jul-09 20:49
PankajB31-Jul-09 20:49 
QuestionRe: C++ vs. C# Pin
Rajesh R Subramanian31-Jul-09 20:53
professionalRajesh R Subramanian31-Jul-09 20:53 
AnswerRe: C++ vs. C# Pin
PankajB31-Jul-09 21:14
PankajB31-Jul-09 21:14 
GeneralRe: C++ vs. C# Pin
harold aptroot31-Jul-09 21:24
harold aptroot31-Jul-09 21:24 
GeneralRe: C++ vs. C# Pin
PankajB31-Jul-09 21:29
PankajB31-Jul-09 21:29 
GeneralRe: C++ vs. C# Pin
Rajesh R Subramanian31-Jul-09 21:38
professionalRajesh R Subramanian31-Jul-09 21:38 
GeneralRe: C++ vs. C# Pin
harold aptroot31-Jul-09 21:54
harold aptroot31-Jul-09 21:54 
AnswerRe: C++ vs. C# Pin
Joe Woodbury1-Aug-09 10:23
professionalJoe Woodbury1-Aug-09 10:23 
QuestionHow can made safer application that is not detect by antivirus? Pin
Le@rner31-Jul-09 19:24
Le@rner31-Jul-09 19:24 
AnswerRe: How can made safer application that is not detect by antivirus? Pin
Rajesh R Subramanian31-Jul-09 20:38
professionalRajesh R Subramanian31-Jul-09 20:38 
GeneralRe: How can made safer application that is not detect by antivirus? Pin
Le@rner31-Jul-09 21:02
Le@rner31-Jul-09 21:02 
AnswerRe: How can made safer application that is not detect by antivirus? Pin
Bacon Ultimate Cheeseburger1-Aug-09 1:23
Bacon Ultimate Cheeseburger1-Aug-09 1:23 

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.