Re: [問題] 視窗化程式設定

看板C_and_CPP作者 (不知名的人物)時間12年前 (2012/01/05 20:44), 編輯推噓2(205)
留言7則, 3人參與, 最新討論串2/3 (看更多)
※ 引述《ddv70 (大David為)》之銘言: : 我是使用vc2010 : include windows.h : 之前co了一段sample code 但是結果視窗卻很小 : cvNamedWindow("status", 0); // test : Window = (HWND) cvGetWindowHandle("status"); : Window = GetParent(Window) ; : style = GetWindowLong( Window, GWL_EXSTYLE); : style = style | WS_EX_LAYERED; : SetWindowLong( Window, GWL_EXSTYLE, style); : SetLayeredWindowAttributes(Window, RGB(255,255,255), 0, LWA_COLORKEY); : style = GetWindowLong(Window, GWL_STYLE); : style = GetWindowLong(Window, WS_MAXIMIZE); : style = style & (~WS_CAPTION) & ~(WS_BORDER) & ~WS_THICKFRAME & WS_MAXIMIZE; : SetWindowLong( Window,GWL_STYLE, style); : 請問要怎麼設定成全螢幕大小且底色為透明之程式??? : 萬分感謝大家解答 首先,創造視窗前 要先知道你電腦螢幕解析度 Win32API 有個function GetSystemMetrics 可以取得螢墓解析度 範例: int x=GetSystemMetrics(SM_CXSCREEN); //取得寬度 int y =GetSystemMetrics(SM_CYSCREEN); //取得高度 附上msdn連結 http://ppt.cc/3zQL 而 CreateWindow 的style 設定成 WS_EX_TOPMOST | WS_POPUP 視窗寬高 則設定剛取得的x,和y 視窗位置則設0 ,0 即可 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.129.38.44 ※ 編輯: sand1050 來自: 140.129.38.44 (01/05 20:45)

01/05 21:34, , 1F
非常感謝你的回答!我試過這個方法了但要怎麼樣才能使得視窗
01/05 21:34, 1F

01/05 21:34, , 2F
呈現透明化呢或者說底色為透明,我現在執行都是灰色的
01/05 21:34, 2F

01/05 21:35, , 3F
另外想請教有推薦的書可以參考嗎
01/05 21:35, 3F

01/05 21:37, , 4F
你原文裡面不有提到了嗎? SetLayeredWindowAttributes
01/05 21:37, 4F

01/05 21:51, , 5F
但是執行底色依然是灰色耶!?
01/05 21:51, 5F

01/05 21:57, , 6F
(HBRUSH)GetStockObject(WHITE_BRUSH);
01/05 21:57, 6F

01/05 21:59, , 7F
WNDCLASSEX 成員 hbrBackground 設定成上面那個
01/05 21:59, 7F
文章代碼(AID): #1F1PiPxB (C_and_CPP)
文章代碼(AID): #1F1PiPxB (C_and_CPP)