Click here to Skip to main content
15,908,775 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
General.NET Benchmark Challenge Pin
Chris Maunder20-Mar-02 14:44
cofounderChris Maunder20-Mar-02 14:44 
GeneralRe: .NET Benchmark Challenge Pin
Nish Nishant20-Mar-02 17:14
sitebuilderNish Nishant20-Mar-02 17:14 
GeneralRe: .NET Benchmark Challenge Pin
Jason Hooper20-Mar-02 20:39
Jason Hooper20-Mar-02 20:39 
GeneralRe: .NET Benchmark Challenge Pin
Chris Maunder21-Mar-02 0:01
cofounderChris Maunder21-Mar-02 0:01 
QuestionHow Can I use MFC CView class in my Console application Pin
20-Mar-02 13:33
suss20-Mar-02 13:33 
AnswerRe: How Can I use MFC CView class in my Console application Pin
Nish Nishant20-Mar-02 14:21
sitebuilderNish Nishant20-Mar-02 14:21 
GeneralRe: How Can I use MFC CView class in my Console application Pin
Alex Talazar20-Mar-02 17:49
professionalAlex Talazar20-Mar-02 17:49 
Questionwhy is ::CreatePen() failing? Pin
moredip20-Mar-02 11:18
moredip20-Mar-02 11:18 
Hey all,

I'm getting exceptions thrown when I create a CPen like this:
CPen(PS_SOLID, 4, RGB(0,0,0))

CPen's constructor uses the following code:
if (!Attach(::CreatePen(nPenStyle, nWidth, crColor)))
     AfxThrowResourceException();

and Attach() fails coz ::CreatePen() returns NULL. I can't descend into ::CreatePen(), I assume because the source-code isn't supplied.
Now according to MSDN, "If the function fails, the return value is NULL". But why is it failing?

The constructor only starts throwing exceptions after my app has been running for a while (i.e. about 10mins of hard work), but I don't know enough about MFC to deduce what that means about my problem.

In the ::CreatePen() documentation MSDN says "Windows NT/2000: To get extended error information, call GetLastError.". I tried that in a catch(...) straight after calling CPen's constructor, but the string I get is "Operation Completed". Not really that helpful. And yes, I am running NT Wink | ;)

Why Oh Why is this happeningMad | :mad: ? Has anyone else experienced this? Can anyone suggest anything?

And here's another wierd thing. I have another call to CPen::CPen(...) in another class's member function, and that seem's to work. Or at least it doesn't throw an exception as far as I know.

I hope someone can stop me pulling /all/ my hair out over this!

TIA,

Pete
AnswerRe: why is ::CreatePen() failing? Pin
Joaquín M López Muñoz20-Mar-02 11:20
Joaquín M López Muñoz20-Mar-02 11:20 
GeneralRe: why is ::CreatePen() failing? Pin
moredip20-Mar-02 11:32
moredip20-Mar-02 11:32 
GeneralRe: why is ::CreatePen() failing? Pin
alex.barylski20-Mar-02 14:28
alex.barylski20-Mar-02 14:28 
Generaltesting #define with no token string Pin
20-Mar-02 10:56
suss20-Mar-02 10:56 
GeneralRe: testing #define with no token string Pin
Joaquín M López Muñoz20-Mar-02 11:03
Joaquín M López Muñoz20-Mar-02 11:03 
Generalthe background color of CView Pin
20-Mar-02 10:19
suss20-Mar-02 10:19 
GeneralRe: the background color of CView Pin
Mazdak20-Mar-02 10:29
Mazdak20-Mar-02 10:29 
Generalan others solutions please Pin
20-Mar-02 10:43
suss20-Mar-02 10:43 
GeneralRe: an others solutions please Pin
Paul M Watt20-Mar-02 12:21
mentorPaul M Watt20-Mar-02 12:21 
GeneralThe solution is Pin
20-Mar-02 21:24
suss20-Mar-02 21:24 
QuestionColors: How To? Pin
soup20-Mar-02 9:38
soup20-Mar-02 9:38 
AnswerRe: Colors: How To? Pin
Christian Graus20-Mar-02 9:49
protectorChristian Graus20-Mar-02 9:49 
GeneralRe: Colors: How To? Pin
soup20-Mar-02 13:11
soup20-Mar-02 13:11 
AnswerRe: Colors: How To? Pin
soup20-Mar-02 13:36
soup20-Mar-02 13:36 
GeneralRe: Colors: How To? Pin
Christian Graus20-Mar-02 14:35
protectorChristian Graus20-Mar-02 14:35 
AnswerRe: Colors: How To? Pin
Michael Martin20-Mar-02 15:30
professionalMichael Martin20-Mar-02 15:30 
AnswerRe: Colors: How To? Pin
soup21-Mar-02 11:37
soup21-Mar-02 11:37 

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.