<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[WS_CHILD &#x2F; WS_OVERLAPPED und openGl]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich beschaeftige mich mit embedded WinMain in Tk-Containers und habe ein Problem.</p>
<p>Ich habe:</p>
<pre><code class="language-cpp">...
WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX); 

	wcex.style			= CS_OWNDC | CS_PARENTDC | CS_VREDRAW;
	wcex.lpfnWndProc	= (WNDPROC)WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInstance;
	wcex.hIcon			= LoadIcon(hInstance, (LPCTSTR)IDI_FEOUD);
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= NULL;
	wcex.lpszMenuName	= NULL;
	wcex.lpszClassName	= szWindowClass;
	wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
...
hWnd = CreateWindow(szWindowClass, szTitle, WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, hWndParent, NULL, hInstance, NULL);

...
</code></pre>
<p>Nun kan ich mit WS_CHILD oder mit WS_OVERLAPPEDWINDOW compilieren.<br />
Zweiteres erzeugt ein zweites Fenster und ich sehe dort auch mein openGl-Zeug. Wenn ich es als WS_CHILD compiliere scheint etwas mit den hdc's nicht zu passen. Kann mir jemand einen Tipp geben?</p>
<p>Woran kann es liegen, das es als WS_OVERLAPPEDWINDOW funzt, aber als WS_CHILD nicht?</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/119699/ws_child-ws_overlapped-und-opengl</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Jul 2026 01:00:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/119699.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 Sep 2005 19:31:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to WS_CHILD &#x2F; WS_OVERLAPPED und openGl on Sun, 04 Sep 2005 19:31:33 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich beschaeftige mich mit embedded WinMain in Tk-Containers und habe ein Problem.</p>
<p>Ich habe:</p>
<pre><code class="language-cpp">...
WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX); 

	wcex.style			= CS_OWNDC | CS_PARENTDC | CS_VREDRAW;
	wcex.lpfnWndProc	= (WNDPROC)WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInstance;
	wcex.hIcon			= LoadIcon(hInstance, (LPCTSTR)IDI_FEOUD);
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= NULL;
	wcex.lpszMenuName	= NULL;
	wcex.lpszClassName	= szWindowClass;
	wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
...
hWnd = CreateWindow(szWindowClass, szTitle, WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, hWndParent, NULL, hInstance, NULL);

...
</code></pre>
<p>Nun kan ich mit WS_CHILD oder mit WS_OVERLAPPEDWINDOW compilieren.<br />
Zweiteres erzeugt ein zweites Fenster und ich sehe dort auch mein openGl-Zeug. Wenn ich es als WS_CHILD compiliere scheint etwas mit den hdc's nicht zu passen. Kann mir jemand einen Tipp geben?</p>
<p>Woran kann es liegen, das es als WS_OVERLAPPEDWINDOW funzt, aber als WS_CHILD nicht?</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864868</guid><dc:creator><![CDATA[SaBoro]]></dc:creator><pubDate>Sun, 04 Sep 2005 19:31:33 GMT</pubDate></item><item><title><![CDATA[Reply to WS_CHILD &#x2F; WS_OVERLAPPED und openGl on Sun, 04 Sep 2005 20:12:37 GMT]]></title><description><![CDATA[<p>ist dein hdc vom richtigen fensterhandle?<br />
zeig doch mal deinen pixelformatdesciptor bzw. deinen wesentlichen initcode</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864901</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864901</guid><dc:creator><![CDATA[miller_m]]></dc:creator><pubDate>Sun, 04 Sep 2005 20:12:37 GMT</pubDate></item><item><title><![CDATA[Reply to WS_CHILD &#x2F; WS_OVERLAPPED und openGl on Sun, 04 Sep 2005 20:34:44 GMT]]></title><description><![CDATA[<p>Sag ob noch mehr noetig ist.<br />
Das komische ist, das es als WS_OVERLAPPED funktioniert, aber wenn es als WS_CHILD eingebunden wird, dann geht es nicht.<br />
Ich hab in WM_PAINT auch noch andere Paints drin, die in das selbe HWND gehen, und die landen dort auch. Im WS_OVERLAPPED landen diese DrawText... im WS_CHILD Frame und im WS_OVERLAPPEDWINDOW window.</p>
<p>Also doppenlt, aber die openGl landen nur im Extra-fenster, und nicht doppelt.</p>
<pre><code class="language-cpp">OpenGl opengl;
HWND hWnd;

WinMain(...)
{
...
opengl = OpenGl();
...
}

class OpenGl  
{
public:
	OpenGl();
	virtual ~OpenGl();

	BOOL Init(HWND hWnd); 

	void OnClose();
	GLvoid resize(GLsizei, GLsizei); 
	GLvoid initializeGL(GLsizei, GLsizei); 
	GLvoid drawScene(GLvoid); 

private:

	BOOL bSetupPixelFormat(HDC); 

	HWND hWnd;
	HDC   ghDC; 
	HGLRC ghRC; 

	/* OpenGL globals, defines, and prototypes */ 
	GLfloat latitude, longitude, latinc, longinc; 
	GLdouble radius; 

	GLvoid createObjects();
	void polarView( GLdouble, GLdouble, GLdouble, GLdouble); 
};

BOOL OpenGl::Init(HWND hWnd)
{
        hWnd = hWnd;
	ghDC = GetDC(hWnd); 

	if (!bSetupPixelFormat(ghDC)) 
		return FALSE;		
	DWORD test2 = GetLastError();
	ghRC = wglCreateContext(ghDC);
	DWORD test1 = GetLastError();
	wglMakeCurrent(ghDC, ghRC); 
	DWORD test = GetLastError();

	return TRUE;
}

BOOL  OpenGl::bSetupPixelFormat(HDC hdc) 
{ 
    PIXELFORMATDESCRIPTOR pfd, *ppfd; 
    int pixelformat; 

    ppfd = &amp;pfd; 

    ppfd-&gt;nSize = sizeof(PIXELFORMATDESCRIPTOR); 
    ppfd-&gt;nVersion = 1; 
    ppfd-&gt;dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; 
    ppfd-&gt;dwLayerMask = PFD_MAIN_PLANE; 
    ppfd-&gt;iPixelType = PFD_TYPE_COLORINDEX; 
    ppfd-&gt;cColorBits = 8; 
    ppfd-&gt;cDepthBits = 16; 
    ppfd-&gt;cAccumBits = 0; 
    ppfd-&gt;cStencilBits = 0; 

    pixelformat = ChoosePixelFormat(hdc, ppfd); 

    if ( (pixelformat = ChoosePixelFormat(hdc, ppfd)) == 0 ) 
    { 
        MessageBox(NULL, &quot;ChoosePixelFormat failed&quot;, &quot;Error&quot;, MB_OK); 
        return FALSE; 
    } 

    if (SetPixelFormat(hdc, pixelformat, ppfd) == FALSE) 
    { 
        MessageBox(NULL, &quot;SetPixelFormat failed&quot;, &quot;Error&quot;, MB_OK); 
        return FALSE; 
    } 

    return TRUE; 
}

WndProc:
...
                case WM_CREATE: 
			if(!opengl.Init(hWnd))
				PostQuitMessage (0); 

			GetClientRect(hWnd, &amp;rt); 
			opengl.initializeGL(rt.right, rt.bottom); 
			break; 
		case WM_MOVE:       /* The frame has moved */
			GetClientRect( hWnd, &amp;rt );
			InvalidateRect(hWnd,&amp;rt,TRUE);
                        break;

		case WM_SIZE:       /* The frame changed size */
			GetClientRect( hWnd, &amp;rt );
			opengl.resize(rt.right, rt.bottom);
			InvalidateRect(hWnd,&amp;rt,TRUE);
                        break;
		case WM_CLOSE: 
			opengl.OnClose();

			DestroyWindow (hWnd); 
			break; 
		case WM_PAINT:
			opengl.drawScene();
		        hdc = BeginPaint (hWnd, &amp;ps);
			GetClientRect( hWnd, &amp;rt );
		        DrawFocusRect(hdc,&amp;rt);
			DrawText( hdc, &quot;test&quot;, 4, &amp;rt, DT_CENTER );
			EndPaint( hWnd, &amp;ps );
			break;
		case WM_DESTROY:
			DestroyWindow(hWnd);
			PostQuitMessage( 0 );
			break;
		default:                      CallWindowProc(lpPrevWndFunc,hWnd,message,
wParam,lParam);
		        return DefWindowProc( hWnd, message, wParam, lParam );

...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/864929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864929</guid><dc:creator><![CDATA[SaBoro]]></dc:creator><pubDate>Sun, 04 Sep 2005 20:34:44 GMT</pubDate></item><item><title><![CDATA[Reply to WS_CHILD &#x2F; WS_OVERLAPPED und openGl on Sun, 04 Sep 2005 20:41:50 GMT]]></title><description><![CDATA[<p>Der Witz ist:</p>
<p>Im WS_OVERLAPPED habe ich also zwei Fenster. Das eine (Tcl/)Tk-Fenster und mein neues Fester(openGl). Das Tk-Fenster hat ein freien Frame in den das WS_CHILD passen soll.</p>
<p>Wenn ich jetzt mein Tk-Fenster verziehe, dann wird auch meine openGL-Szene in der groesse wie gewollt upgedateded und die Szene hat genau die Groesse wie der freie Frame.</p>
<p>Aber wenn ich nun WS_CHILD compiliere is nix mit openGL.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/864931</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/864931</guid><dc:creator><![CDATA[SaBoro]]></dc:creator><pubDate>Sun, 04 Sep 2005 20:41:50 GMT</pubDate></item></channel></rss>