How to get HWND from System::Windows::Forms::Panel^ panel [modified]
-
Newbie00 wrote:
Yes GetDC() is returning non-NULL
And the HWND you pass to GetDC() is non-NULL too?
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Newbie00 wrote:
Yes GetDC() is returning non-NULL
And the HWND you pass to GetDC() is non-NULL too?
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Then I would assume the problem is not related to getting the panel's HWND. What does GetLastError() return after the failed
wglCreateContext
call? MarkMark Salsbery Microsoft MVP - Visual C++ :java:
-
Then I would assume the problem is not related to getting the panel's HWND. What does GetLastError() return after the failed
wglCreateContext
call? MarkMark Salsbery Microsoft MVP - Visual C++ :java:
Yeees :] hmmmmmmmm I've tried to use GetLastError() with FormatMessage() like this:
LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL );
But an exception occures: An unhandled exception of type 'System.Runtime.InteropServices.MarshalDirectiveException' occurred in Figury.exe Additional information: Cannot marshal 'parameter #7': Pointers cannot reference marshaled structures. Use ByRef instead. GetLastError() returns 2000, i don't know what to do :[ -
Yeees :] hmmmmmmmm I've tried to use GetLastError() with FormatMessage() like this:
LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL );
But an exception occures: An unhandled exception of type 'System.Runtime.InteropServices.MarshalDirectiveException' occurred in Figury.exe Additional information: Cannot marshal 'parameter #7': Pointers cannot reference marshaled structures. Use ByRef instead. GetLastError() returns 2000, i don't know what to do :[Newbie00 wrote:
GetLastError() returns 2000
...which is ERROR_INVALID_PIXEL_FORMAT. Is that a clue? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Newbie00 wrote:
GetLastError() returns 2000
...which is ERROR_INVALID_PIXEL_FORMAT. Is that a clue? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
how do you know what 2000 means? :O That could be a clue, but it's worse than i thought :O I have no idea why such strange error occures. I've tried this code with C++ Builder 6.0 and everything was ok :O There was no ERROR_INVALID_PIXEL_FORMAT
There's lots of error codes[^] listed in the documentation for GetLastError()[^] :) I'm not sure what's going on with this, or why it would work with builder. I guess this leaves SetupPixelFormat() ... what goes on in there? Is it supposed to have a DC passed to it? If so, is that DC supposed to be a memory DC or can it be a window DC? Since you can't change the format of a window DC, I would expect it requires a memory DC - or does it create one internally? I'm just guessing from what little code I've seen, but I suspect you're passing the wrong DC to wglCreateContext(). Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
There's lots of error codes[^] listed in the documentation for GetLastError()[^] :) I'm not sure what's going on with this, or why it would work with builder. I guess this leaves SetupPixelFormat() ... what goes on in there? Is it supposed to have a DC passed to it? If so, is that DC supposed to be a memory DC or can it be a window DC? Since you can't change the format of a window DC, I would expect it requires a memory DC - or does it create one internally? I'm just guessing from what little code I've seen, but I suspect you're passing the wrong DC to wglCreateContext(). Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Interesting. I don't have that utility either. In fact, I'm pretty sure I've never found any utilities I wanted to find in VS. Yes, there's ones there I never use... *shrug*
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
There's lots of error codes[^] listed in the documentation for GetLastError()[^] :) I'm not sure what's going on with this, or why it would work with builder. I guess this leaves SetupPixelFormat() ... what goes on in there? Is it supposed to have a DC passed to it? If so, is that DC supposed to be a memory DC or can it be a window DC? Since you can't change the format of a window DC, I would expect it requires a memory DC - or does it create one internally? I'm just guessing from what little code I've seen, but I suspect you're passing the wrong DC to wglCreateContext(). Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
I think i'm passing correct DC.
void TFigure::SetupPixelFormat() { int nPixelFormat = 0; PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; nPixelFormat = ChoosePixelFormat( m_gHDC, &pfd ); SetPixelFormat( m_gHDC, nPixelFormat, &pfd ); }
ChoosePixelFormat( m_gHDC, &pfd ); returns 7. -- modified at 13:35 Monday 15th October, 2007