Прозрачность окон в Windows
Многие интересуются как сделать прозрачным какое-либо окно.
Если поискать в Интернете, почитать MSDN, справочники по WinApi, то окажется, что это вовсе не сложно (сложнее будет написать это на PureBasic'e;)) Вот что у меня получилось: Код:
OpenWindow(0,50,50,200,200,"Prof. BiG BanG") |
Re: Прозрачность окон в Windows
А на сколько прозрачное будет? Есть возможность частично?
|
Re: Прозрачность окон в Windows
Цитата:
Код:
SetLayeredWindowAttributes_(aw,0,i,#LWA_ALPHA) Можно устанавливать промежуточные значения. В моём примере прозрачность меняется (i меняется от 0 до 255) |
Re: Прозрачность окон в Windows
Prof. BiG BanG, оу, благодарю.
|
Re: Прозрачность окон в Windows
Вот код, который и окошко прозрачным делает и еще регион окна меняет:
Global hWnd Global transparent Global Wait TWait=5000 Global Start Structure aPOINT x.l y.l EndStructure Structure bPOINT aPOLYGON.aPOINT[10] EndStructure bPOLYGON.bPOINT For k = 0 To 9 With bPOLYGON\aPOLYGON[k] \x = Random(100) \y = Random(100) EndWith Next Procedure MyWindowCallback(WindowId, Message, wParam, lParam) Result = #PB_ProcessPureBasicEvents Select WindowId Case 0 Default Select Message ;Case #WM_NCHITTEST ; Result=#HTCAPTION Case #WM_TIMER Result=0 Select wParam Case 1 ; fade in If transparent<255 transparent +1 ElseIf transparent=255 KillTimer_(hWnd,1) ; stop, fade in ready SetTimer_(hWnd,2,TWait,0) ; set pause EndIf SetLayeredWindowAttributes_(hWnd,0,transparent,2) ; Case 2 ; pause ready KillTimer_(hWnd,2) SetTimer_(hWnd,3,3,0) ; set fade out Case 3 ; fade out If transparent>0 transparent -1 ElseIf transparent=0 KillTimer_(hWnd,3) Start=1 ; start main app EndIf SetLayeredWindowAttributes_(hWnd,0,transparent,2) ; EndSelect EndSelect EndSelect ProcedureReturn Result EndProcedure hWnd= OpenWindow(2, 1,1, 291, 155, "",#PB_Window_BorderLess | #PB_Window_Invisible | #WS_POPUP ) SetWindowPos_(hWnd,#HWND_TOPMOST,(GetSystemMetrics _(#SM_CXSCREEN)/2)-(WindowWidth(2)/2),(GetSystemMetrics_(#SM_CYSCREEN)/2)-(WindowHeight(2)/2),291,155, 0 ) If hWnd SetWindowLong_(hWnd,#GWL_EXSTYLE,$00080000|#WS_EX_ PALETTEWINDOW) SetLayeredWindowAttributes_(hWnd,0,0,2) ;completely transparent h = CreatePolygonRgn_(bPOLYGON, 10, #ALTERNATE) If CatchImage(0, ?Logo) If CreateGadgetList(WindowID(2)) SetWindowRgn_(hWnd, h, True) ImageGadget(0, 0, 0, 0, 0, ImageID(0)) SetWindowLong_(GadgetID(0),#WS_BORDER,0) HideWindow(2,0) SetWindowCallback(@MyWindowCallback()) SetTimer_(hWnd,1,3,0) Repeat WaitWindowEvent() Until Start=1 ; wait until splashwindow finished CloseWindow(2) hWnd= OpenWindow(1, 200, 200, 673, 155 ,"PB App",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget) Repeat Until WaitWindowEvent()=#PB_Event_CloseWindow EndIf EndIf EndIf Писал быстро. Извиняйте за некрасивость :) Тут случайным образом генерируются точки региона окна. Указав точки, вместо их генерирования можно делать окошки самых разных форм. ПОЛИГОНАЛЬНЫЙ регион рисуется, заполняя эти точки. Если хотим нарисовать отдельные друг от друга регионы - то создаем каждый, а потом int CombineRgn( HRGN hrgnDest, // handle to destination region HRGN hrgnSrc1, // handle to source region HRGN hrgnSrc2, // handle to source region int fnCombineMode // region combining mode ); Parameters hrgnDest Identifies a new region with dimensions defined by combining two other regions. (This region must exist before CombineRgn is called.) hrgnSrc1 Identifies the first of two regions to be combined. hrgnSrc2 Identifies the second of two regions to be combined. fnCombineMode Specifies a mode indicating how the two regions will be combined. This parameter can be one of the following values: Value Description RGN_AND Creates the intersection of the two combined regions. RGN_COPY Creates a copy of the region identified by hrgnSrc1. RGN_DIFF Combines the parts of hrgnSrc1 that are not part of hrgnSrc2. RGN_OR Creates the union of two combined regions. RGN_XOR Creates the union of two combined regions except for any overlapping areas это - выписка из Микрософтовского АПИ-шного справочника. |
Часовой пояс GMT +4, время: 16:42. |
vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot