<?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[Frage zu GetMessage]]></title><description><![CDATA[<p>Hi,</p>
<p>in der MSDN steht folgendes:</p>
<p><strong>The GetMessage function retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a posted message is available for retrieval.</strong></p>
<p>Wenn ich das also richtig verstehe bedeutet das, dass man in einer Anwendung<br />
die z.B. aus verschieden Dialogen, aber aus nur einem Thread besteht alle Messages in z.B. so einen Loop bekommt:</p>
<pre><code class="language-cpp">while( GetMessage(&amp;mMsg, NULL, 0, 0) ) {			
			if( PeekMessage(&amp;mMsg, 0, 0, 0, PM_REMOVE) )
		        if( mMsg.message == WM_QUIT ) 
					break;		    
			TranslateMessage(&amp;mMsg);
			DispatchMessage(&amp;mMsg);
		}
</code></pre>
<p>Ich hab nämlich folgendes Problem. Ich habe eine Anwendung die per Button<br />
einen Dialog generiert(mit CreateDialog).<br />
Bei CreateDialog ist ja das MessageHandling nicht so implementiert wie z.B.<br />
einer DialogBox, daher arbeite man ja mit diesem MessageLoop.</p>
<p>Nach ich also das Button klicke und der Dialog erscheint will ich die Anwendung schließen durch kllck auf den auf den schließenButton.</p>
<p>Der SchließenButton befindet sich im HauptDialog und bevor ich den HauptDialog<br />
durch z.B. DestroyWindow zerstöre mache ich zuvor das gleiche mit dem<br />
anderen Dialog (habe mir das Handle bei der Instanzierung des Dialogs gesichtert) durch DestroyWindow.</p>
<p>Wenn ich nun aber im TaskManager nachschau ist der HauptProzess immer noch nicht beendet.<br />
Wenn ich den NebenDialog nicht durch klick öffne und die Anwendung vorher einfach schließe habe ich keinen Prozess mehr im Speicher.<br />
D.h. das etwas beim schliessen des NebenDialogs schief ging.<br />
Ich habs auch schon mit SendMessage und WM_DESTROY versucht aber das war auch nicht erfolgreich.</p>
<p>Ich habe irgendwie das Gefühl das die Messages den NebenDialog nicht erreichen.<br />
Bei bedarf poste ich gerne Code.</p>
<p>Danke schonmal,</p>
<p>Gruß,</p>
<p>G.Ben</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/104541/frage-zu-getmessage</link><generator>RSS for Node</generator><lastBuildDate>Sat, 02 May 2026 05:47:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/104541.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 20 Mar 2005 20:26:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage zu GetMessage on Sun, 20 Mar 2005 20:26:39 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>in der MSDN steht folgendes:</p>
<p><strong>The GetMessage function retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a posted message is available for retrieval.</strong></p>
<p>Wenn ich das also richtig verstehe bedeutet das, dass man in einer Anwendung<br />
die z.B. aus verschieden Dialogen, aber aus nur einem Thread besteht alle Messages in z.B. so einen Loop bekommt:</p>
<pre><code class="language-cpp">while( GetMessage(&amp;mMsg, NULL, 0, 0) ) {			
			if( PeekMessage(&amp;mMsg, 0, 0, 0, PM_REMOVE) )
		        if( mMsg.message == WM_QUIT ) 
					break;		    
			TranslateMessage(&amp;mMsg);
			DispatchMessage(&amp;mMsg);
		}
</code></pre>
<p>Ich hab nämlich folgendes Problem. Ich habe eine Anwendung die per Button<br />
einen Dialog generiert(mit CreateDialog).<br />
Bei CreateDialog ist ja das MessageHandling nicht so implementiert wie z.B.<br />
einer DialogBox, daher arbeite man ja mit diesem MessageLoop.</p>
<p>Nach ich also das Button klicke und der Dialog erscheint will ich die Anwendung schließen durch kllck auf den auf den schließenButton.</p>
<p>Der SchließenButton befindet sich im HauptDialog und bevor ich den HauptDialog<br />
durch z.B. DestroyWindow zerstöre mache ich zuvor das gleiche mit dem<br />
anderen Dialog (habe mir das Handle bei der Instanzierung des Dialogs gesichtert) durch DestroyWindow.</p>
<p>Wenn ich nun aber im TaskManager nachschau ist der HauptProzess immer noch nicht beendet.<br />
Wenn ich den NebenDialog nicht durch klick öffne und die Anwendung vorher einfach schließe habe ich keinen Prozess mehr im Speicher.<br />
D.h. das etwas beim schliessen des NebenDialogs schief ging.<br />
Ich habs auch schon mit SendMessage und WM_DESTROY versucht aber das war auch nicht erfolgreich.</p>
<p>Ich habe irgendwie das Gefühl das die Messages den NebenDialog nicht erreichen.<br />
Bei bedarf poste ich gerne Code.</p>
<p>Danke schonmal,</p>
<p>Gruß,</p>
<p>G.Ben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/749081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/749081</guid><dc:creator><![CDATA[G.Ben]]></dc:creator><pubDate>Sun, 20 Mar 2005 20:26:39 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Sun, 20 Mar 2005 21:05:58 GMT]]></title><description><![CDATA[<p>GetMessage() macht dasselbe wie PeekMessage() mit PM_REMOVE !!<br />
Nur das GetMessage() solange wartet, bis eine Nachricht ankommt, während PeekMessage() sofort true oder false zurückliefert.</p>
<p>Du rufst also z.B. mit GetMessage() die WM_MOUSEMOVE Nachricht ab und direkt danach mit PeekMessage() meinetwegen die WM_QUIT Nachricht.<br />
In dem Falle wäre die WM_MOUSEMOVE-Nachricht einfach verloren gegangen...</p>
<p>Sobald GetMessage() die WM_QUIT sieht, liefert es false zurück und es wird aus while() rausgesprungen. Wenn WM_QUIT von PeekMessage() bereits empfangen wurde kommt es bei GetMessage() nicht mehr an und du bleibst in der while-schleife.<br />
d.h. dein programm läuft weiter, aber die fenster wurden geschlossen...</p>
<p>Es reicht so:</p>
<pre><code class="language-cpp">while(GetMessage(&amp;mMsg, NULL, 0, 0))
{           
   TranslateMessage(&amp;mMsg);
   DispatchMessage(&amp;mMsg);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/749112</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/749112</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sun, 20 Mar 2005 21:05:58 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Sun, 20 Mar 2005 21:46:46 GMT]]></title><description><![CDATA[<p>Hi geeky,</p>
<p>ich habe eben gerade deine Version probiert, soll heißen ich habe auch<br />
der Procedure von meinem MainDialog und meinem NebenDialog den MSG-Loop<br />
entsprechend verändert.</p>
<p>Ausser das die beiden Fenster schneller schließen hat sich nix geändert.<br />
Der Prozess is immer noch da <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Ich paste hier mal meinen Code: (Kann bischen übel werden also bitte keine<br />
kritik am Code-Stil :))</p>
<pre><code>#include &quot;template.h&quot;

#include &quot;skin/skin.h&quot;

HINSTANCE hMainInstance=NULL;

int global = 0;

VOID alignRightMenu(HWND hMainWindow, HWND hRightMenu) {
	RECT r;
	GetWindowRect(hMainWindow, &amp;r);
	SetWindowPos(hRightMenu,HWND_TOPMOST,r.left+(global+8),r.top,200,300,SWP_SHOWWINDOW);
}

BOOL CALLBACK ContextDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	if(uMsg==WM_INITDIALOG) {
		SetWindowText(hwnd, APPLICATION_ABOUT_NAME);

		hContext = hwnd;

		alignRightMenu(hMain,hwnd);

		CSkin skSkin(IDR_CONTEXT, IDB_CONTEXT);		
		skSkin.Hook(hwnd);		
		skSkin.Enable(true);		

		int iWidth = skSkin.Width();
		int iHeight = skSkin.Height();		
		int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); 
		int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN);
		RECT rc = { (iSw - iWidth)/2, (iSh - iHeight)/2, iWidth, iHeight };		

		ShowWindow(hwnd, SW_SHOW);

		MSG mMsg;
		while( GetMessage(&amp;mMsg, NULL, 0, 0) ) {
			TranslateMessage(&amp;mMsg);
			DispatchMessage(&amp;mMsg);
		}		

		DestroyWindow(hwnd);
		// Skin-Init-Ende

		return TRUE;
	}//WM_INITDIALOG

	else if(uMsg==WM_COMMAND) {
	}//WM_COMMAND

	else if(uMsg==WM_CLOSE) {
		bContextHandleExists = false;
		EndDialog(hwnd,1);		
        return 0;
    }// WM_CLOSE

	else if(uMsg==WM_WINDOWPOSCHANGED) {
		RECT r;
		GetWindowRect(hwnd, &amp;r);

		POINT lp;

		GetCursorPos(&amp;lp);		

		if(r.left &lt; lp.x &amp;&amp; r.right &gt; lp.x){
			alignRightMenu(hMain,hwnd);
			MessageBeep(1000);
		}
	}

	else if(uMsg==WM_CTLCOLORDLG){
		SetBkMode((HDC)wParam,TRANSPARENT);
		// Texthintergrund auf transparent setzen 
        SetTextColor((HDC)wParam,RGB(255,204,0));
		// Textfarbe auf Gelb setzen 
        return (BOOL)CreateSolidBrush(RGB(0,0,0));
		// Hintergrundfarbe auf schwarz setzen 
	}//WM_CTLCOLORDLG

	else {
		return FALSE;
	}//ELSE

	return TRUE;
}

LRESULT CALLBACK NewStaticProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	if(uMsg == WM_MOUSEMOVE) {
		if (!bMouseInWindow) {		
			bMouseInWindow = true;

			if (hWnd == hWndStaticButtonOk)
				SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapOkOver );
			if (hWnd == hWndStaticButtonClose)
				SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapCloseOver );
			if (hWnd == hWndStaticIconExit)
				SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconExitOver );
			if (hWnd == hWndStaticIconMinimize)
				SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconMinimizeOver );

			TRACKMOUSEEVENT tme;
			tme.cbSize = sizeof(tme);
			tme.dwFlags = TME_LEAVE | TME_HOVER;
			tme.hwndTrack = hWnd;
			tme.dwHoverTime = HOVER_DEFAULT;
			TrackMouseEvent(&amp;tme);
		}else{
			if (hWnd == hWndStaticButtonOk)
				return CallWindowProc(wpOrigButtonOkProc, hWnd, uMsg, wParam, lParam);
			else if (hWnd == hWndStaticButtonClose)
				return CallWindowProc(wpOrigButtonCloseProc, hWnd, uMsg, wParam, lParam);
			else if (hWnd == hWndStaticIconExit)
				return CallWindowProc(wpOrigIconExitProc, hWnd, uMsg, wParam, lParam);
			else if (hWnd == hWndStaticIconMinimize)
				return CallWindowProc(wpOrigIconMinimizeProc, hWnd, uMsg, wParam, lParam);
		}

	}else if(uMsg == WM_MOUSELEAVE) {
		bMouseInWindow = false;			

		if (hWnd == hWndStaticButtonOk)
			SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapOk);
		else if (hWnd == hWndStaticButtonClose)
			SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapClose);
		else if (hWnd == hWndStaticIconExit)
			SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconExit);
		else if (hWnd == hWndStaticIconMinimize)
			SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconMinimize);

	}else {
		if (hWnd == hWndStaticButtonOk)
			return CallWindowProc(wpOrigButtonOkProc, hWnd, uMsg, wParam, lParam);
		else if (hWnd == hWndStaticButtonClose)
			return CallWindowProc(wpOrigButtonCloseProc, hWnd, uMsg, wParam, lParam);
		else if (hWnd == hWndStaticIconExit)
			return CallWindowProc(wpOrigIconExitProc, hWnd, uMsg, wParam, lParam);
		else if (hWnd == hWndStaticIconMinimize)
			return CallWindowProc(wpOrigIconMinimizeProc, hWnd, uMsg, wParam, lParam);
	}		

	return true;
}

VOID terminateAll() {
	/* Handle zum Hauptfenster.
	 * Wird als letztes aufgelöst!
	 */
	HWND handleToMainDialog;

	/*
	 * Handle zum ContextFenster.
	 * Wird zuerst augelöst!
	 */
	HWND handleToContextDialog;

	handleToMainDialog		= hMain;
	handleToContextDialog	= hContext;

	DestroyWindow(handleToContextDialog);
	DestroyWindow(handleToMainDialog);
}

BOOL CALLBACK MainDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {	
	if(Message==WM_INITDIALOG) {	

		hMain = hwnd;

		SetWindowText(hwnd, APPLICATION_NAME);
		SetDlgItemText(hwnd, IDC_STATIC_APP_TITLE, APPLICATION_NAME);

		hBitmapOk				= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_OK));
		hBitmapOkOver			= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_OK_OVER));
		hBitmapClose			= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_CLOSE));
		hBitmapCloseOver		= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_CLOSE_OVER));		
		hBitmapIconExit			= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_ICONEXIT));
		hBitmapIconExitOver		= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_ICONEXIT_OVER));		
		hBitmapIconMinimize		= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_ICONMINIMIZE));
		hBitmapIconMinimizeOver = LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_ICONMINIMIZE_OVER));		

		hWndStaticButtonOk		= GetDlgItem(hwnd, IDC_STATICOK);
		hWndStaticButtonClose	= GetDlgItem(hwnd, IDC_STATICCLOSE);
		hWndStaticIconExit		= GetDlgItem(hwnd, IDC_STATICICONEXIT);
		hWndStaticIconMinimize	= GetDlgItem(hwnd, IDC_STATICICONMINIMIZE);

		SendMessage(hWndStaticButtonOk, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapOk );		
		SendMessage(hWndStaticButtonClose, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapClose );			
		SendMessage(hWndStaticIconExit, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconExit );	
		SendMessage(hWndStaticIconMinimize, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconMinimize );	

		wpOrigButtonOkProc		= (WNDPROC) SetWindowLong(hWndStaticButtonOk, GWL_WNDPROC, (LONG) NewStaticProc);
		wpOrigButtonCloseProc	= (WNDPROC) SetWindowLong(hWndStaticButtonClose, GWL_WNDPROC, (LONG) NewStaticProc);
		wpOrigIconExitProc		= (WNDPROC) SetWindowLong(hWndStaticIconExit, GWL_WNDPROC, (LONG) NewStaticProc);
		wpOrigIconMinimizeProc	= (WNDPROC) SetWindowLong(hWndStaticIconMinimize, GWL_WNDPROC, (LONG) NewStaticProc);

		// Skin-Init-Beginn
		CSkin skSkin(IDR_SPLASH, IDB_SPLASH);		
		skSkin.Hook(hwnd);		
		skSkin.Enable(true);		

		int iWidth = skSkin.Width();
		int iHeight = skSkin.Height();		
		int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); 
		int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN);
		RECT rc = { (iSw - iWidth)/2, (iSh - iHeight)/2, iWidth, iHeight };		

		global = iWidth;

		ShowWindow(hwnd, SW_SHOW);

		MSG mMsg;
		while( GetMessage(&amp;mMsg, NULL, 0, 0) ) {			
			TranslateMessage(&amp;mMsg);
			DispatchMessage(&amp;mMsg);		 
		}		

		DestroyWindow(hwnd);
		// Skin-Init-Ende		

	}

	else if (Message==WM_CTLCOLORSTATIC){         
		SetBkMode((HDC)wParam,TRANSPARENT);		
        SetTextColor((HDC)wParam,RGB(255,255,255));		
        return (long)CreateSolidBrush(RGB(73,114,208));		
	}//WM_CTLCOLOREDIT

	else if(Message==WM_COMMAND) {	
		if(wParam == IDC_STATICCLOSE || wParam == IDC_STATICICONEXIT)
			DestroyWindow( hwnd );		
		else if(wParam == IDC_STATICICONMINIMIZE)
			ShowWindow(hwnd,SW_MINIMIZE);
		if(hContext != NULL) {
				ShowWindow(hContext,SW_MINIMIZE);
		}
		else if(wParam == IDC_STATICOK) {
			if(!bContextHandleExists) {				
				bContextHandleExists = true;
				hContext = CreateDialog(hMainInstance, MAKEINTRESOURCE(IDD_CONTEXT), hwnd, ContextDlgProc);					
			}			
		}
	}

	else if(Message==WM_CLOSE) {
		//terminateAll();
		SendMessage(hContext,WM_QUIT,NULL,NULL);
		if(hContext == NULL) {
			MessageBox(NULL,NULL,NULL,NULL);
		}

		DestroyWindow( hwnd );
		return 0;
	}

	else if(Message==WM_DESTROY) {
		PostQuitMessage (0);
		return 0;
	}

	else if(Message==WM_WINDOWPOSCHANGED) {
		if(hContext != NULL) {
			alignRightMenu(hwnd,hContext);
		}
	}

	else{
		return FALSE;
	}

	return TRUE;
}

BOOL CALLBACK SplashDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
	if(Message==WM_INITDIALOG) {	

		// sets the icon of the application displayed 
		// in the upper left corner
		SetClassLong(hwnd, GCL_HICON, (LONG)LoadIcon(hMainInstance, (LPCTSTR)IDI_TEMPLATE));

		SetWindowText(hwnd, APPLICATION_NAME);
		SetTimer(hwnd,1,2000,NULL);

		// Skin-Init-Beginn
		CSkin skSkin(IDR_SPLASH, IDB_SPLASH);		
		skSkin.Hook(hwnd);		
		skSkin.Enable(true);		

		int iWidth = skSkin.Width();
		int iHeight = skSkin.Height();		
		int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); 
		int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN);
		RECT rc = { (iSw - iWidth)/2, (iSh - iHeight)/2, iWidth, iHeight };		

		ShowWindow(hwnd, SW_SHOW);

		MSG mMsg;
		while( GetMessage(&amp;mMsg, NULL, 0, 0) ) {			
			if( PeekMessage(&amp;mMsg, 0, 0, 0, PM_REMOVE) )
		        if( mMsg.message == WM_QUIT ) 
					break;
		    TranslateMessage( &amp;mMsg );
			DispatchMessage( &amp;mMsg );
		}		

		DestroyWindow(hwnd);
		// Skin-Init-Ende

        return TRUE;				
	}//WM_INITDIALOG

	else if (Message == WM_TIMER) {
		KillTimer(hwnd,1);

		EndDialog(hwnd,IDD_SPLASH);		
		DialogBox(hMainInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDlgProc);	
	}//WM_TIMER

	else if(Message==WM_COMMAND) {
	}//WM_COMMAND

	else if(Message==WM_CLOSE) {
		EndDialog(hwnd,1);
        return 0;
    }// WM_CLOSE

	else {
		return FALSE;
	}//ELSE

	return TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPSTR lpCmdLine, int nCmdShow) { 
	hMainInstance = hInstance;

	// show splashscreen on startup ?
	DEBUG_LOAD_SPLASH = false;

	if(DEBUG_LOAD_SPLASH) {
		return DialogBox(hInstance, MAKEINTRESOURCE(IDD_SPLASH), NULL, SplashDlgProc);
	}else {		
		return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDlgProc);
	}	
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/749141</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/749141</guid><dc:creator><![CDATA[G.Ben]]></dc:creator><pubDate>Sun, 20 Mar 2005 21:46:46 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Sun, 20 Mar 2005 22:11:33 GMT]]></title><description><![CDATA[<p>1.) Bei modalen Dialogen hat man gar keine Message-Loop!<br />
2.) Schon mal was von switch/case gehört?!</p>
<p>Vielleicht solltest du dir z.B. <a href="http://www.winapi.net/index.php?inhalt=tipp2" rel="nofollow">das hier</a> mal anschauen - oder auch <a href="http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/usingdialogboxes.asp" rel="nofollow">das hier</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/749162</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/749162</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sun, 20 Mar 2005 22:11:33 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Mon, 21 Mar 2005 10:21:46 GMT]]></title><description><![CDATA[<p>3.) i.d.R. langt eine Nachrichtenschleife pro Prozess (bei dir seh ich mindestens 3)<br />
4.) du scheinst das Prinzip der Nachrichtenverarbeitung IMHO noch nicht 100%ig verstanden zu haben<br />
5.) bei dem Code ist &quot;übel&quot; untertrieben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>hier noch ein Link für dich: <a href="http://www.henkessoft.de/inhalt.htm" rel="nofollow">http://www.henkessoft.de/inhalt.htm</a> (insb.: <a href="http://www.henkessoft.de/api4.htm" rel="nofollow">http://www.henkessoft.de/api4.htm</a> )</p>
]]></description><link>https://www.c-plusplus.net/forum/post/749338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/749338</guid><dc:creator><![CDATA[D*niel *chumann]]></dc:creator><pubDate>Mon, 21 Mar 2005 10:21:46 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Mon, 21 Mar 2005 22:25:38 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/1644">@flenders</a>: ich weiß wie man switch/case verwendet, aber es gefällt mir nicht.<br />
Außerdem gibt es keinen logischen Grund die einer normalen íf-anweisung vorzuziehen. Und über Programmier-Stil lässt sich nicht streiten solange der<br />
code syntaktisch korrekt ist.<br />
Deine Links zeigen mir zwar wie man switsch/case verwendet, haben aber leider nichts direktes mit meinem Problem zu tun.<br />
Trotzdem Danke</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16566">@D</a>@niel $chumann :<br />
zu 3.: Das war ja eigentlich meine anfänglich Frage weil ich es eben genauso<br />
gesehen habe mehrere Loops sind also überflüssig in der Form wie ich sie verwende, da ich ja sowieso nur einen Prozess habe.<br />
zu 4.: Da gebe ich dir 100 % recht, sonst würde ich ja auch nicht fragen gell <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
zu 5. Ich hab mir die Beispiele angeschaut, aber ich kann leider nicht erkennen wie mir das weiterhelfen soll. Mit ein bischen erklärung zu dem<br />
Warum es bei meinem Beispiel nicht klappt wäre mir sehr geholfen.</p>
<p>Danke nochmal.</p>
<p>Gruß G.Ben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/749904</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/749904</guid><dc:creator><![CDATA[G.Ben]]></dc:creator><pubDate>Mon, 21 Mar 2005 22:25:38 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Mon, 21 Mar 2005 22:35:06 GMT]]></title><description><![CDATA[<p>flenders schrieb:</p>
<blockquote>
<p>Bei modalen Dialogen hat man gar keine Message-Loop!</p>
</blockquote>
<p>Hast du das überlesen bzw. in den Beispielen irgendwo eine Message-Loop gesehen?!</p>
<p>Ich will jetzt nicht über deinen Programmierstil streiten, aber was gefällt dir an switch/case nicht bzw. was findest du an if/else in diesem Umfang besser? Ich persönlich finde es mit switch/case eben wesentlich übersichtlicher <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/749912</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/749912</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Mon, 21 Mar 2005 22:35:06 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Mon, 21 Mar 2005 22:52:46 GMT]]></title><description><![CDATA[<p>flenders schrieb:</p>
<blockquote>
<p>flenders schrieb:</p>
<blockquote>
<p>Bei modalen Dialogen hat man gar keine Message-Loop!</p>
</blockquote>
<p>Hast du das überlesen bzw. in den Beispielen irgendwo eine Message-Loop gesehen?!</p>
</blockquote>
<p>nur in die 'winmain' muss eine rein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/749932</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/749932</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Mon, 21 Mar 2005 22:52:46 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Tue, 22 Mar 2005 09:16:25 GMT]]></title><description><![CDATA[<p>Nein - siehe auch: <a href="http://www.winapi.net/index.php?inhalt=tipp2" rel="nofollow">http://www.winapi.net/index.php?inhalt=tipp2</a><br />
DialogBox kehrt ja erst zurück, wenn der Dialog wieder geschlossen wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/750049</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/750049</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Tue, 22 Mar 2005 09:16:25 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Thu, 24 Mar 2005 20:07:29 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/1644">@flenders</a>: Ich kann nicht begründen warum mir sw-anweisungen nicht gefallen.<br />
Bei mir is eher das gegenteil der fall. Ich finde sie eher unübersichtlich, aber wie gesagt, das ist ansichtsache.</p>
<p>Leider bin ich noch nicht weiter mit meinem Problem.<br />
Vielleicht sollte ich versuchen meine Fenster anstelle mir DialogBox mit<br />
CreateWindow zu machen.</p>
<p>Hat sonst noch jemand einen Tip wie ich mein kleines MessageProblem lösen kann ?</p>
<p>G.Ben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/752171</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/752171</guid><dc:creator><![CDATA[G.Ben]]></dc:creator><pubDate>Thu, 24 Mar 2005 20:07:29 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Thu, 24 Mar 2005 21:00:59 GMT]]></title><description><![CDATA[<blockquote>
<p>Hat sonst noch jemand einen Tip wie ich mein kleines MessageProblem lösen kann ?</p>
</blockquote>
<p>Tsss. Es wurden dir doch schon genug Tipps gegeben. Ich glaube, du hast dir die Beiträge von z.B. flenders gar nicht richtig durchgelesen. Alle MessageLoops raus - feddich!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/752210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/752210</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Thu, 24 Mar 2005 21:00:59 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Thu, 24 Mar 2005 21:25:54 GMT]]></title><description><![CDATA[<p>Tja, das geht leider nicht.<br />
Da ich ein spezielles Skin-AddOn verwende is es leider nicht so simple.<br />
Sieht man aber auch am Code wenn man hinschaut <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>z.B.</p>
<pre><code class="language-cpp">CSkin skSkin(IDR_CONTEXT, IDB_CONTEXT);		
		skSkin.Hook(hwnd);		
		skSkin.Enable(true);		

		int iWidth = skSkin.Width();
		int iHeight = skSkin.Height();		
		int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); 
		int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN);
		RECT rc = { (iSw - iWidth)/2, (iSh - iHeight)/2, iWidth, iHeight };		

		ShowWindow(hwnd, SW_SHOW);		

		MSG msg;
		BOOL bRet;
		while ( (bRet = GetMessage(&amp;msg, NULL, 0, 0)) != 0 ) 
		{ 
			if (bRet == -1 )
			{

			}
			else if (!IsWindow(hMain) || !IsDialogMessage(hMain, &amp;msg)) 
			{ 

				TranslateMessage(&amp;msg); 
				DispatchMessage(&amp;msg); 
			} 
		}

		DestroyWindow(hwnd);
		// Skin-Init-Ende
</code></pre>
<p>Bisher habe ich immer nur einen &quot;geskinten&quot; Dialog gehabt, da war das kein Problem(da ja nur ein MessageLoop vorkam).<br />
Jetzt will ich aber in meiner Anwendung verschiedene Dialog verwenden, mit verschiedenen Skins.<br />
Der AddOn ist dafür wahrscheinlich nicht ausgelegt, aber ich bin sich das es irgendwie geht.<br />
Deshalb versuche ich hier mir Hilfe zu holen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/752232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/752232</guid><dc:creator><![CDATA[G.Ben]]></dc:creator><pubDate>Thu, 24 Mar 2005 21:25:54 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Thu, 24 Mar 2005 21:53:54 GMT]]></title><description><![CDATA[<p>Ich verstehe nicht ganz, was das Problem mit der Skin-Klasse sein soll. Nimm doch einfach mal alle MessageLoops raus, die du hast. Deine Anwendung hat doch schon eine - die siehst du nur nicht. Jeder GUI-Thread in Windows besitzt eine MessageLoop. Da du eine dialogbasierte Anwendung hast, musst du explizit keine MessageLoop programmieren. Aber sie ist da.</p>
<p>P.S.: Jeder <strong>Thread</strong> - nicht jedes <strong>Fenster</strong>!!! - braucht eine Message-Loop.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/752248</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/752248</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Thu, 24 Mar 2005 21:53:54 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Fri, 25 Mar 2005 11:20:39 GMT]]></title><description><![CDATA[<p>Ich hab natürlich versucht sämtliche MessageLoop rauszumachen und zwar ALLE.<br />
Wie man im Code sieht musste ich dann noch die DestroyWindow entfernen sonst hat sich die Anwendungen bzw. die jeweiligen Dialoge sofort beendet.</p>
<p>Wenn ich das App nun starte bekomme ich statt meinen schönen SkinBMPs als Hintergrund nur die Fenster zu sehen aber komplett in Schwarz.</p>
<p>Ich paste nochmal die Version ohne MSG-Loops</p>
<p>mfg</p>
<pre><code class="language-cpp">#include &quot;template.h&quot;

#include &quot;skin/skin.h&quot;

HINSTANCE hMainInstance=NULL;

int global = 0;

VOID alignRightMenu(HWND hMainWindow, HWND hRightMenu) {
	RECT r;
	GetWindowRect(hMainWindow, &amp;r);
	SetWindowPos(hRightMenu,HWND_TOPMOST,r.left+(global+8),r.top,200,300,SWP_SHOWWINDOW);
}

BOOL CALLBACK ContextDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	if(uMsg==WM_INITDIALOG) {
		SetWindowText(hwnd, APPLICATION_ABOUT_NAME);

		hContext = hwnd;

		alignRightMenu(hMain,hwnd);

		CSkin skSkin(IDR_CONTEXT, IDB_CONTEXT);		
		skSkin.Hook(hwnd);		
		skSkin.Enable(true);		

		int iWidth = skSkin.Width();
		int iHeight = skSkin.Height();		
		int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); 
		int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN);
		RECT rc = { (iSw - iWidth)/2, (iSh - iHeight)/2, iWidth, iHeight };		

		ShowWindow(hwnd, SW_SHOW);		

		return TRUE;
	}//WM_INITDIALOG

	else if(uMsg==WM_COMMAND) {
	}//WM_COMMAND

	else if(uMsg==WM_CLOSE) {
		bContextHandleExists = false;
		EndDialog(hwnd,1);		
        return 0;
    }// WM_CLOSE

	else if(uMsg==WM_WINDOWPOSCHANGED) {
		RECT r;
		GetWindowRect(hwnd, &amp;r);

		POINT lp;

		GetCursorPos(&amp;lp);		

		if(r.left &lt; lp.x &amp;&amp; r.right &gt; lp.x){
			alignRightMenu(hMain,hwnd);
			MessageBeep(1000);
		}
	}

	else if(uMsg==WM_CTLCOLORDLG){
		SetBkMode((HDC)wParam,TRANSPARENT);
		// Texthintergrund auf transparent setzen 
        SetTextColor((HDC)wParam,RGB(255,204,0));
		// Textfarbe auf Gelb setzen 
        return (BOOL)CreateSolidBrush(RGB(0,0,0));
		// Hintergrundfarbe auf schwarz setzen 
	}//WM_CTLCOLORDLG

	else {
		return FALSE;
	}//ELSE

	return TRUE;
}

LRESULT CALLBACK NewStaticProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	if(uMsg == WM_MOUSEMOVE) {
		if (!bMouseInWindow) {		
			bMouseInWindow = true;

			if (hWnd == hWndStaticButtonOk)
				SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapOkOver );
			if (hWnd == hWndStaticButtonClose)
				SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapCloseOver );
			if (hWnd == hWndStaticIconExit)
				SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconExitOver );
			if (hWnd == hWndStaticIconMinimize)
				SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconMinimizeOver );

			TRACKMOUSEEVENT tme;
			tme.cbSize = sizeof(tme);
			tme.dwFlags = TME_LEAVE | TME_HOVER;
			tme.hwndTrack = hWnd;
			tme.dwHoverTime = HOVER_DEFAULT;
			TrackMouseEvent(&amp;tme);
		}else{
			if (hWnd == hWndStaticButtonOk)
				return CallWindowProc(wpOrigButtonOkProc, hWnd, uMsg, wParam, lParam);
			else if (hWnd == hWndStaticButtonClose)
				return CallWindowProc(wpOrigButtonCloseProc, hWnd, uMsg, wParam, lParam);
			else if (hWnd == hWndStaticIconExit)
				return CallWindowProc(wpOrigIconExitProc, hWnd, uMsg, wParam, lParam);
			else if (hWnd == hWndStaticIconMinimize)
				return CallWindowProc(wpOrigIconMinimizeProc, hWnd, uMsg, wParam, lParam);
		}

	}else if(uMsg == WM_MOUSELEAVE) {
		bMouseInWindow = false;			

		if (hWnd == hWndStaticButtonOk)
			SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapOk);
		else if (hWnd == hWndStaticButtonClose)
			SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapClose);
		else if (hWnd == hWndStaticIconExit)
			SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconExit);
		else if (hWnd == hWndStaticIconMinimize)
			SendMessage(hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconMinimize);

	}else {
		if (hWnd == hWndStaticButtonOk)
			return CallWindowProc(wpOrigButtonOkProc, hWnd, uMsg, wParam, lParam);
		else if (hWnd == hWndStaticButtonClose)
			return CallWindowProc(wpOrigButtonCloseProc, hWnd, uMsg, wParam, lParam);
		else if (hWnd == hWndStaticIconExit)
			return CallWindowProc(wpOrigIconExitProc, hWnd, uMsg, wParam, lParam);
		else if (hWnd == hWndStaticIconMinimize)
			return CallWindowProc(wpOrigIconMinimizeProc, hWnd, uMsg, wParam, lParam);
	}		

	return true;
}

BOOL CALLBACK MainDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {	
	if(Message==WM_INITDIALOG) {	

		hMain = hwnd;

		SetWindowText(hwnd, APPLICATION_NAME);
		SetDlgItemText(hwnd, IDC_STATIC_APP_TITLE, APPLICATION_NAME);

		hBitmapOk				= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_OK));
		hBitmapOkOver			= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_OK_OVER));
		hBitmapClose			= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_CLOSE));
		hBitmapCloseOver		= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_CLOSE_OVER));		
		hBitmapIconExit			= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_ICONEXIT));
		hBitmapIconExitOver		= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_ICONEXIT_OVER));		
		hBitmapIconMinimize		= LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_ICONMINIMIZE));
		hBitmapIconMinimizeOver = LoadBitmap(hMainInstance, MAKEINTRESOURCE(IDB_ICONMINIMIZE_OVER));		

		hWndStaticButtonOk		= GetDlgItem(hwnd, IDC_STATICOK);
		hWndStaticButtonClose	= GetDlgItem(hwnd, IDC_STATICCLOSE);
		hWndStaticIconExit		= GetDlgItem(hwnd, IDC_STATICICONEXIT);
		hWndStaticIconMinimize	= GetDlgItem(hwnd, IDC_STATICICONMINIMIZE);

		SendMessage(hWndStaticButtonOk, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapOk );		
		SendMessage(hWndStaticButtonClose, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapClose );			
		SendMessage(hWndStaticIconExit, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconExit );	
		SendMessage(hWndStaticIconMinimize, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmapIconMinimize );	

		wpOrigButtonOkProc		= (WNDPROC) SetWindowLong(hWndStaticButtonOk, GWL_WNDPROC, (LONG) NewStaticProc);
		wpOrigButtonCloseProc	= (WNDPROC) SetWindowLong(hWndStaticButtonClose, GWL_WNDPROC, (LONG) NewStaticProc);
		wpOrigIconExitProc		= (WNDPROC) SetWindowLong(hWndStaticIconExit, GWL_WNDPROC, (LONG) NewStaticProc);
		wpOrigIconMinimizeProc	= (WNDPROC) SetWindowLong(hWndStaticIconMinimize, GWL_WNDPROC, (LONG) NewStaticProc);

		// Skin-Init-Beginn
		CSkin skSkin(IDR_SPLASH, IDB_SPLASH);		
		skSkin.Hook(hwnd);		
		skSkin.Enable(true);		

		int iWidth = skSkin.Width();
		int iHeight = skSkin.Height();		
		int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); 
		int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN);
		RECT rc = { (iSw - iWidth)/2, (iSh - iHeight)/2, iWidth, iHeight };		

		global = iWidth;

		ShowWindow(hwnd, SW_SHOW);		 		
	}

	else if (Message==WM_CTLCOLORSTATIC){         
		SetBkMode((HDC)wParam,TRANSPARENT);		
        SetTextColor((HDC)wParam,RGB(255,255,255));		
        return (long)CreateSolidBrush(RGB(73,114,208));		
	}//WM_CTLCOLOREDIT

	else if(Message==WM_COMMAND) {	
		if(wParam == IDC_STATICCLOSE || wParam == IDC_STATICICONEXIT)
			DestroyWindow( hwnd );		
		else if(wParam == IDC_STATICICONMINIMIZE)
			ShowWindow(hwnd,SW_MINIMIZE);
		if(hContext != NULL) {
				ShowWindow(hContext,SW_MINIMIZE);
		}
		else if(wParam == IDC_STATICOK) {
			if(!bContextHandleExists) {				
				bContextHandleExists = true;
				hContext = CreateDialog(hMainInstance, MAKEINTRESOURCE(IDD_CONTEXT), hwnd, ContextDlgProc);					
			}			
		}
	}

	else if(Message==WM_CLOSE) {
		//terminateAll();
		SendMessage(hContext,WM_QUIT,NULL,NULL);
		if(hContext == NULL) {
			MessageBox(NULL,NULL,NULL,NULL);
		}

		DestroyWindow( hwnd );
		return 0;
	}

	else if(Message==WM_DESTROY) {
		PostQuitMessage (0);
		return 0;
	}

	else if(Message==WM_WINDOWPOSCHANGED) {
		if(hContext != NULL) {
			alignRightMenu(hwnd,hContext);
		}
	}

	else{
		return FALSE;
	}

	return TRUE;
}

BOOL CALLBACK SplashDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
	if(Message==WM_INITDIALOG) {	

		// sets the icon of the application displayed 
		// in the upper left corner
		SetClassLong(hwnd, GCL_HICON, (LONG)LoadIcon(hMainInstance, (LPCTSTR)IDI_TEMPLATE));

		SetWindowText(hwnd, APPLICATION_NAME);
		SetTimer(hwnd,1,2000,NULL);

		// Skin-Init-Beginn
		CSkin skSkin(IDR_SPLASH, IDB_SPLASH);		
		skSkin.Hook(hwnd);		
		skSkin.Enable(true);		

		int iWidth = skSkin.Width();
		int iHeight = skSkin.Height();		
		int iSw = (WORD)GetSystemMetrics(SM_CXSCREEN); 
		int iSh = (WORD)GetSystemMetrics(SM_CYSCREEN);
		RECT rc = { (iSw - iWidth)/2, (iSh - iHeight)/2, iWidth, iHeight };		

		ShowWindow(hwnd, SW_SHOW);

        return TRUE;				
	}//WM_INITDIALOG

	else if (Message == WM_TIMER) {
		KillTimer(hwnd,1);

		EndDialog(hwnd,IDD_SPLASH);		
		DialogBox(hMainInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDlgProc);	
	}//WM_TIMER

	else if(Message==WM_COMMAND) {
	}//WM_COMMAND

	else if(Message==WM_CLOSE) {
		EndDialog(hwnd,1);
        return 0;
    }// WM_CLOSE

	else {
		return FALSE;
	}//ELSE

	return TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPSTR lpCmdLine, int nCmdShow) { 
	hMainInstance = hInstance;

	// show splashscreen on startup ?
	DEBUG_LOAD_SPLASH = false;

	if(DEBUG_LOAD_SPLASH) {
		return DialogBox(hInstance, MAKEINTRESOURCE(IDD_SPLASH), NULL, SplashDlgProc);
	}else {		
		return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDlgProc);
	}	
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/752437</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/752437</guid><dc:creator><![CDATA[G.Ben]]></dc:creator><pubDate>Fri, 25 Mar 2005 11:20:39 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Fri, 25 Mar 2005 11:32:45 GMT]]></title><description><![CDATA[<p>In der Skin Klasse wird das Window subclassed.<br />
Möglicherweise ist das der Grund warum der Skin ohne die MSG-Loops nicht<br />
mehr dargestellt werden kann.</p>
<pre><code class="language-cpp">bool CSkin::Hook(HWND hWnd)
{
  // unsubclass any other window
  if (Hooked()) UnHook();

  // this will be our new subclassed window
  m_hWnd = hWnd;

  // set the skin region to the window
  SetWindowRgn(m_hWnd, m_rgnSkin, true);

  // subclass the window procedure
  m_OldWndProc = (WNDPROC)SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG)SkinWndProc);

  // store a pointer to our class instance inside the window procedure.
  if (!SetProp(m_hWnd, &quot;skin&quot;, (void*)this))
  {
    // if we fail to do so, we just can't activate the skin.
    UnHook();
    return false;
  }

  // update flag
  m_bHooked = ( m_OldWndProc ? true : false );

  // force window repainting
  InvalidateRect(m_hWnd, NULL, TRUE);

  // successful return if we're hooked.
  return m_bHooked;
}

// ----------------------------------------------------------------------------
// unhook the window
// ----------------------------------------------------------------------------
bool CSkin::UnHook()
{
  // just to be safe we'll check this
  WNDPROC OurWnd;

  // cannot unsubclass if there is no window subclassed
  if (!Hooked()) return false;

  // remove the skin region from the window
  SetWindowRgn(m_hWnd, NULL, true);

  // unsubclass the window procedure
  OurWnd = (WNDPROC)SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG)m_OldWndProc);

  // remove the pointer to our class instance, but if we fail we don't care.
  RemoveProp(m_hWnd, &quot;skin&quot;);

  // update flag - if we can't get our window procedure address again,
  // we failed to unhook the window.
  m_bHooked = ( OurWnd ? false : true );

  // force window repainting
  InvalidateRect(m_hWnd, NULL, TRUE);

  // successful return if we're unhooked.
  return !m_bHooked;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/752447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/752447</guid><dc:creator><![CDATA[G.Ben]]></dc:creator><pubDate>Fri, 25 Mar 2005 11:32:45 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Fri, 25 Mar 2005 19:27:30 GMT]]></title><description><![CDATA[<pre><code>// subclass the window procedure
m_OldWndProc = (WNDPROC)SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG)SkinWndProc);
</code></pre>
<p>Was ist denn SkinWndProc, wo und wie hast du es definiert? Was passiert denn, wenn du das Skinning mal rauslässt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/752738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/752738</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Fri, 25 Mar 2005 19:27:30 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu GetMessage on Fri, 25 Mar 2005 20:46:39 GMT]]></title><description><![CDATA[<p>So ich paste mal die gesamte Skin-Klasse.<br />
Die ist nicht so lang.</p>
<pre><code>// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//
// WINDOWS SKINNING TUTORIAL - by Vander Nunes - virtware.net
// This is the source-code that shows what is discussed in the tutorial.
// The code is simplified for the sake of clarity, but all the needed
// features for handling skinned windows is present. Please read
// the article for more information.
//
// skin.cpp   : CSkin class implementation
// 28/02/2002 : initial release.
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

#include &quot;skin.h&quot;

// ----------------------------------------------------------------------------
// constructor 1 - use it when you have not already created the app window.
// this one will not subclass automatically, you must call Hook() and Enable()
// to subclass the app window and enable the skin respectively.
// will throw an exception if unable to initialize skin from resource.
// ----------------------------------------------------------------------------

CSkin::CSkin(int iSkinRegion, int iSkinBitmap)
{
  // try to retrieve the skin data from resource.
  if ( !GetSkinData(iSkinRegion, iSkinBitmap) )
    throw (&quot;Unable to retrieve the skin.&quot;);
}

// ----------------------------------------------------------------------------
// constructor 2 - use it when you have already created the app window.
// this one will subclass the window and enable the skin automatically.
// will throw an exception if unable to initialize skin from resource.
// ----------------------------------------------------------------------------
CSkin::CSkin(HWND hWnd, int iSkinRegion, int iSkinBitmap)
{
  // initialize
  CSkin(iSkinRegion, iSkinBitmap);

  // subclass
  Hook(hWnd);

  // enable
  Enable(true);
}

// ----------------------------------------------------------------------------
// destructor - will free allocated resources.
// ----------------------------------------------------------------------------
CSkin::~CSkin()
{
  // unhook the window
  UnHook();

  // free bitmaps and device context
  if (m_dcSkin) { SelectObject(m_dcSkin, m_hOldBmp); DeleteDC(m_dcSkin); }
  if (m_hBmp) DeleteObject(m_hBmp);

  // free skin region
  if (m_rgnSkin) DeleteObject(m_rgnSkin);
}

// ----------------------------------------------------------------------------
// toggle skin on/off - must be Hooked() before attempting to enable skin.
// ----------------------------------------------------------------------------
bool CSkin::Enable(bool bEnable)
{
  // refuse to enable if there is no window subclassed yet.
  if (!Hooked()) return false;

  // toggle
  m_bEnabled = bEnable;

  // force window repainting
  InvalidateRect(m_hWnd, NULL, TRUE);

  return true;
}

// ----------------------------------------------------------------------------
// tell if the skinning is enabled
// ----------------------------------------------------------------------------
bool CSkin::Enabled()
{
  return m_bEnabled;
}

// ----------------------------------------------------------------------------
// hook a window
// ----------------------------------------------------------------------------
bool CSkin::Hook(HWND hWnd)
{
  // unsubclass any other window
  if (Hooked()) UnHook();

  // this will be our new subclassed window
  m_hWnd = hWnd;

  // set the skin region to the window
  SetWindowRgn(m_hWnd, m_rgnSkin, true);

  // subclass the window procedure
  m_OldWndProc = (WNDPROC)SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG)SkinWndProc);

  // store a pointer to our class instance inside the window procedure.
  if (!SetProp(m_hWnd, &quot;skin&quot;, (void*)this))
  {
    // if we fail to do so, we just can't activate the skin.
    UnHook();
    return false;
  }

  // update flag
  m_bHooked = ( m_OldWndProc ? true : false );

  // force window repainting
  InvalidateRect(m_hWnd, NULL, TRUE);

  // successful return if we're hooked.
  return m_bHooked;
}

// ----------------------------------------------------------------------------
// unhook the window
// ----------------------------------------------------------------------------
bool CSkin::UnHook()
{
  // just to be safe we'll check this
  WNDPROC OurWnd;

  // cannot unsubclass if there is no window subclassed
  if (!Hooked()) return false;

  // remove the skin region from the window
  SetWindowRgn(m_hWnd, NULL, true);

  // unsubclass the window procedure
  OurWnd = (WNDPROC)SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG)m_OldWndProc);

  // remove the pointer to our class instance, but if we fail we don't care.
  RemoveProp(m_hWnd, &quot;skin&quot;);

  // update flag - if we can't get our window procedure address again,
  // we failed to unhook the window.
  m_bHooked = ( OurWnd ? false : true );

  // force window repainting
  InvalidateRect(m_hWnd, NULL, TRUE);

  // successful return if we're unhooked.
  return !m_bHooked;
}

// ----------------------------------------------------------------------------
// tell us if there is a window subclassed
// ----------------------------------------------------------------------------
bool CSkin::Hooked()
{
  return m_bHooked;
}

// ----------------------------------------------------------------------------
// return the skin bitmap width
// ----------------------------------------------------------------------------
int CSkin::Width()
{
  return m_iWidth;
}

// ----------------------------------------------------------------------------
// return the skin bitmap height
// ----------------------------------------------------------------------------
int CSkin::Height()
{
  return m_iHeight;
}

// ----------------------------------------------------------------------------
// return the skin device context
// ----------------------------------------------------------------------------
HDC CSkin::HDC()
{
  return m_dcSkin;
}

// ----------------------------------------------------------------------------
// skin retrieval helper
// ----------------------------------------------------------------------------
bool CSkin::GetSkinData(int iSkinRegion, int iSkinBitmap)
{
  // get app instance handle
  HINSTANCE hInstance = GetModuleHandle(NULL);

  // -------------------------------------------------
  // retrieve the skin bitmap from resource.
  // -------------------------------------------------

  m_hBmp = LoadBitmap(hInstance, MAKEINTRESOURCE(iSkinBitmap));
  if (!m_hBmp) return false;

  // get skin info
  BITMAP bmp;
  GetObject(m_hBmp, sizeof(bmp), &amp;bmp);

  // get skin dimensions
  m_iWidth = bmp.bmWidth;
  m_iHeight = bmp.bmHeight;

  // -------------------------------------------------
  // then, we retrieve the skin region from resource.
  // -------------------------------------------------

  // ask resource for our skin.
  HRSRC hrSkin = FindResource(hInstance, MAKEINTRESOURCE(iSkinRegion),&quot;BINARY&quot;);
  if (!hrSkin) return false;

  // this is standard &quot;BINARY&quot; retrieval.
  LPRGNDATA pSkinData = (LPRGNDATA)LoadResource(hInstance, hrSkin);
  if (!pSkinData) return false;

  // create the region using the binary data.
  m_rgnSkin = ExtCreateRegion(NULL, SizeofResource(NULL,hrSkin), pSkinData);

  // free the allocated resource
  FreeResource(pSkinData);

  // check if we have the skin at hand.
  if (!m_rgnSkin) return false;

  // -------------------------------------------------
  // well, things are looking good...
  // as a quick providence, just create and keep
  // a device context for our later blittings.
  // -------------------------------------------------

  // create a context compatible with the user desktop
  m_dcSkin = CreateCompatibleDC(0);
  if (!m_dcSkin) return false;

  // select our bitmap
  m_hOldBmp = (HBITMAP)SelectObject(m_dcSkin, m_hBmp);

  // -------------------------------------------------
  // done
  // -------------------------------------------------
  return true;
}

// ------------------------------------------------------------------------
// Default skin window procedure.
// Here the class will handle WM_PAINT and WM_LBUTTONDOWN, originally sent
// to the application window, but now subclassed. Any other messages will
// just pass through the procedure and reach the original app procedure.
// ------------------------------------------------------------------------
LRESULT CALLBACK SkinWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
  // we will need a pointer to the associated class instance
  // (it was stored in the window before, remember?)
  CSkin *pSkin = (CSkin*)GetProp(hWnd, &quot;skin&quot;);

  // to handle WM_PAINT
	PAINTSTRUCT ps;

  // if we fail to get our class instance, we can't handle anything.
  if (!pSkin) return DefWindowProc(hWnd,uMessage,wParam,lParam);

  switch(uMessage)
  {

    case WM_PAINT:
    {
      // ---------------------------------------------------------
      // here we just need to blit our skin
      // directly to the device context
      // passed by the painting message.
      // ---------------------------------------------------------
      BeginPaint(hWnd,&amp;ps);

      // blit the skin
      BitBlt(ps.hdc,0,0,pSkin-&gt;Width(),pSkin-&gt;Height(),pSkin-&gt;HDC(),0,0,SRCCOPY);

      EndPaint(hWnd,&amp;ps);
      break;
    }

    case WM_LBUTTONDOWN:
    {
      // ---------------------------------------------------------
      // this is a common trick for easy dragging of the window.
      // this message fools windows telling that the user is
      // actually dragging the application caption bar.
      // ---------------------------------------------------------
      SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION,NULL);
      break;
    }

  }

  // ---------------------------------------------------------
  // call the default window procedure to keep things going.
  // ---------------------------------------------------------
  return CallWindowProc(pSkin-&gt;m_OldWndProc, hWnd, uMessage, wParam, lParam);
}
</code></pre>
<p>Diese Klasse lässt sich bequem compilieren und ist meiner Meinung nach sehr schön geschrieben. Ausserdem sehr freundlich vom Author das zur Verfügung zu stellen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Hier is übrigens der Artikel den er zum Thema Skinnig geschrieben hat.<br />
War für mich sehr hilfreich.<br />
[url]<br />
<a href="http://www.flipcode.com/articles/article_win32skins.shtml" rel="nofollow">http://www.flipcode.com/articles/article_win32skins.shtml</a><br />
[/url]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/752775</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/752775</guid><dc:creator><![CDATA[G.Ben]]></dc:creator><pubDate>Fri, 25 Mar 2005 20:46:39 GMT</pubDate></item></channel></rss>