Frage zu GetMessage
-
flenders schrieb:
Bei modalen Dialogen hat man gar keine Message-Loop!
Hast du das überlesen bzw. in den Beispielen irgendwo eine Message-Loop gesehen?!
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

-
flenders schrieb:
flenders schrieb:
Bei modalen Dialogen hat man gar keine Message-Loop!
Hast du das überlesen bzw. in den Beispielen irgendwo eine Message-Loop gesehen?!
nur in die 'winmain' muss eine rein.
-
Nein - siehe auch: http://www.winapi.net/index.php?inhalt=tipp2
DialogBox kehrt ja erst zurück, wenn der Dialog wieder geschlossen wird.
-
@flenders: Ich kann nicht begründen warum mir sw-anweisungen nicht gefallen.
Bei mir is eher das gegenteil der fall. Ich finde sie eher unübersichtlich, aber wie gesagt, das ist ansichtsache.Leider bin ich noch nicht weiter mit meinem Problem.
Vielleicht sollte ich versuchen meine Fenster anstelle mir DialogBox mit
CreateWindow zu machen.Hat sonst noch jemand einen Tip wie ich mein kleines MessageProblem lösen kann ?
G.Ben
-
Hat sonst noch jemand einen Tip wie ich mein kleines MessageProblem lösen kann ?
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!
-
Tja, das geht leider nicht.
Da ich ein spezielles Skin-AddOn verwende is es leider nicht so simple.
Sieht man aber auch am Code wenn man hinschaut
z.B.
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(&msg, NULL, 0, 0)) != 0 ) { if (bRet == -1 ) { } else if (!IsWindow(hMain) || !IsDialogMessage(hMain, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } DestroyWindow(hwnd); // Skin-Init-EndeBisher habe ich immer nur einen "geskinten" Dialog gehabt, da war das kein Problem(da ja nur ein MessageLoop vorkam).
Jetzt will ich aber in meiner Anwendung verschiedene Dialog verwenden, mit verschiedenen Skins.
Der AddOn ist dafür wahrscheinlich nicht ausgelegt, aber ich bin sich das es irgendwie geht.
Deshalb versuche ich hier mir Hilfe zu holen.
-
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.S.: Jeder Thread - nicht jedes Fenster!!! - braucht eine Message-Loop.
-
Ich hab natürlich versucht sämtliche MessageLoop rauszumachen und zwar ALLE.
Wie man im Code sieht musste ich dann noch die DestroyWindow entfernen sonst hat sich die Anwendungen bzw. die jeweiligen Dialoge sofort beendet.Wenn ich das App nun starte bekomme ich statt meinen schönen SkinBMPs als Hintergrund nur die Fenster zu sehen aber komplett in Schwarz.
Ich paste nochmal die Version ohne MSG-Loops
mfg
#include "template.h" #include "skin/skin.h" HINSTANCE hMainInstance=NULL; int global = 0; VOID alignRightMenu(HWND hMainWindow, HWND hRightMenu) { RECT r; GetWindowRect(hMainWindow, &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, &r); POINT lp; GetCursorPos(&lp); if(r.left < lp.x && r.right > 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(&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); } }
-
In der Skin Klasse wird das Window subclassed.
Möglicherweise ist das der Grund warum der Skin ohne die MSG-Loops nicht
mehr dargestellt werden kann.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, "skin", (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, "skin"); // 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; }
-
// subclass the window procedure m_OldWndProc = (WNDPROC)SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG)SkinWndProc);Was ist denn SkinWndProc, wo und wie hast du es definiert? Was passiert denn, wenn du das Skinning mal rauslässt?
-
So ich paste mal die gesamte Skin-Klasse.
Die ist nicht so lang.// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // // 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 "skin.h" // ---------------------------------------------------------------------------- // 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 ("Unable to retrieve the skin."); } // ---------------------------------------------------------------------------- // 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, "skin", (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, "skin"); // 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), &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),"BINARY"); if (!hrSkin) return false; // this is standard "BINARY" 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, "skin"); // 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,&ps); // blit the skin BitBlt(ps.hdc,0,0,pSkin->Width(),pSkin->Height(),pSkin->HDC(),0,0,SRCCOPY); EndPaint(hWnd,&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->m_OldWndProc, hWnd, uMessage, wParam, lParam); }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

Hier is übrigens der Artikel den er zum Thema Skinnig geschrieben hat.
War für mich sehr hilfreich.
[url]
http://www.flipcode.com/articles/article_win32skins.shtml
[/url]