我使用DWM創建了一個自定義窗口。我使用PaintCustomCaption()
來繪製標題,這是MSDN的一個例子。它工作正常,直到我加入SetLayeredWindowAttributes()
。加入SetLayeredWindowAttributes和BitBlt之間的C++ WinAPI衝突
SetLayeredWindowAttributes(hWnd,RGB(0,0,1),0,LWA_COLORKEY);
加入
前後
窗口,我試着改變RGB值,但它仍然是黑色的,除了RGB(0,0,0)。
不知道BitBlt()
是否正常工作。
編輯:
我加入SetLayeredWindowAttributes的原因是爲了解決這個問題
你有其他的方法來畫的標題嗎?
case WM_ACTIVATE: {
DwmExtendFrameIntoClientArea(hWnd,&m); // m={-1,-1,-1,-1};
break;
}
case WM_INITDIALOG: {
SetWindowPos(hWnd,NULL,0,0,500,500,SWP_NOMOVE|SWP_FRAMECHANGED);
SetWindowLongPtr(hWnd,GWL_STYLE,WS_VISIBLE|WS_OVERLAPPEDWINDOW);
SetWindowLongPtr(hWnd,GWL_EXSTYLE,WS_EX_LAYERED);
SetLayeredWindowAttributes(hWnd,RGB(0,0,1),0,LWA_COLORKEY);
RedrawWindow(hWnd,NULL,NULL,RDW_INVALIDATE|RDW_ERASE);
return true;
}
case WM_PAINT: {
hdc=BeginPaint(hWnd,&paintstruct);
PaintCustomCaption(hWnd,hdc)
EndPaint(hWnd,&paintstruct);
break;
}
是的,'BitBlt'「正常工作」。你的代碼中有一個錯誤。 –
是否有任何可能的原因導致錯誤? –
你是否考慮過這個備註:'請注意,一旦SetLayeredWindowAttributes被調用了一個分層窗口,後續的UpdateLayeredWindow調用將會失敗,直到分層樣式位被清除並再次設置。 – KuramaYoko