cant attach CDC?
I am not sure what I am doing wrong but it causes an exception.
HDC dc = NULL;
CDC* pdC = NULL;
dc = GetDC(hWnd);
pdC->Attach(dc); *Exception*
I know hWnd is good, I use it in the same class to load an image before entering here, and the value is the same.
thanks,
Matt
Quote:Original post by Code Is Your FriendAt no point in that code do you initialise pdC. You probably want to do:
I am not sure what I am doing wrong but it causes an exception.
HDC dc = NULL;
CDC* pdC = NULL;
dc = GetDC(hWnd);
pdC->Attach(dc); *Exception*
I know hWnd is good, I use it in the same class to load an image before entering here, and the value is the same.
thanks,
Matt
CDC dc = GetDC(hWnd);
That works, but it creates a problem. It only works if the CDC isn't a pointer. And I need it to be a pointer for the next function called, so I either need to convert it to a CDC* somehow, or get the pointer to accept the dc.
Matt
[Edited by - Code Is Your Friend on January 15, 2009 9:35:00 AM]
Matt
[Edited by - Code Is Your Friend on January 15, 2009 9:35:00 AM]
Still having problems with this, I have tried everything I can think of to get the CDC* to take a dc.
Is there just no way to do this?
Matt
Is there just no way to do this?
Matt
Quote:Original post by Code Is Your FriendNo - a CDC* is a pointer to a CDC that already exists. You need to initialise the pointer before you use it.
Still having problems with this, I have tried everything I can think of to get the CDC* to take a dc.
Is there just no way to do this?
Matt
Quote:Original post by Code Is Your FriendWhat function? Can't you just use &dc?:
That works, but it creates a problem. It only works if the CDC isn't a pointer. And I need it to be a pointer for the next function called, so I either need to convert it to a CDC* somehow, or get the pointer to accept the dc.
CDC dc = GetDC(hWnd);SomeFuncThatTakesPointerToCDC(&dc);
Or:
CDC* pDC = new CDC;pDC->Attach(GetDC(hWnd));SomeFuncThatTakesPointerToCDC(pDC);// When you're done with pDC:delete pDC;
I doubt you need it to be a pointer though.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement