Fenster mit MFC Alpha Style ?
-
Hallo. Ich habe ein Programm geschrieben. Nun möchte ich das das Dialogfenster zu 90% Transparent ist. Ich finde nirgends einen brauchbaren Code. Hat einer schon mal sowas gemacht ? Oder geht das in MFC gar nicht ?
Danke
-
google: layered windows
WS_EX_LAYERED
-
Danke werde ich mal nach googlen
-
leider finde ich nichts brauchbares für ne mfc.
hat einer nen codeschnipsel für mich ?
wäre super.
-
Wie, Du findest nichts???
http://www.google.de/search?q=mfc+alpha+blend+site%3Acodeproject.com
-
habs schon.
hier der code.
kommt in den oninitdialog
HWND hWnd=this->m_hWnd; typedef DWORD (WINAPI *PSLWA)(HWND, DWORD, BYTE, DWORD); PSLWA pSetLayeredWindowAttributes; HMODULE hDLL = LoadLibrary ("user32"); pSetLayeredWindowAttributes = (PSLWA) GetProcAddress(hDLL,"SetLayeredWindowAttributes"); if (pSetLayeredWindowAttributes != NULL) { SetWindowLong (hWnd, GWL_EXSTYLE, GetWindowLong (hWnd, GWL_EXSTYLE) |WS_EX_LAYERED); } static int factor=220; // 0 - 255 if (pSetLayeredWindowAttributes != NULL) { pSetLayeredWindowAttributes (hWnd, RGB(255,0,0), factor, LWA_COLORKEY|LWA_ALPHA); }
sollte in der FAQ stehen
-
ehm...das geht (from scratch) auch mit 2 zeilen...
SetWindowLong(hWnd, GWL_EXSTYLE, (GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED)); SetLayeredWindowAttributes(hWnd, 0, 255*0.9, LWA_ALPHA);
-
bei mir gings ned. das soll in die oninit ? was noch ? was ist mit hwnd ?
-
also hier die lösung.
dann muss es korrekterweise so aussehen.
denn NUR die 2 zeilen nutzen nichts:#define WS_EX_LAYERED 0x80000 #define LWA_ALPHA 2
HWND hWnd=this->m_hWnd; typedef DWORD (WINAPI *PSLWA)(HWND, DWORD, BYTE, DWORD); PSLWA pSetLayeredWindowAttributes; HMODULE hDLL = LoadLibrary ("user32"); pSetLayeredWindowAttributes = (PSLWA) GetProcAddress(hDLL,"SetLayeredWindowAttributes"); if (pSetLayeredWindowAttributes != NULL) { SetWindowLong (hWnd, GWL_EXSTYLE, (GetWindowLong (hWnd, GWL_EXSTYLE) |WS_EX_LAYERED)); pSetLayeredWindowAttributes (hWnd, 0, 255*0.9, LWA_ALPHA); }
Wenn noch einer weiss wie man es kürzen kann, lasst euch nur aus