PowerBuilder Make The Window Transparent
Source Code
External Function Declaration
1 2 3 | Function Long GetWindowLongA(Long HWND,Long nOffset) Library "user32.dll" Function Long SetWindowLongA(Long HWND,Long nIndex,Long dwNewLong) Library "user32.dll" Function Long SetLayeredWindowAttributes(Long HWND,Long crKey,Long bAlpha,Long dwFlags) Library "user32.dll" |
Instance Variable
1 2 3 4 5 6 7 8 | Constant Long GWL_EXSTYLE = (-20) Constant Long WS_EX_LAYERED = 524288 Constant Long LWA_COLORKEY = 1 Constant Long LWA_ALPHA = 2 Constant Long ULW_COLORKEY = 1 Constant Long ULW_ALPHA = 2 Constant Long ULW_OPAQUE = 4 Long Value |
Script Using
1 2 3 4 5 6 7 | Long HWND, ll_value,rtn HWND = Handle(This) //this window ll_value = 15 //scale rtn = GetWindowLongA(HWND, GWL_EXSTYLE) rtn = WS_EX_LAYERED rtn = SetWindowLonga(HWND, GWL_EXSTYLE, rtn) SetLayeredWindowAttributes(HWND, 0, (255 * ll_value) / 100, LWA_ALPHA) |
Source Example
w_main from window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | forward global type w_main from window end type type st_value from statictext within w_main end type type st_1 from statictext within w_main end type type htb_1 from htrackbar within w_main end type end forward global type w_main from window integer width = 1769 integer height = 604 boolean titlebar = true string title = "Make The Window Transparent" boolean controlmenu = true boolean minbox = true boolean maxbox = true boolean resizable = true long backcolor = 67108864 string icon = "AppIcon!" boolean center = true st_value st_value st_1 st_1 htb_1 htb_1 end type global w_main w_main type prototypes Function Long GetWindowLongA(Long hwnd,Long nOffset) Library "user32.dll" Function Long SetWindowLongA(Long hwnd,Long nIndex,Long dwNewLong) Library "user32.dll" Function Long SetLayeredWindowAttributes(Long hwnd,Long crKey,Long bAlpha,Long dwFlags) Library "user32.dll" end prototypes type variables CONSTANT long GWL_EXSTYLE = (-20) CONSTANT long WS_EX_LAYERED = 524288 CONSTANT long LWA_COLORKEY = 1 CONSTANT long LWA_ALPHA = 2 CONSTANT long ULW_COLORKEY = 1 CONSTANT long ULW_ALPHA = 2 CONSTANT long ULW_OPAQUE = 4 Long Value end variables on w_main.create this.st_value=create st_value this.st_1=create st_1 this.htb_1=create htb_1 this.Control[]={this.st_value,& this.st_1,& this.htb_1} end on on w_main.destroy destroy(this.st_value) destroy(this.st_1) destroy(this.htb_1) end on event open;htb_1.position = 50 st_value.text = string(50) end event type st_value from statictext within w_main integer x = 366 integer y = 96 integer width = 402 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "100" boolean focusrectangle = false end type type st_1 from statictext within w_main integer x = 183 integer y = 96 integer width = 219 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Value:" boolean focusrectangle = false end type type htb_1 from htrackbar within w_main integer x = 146 integer y = 192 integer width = 1426 integer height = 128 integer maxposition = 100 integer tickfrequency = 10 end type event moved;long HWND, ll_value,rtn HWND =handle(parent) ll_value = scrollpos rtn = GetWindowLongA(hWnd, GWL_EXSTYLE) rtn = WS_EX_LAYERED rtn = SetWindowLonga(HWND, GWL_EXSTYLE, rtn) SetLayeredWindowAttributes(HWND, 0, (255 * ll_value) / 100, LWA_ALPHA) st_value.text = string(scrollpos) end event |
Find Projects On Github click here
Good Luck!