PB x86 ;x 64 v4.31
Code: Select all
Global desktop.RECT,wr.RECT,W,H,FrT,hWnd_1,hWnd_2,GiD,Op,FiC,NMsg$,T2S,Quit,Thread
Procedure RoundedBox(X, Y, W, H, R,FrT,FrC,FiC)
;X = Starting x position - Y = Starting y pos. - W = Button Width - H = Button Height - FrT = Frame Thickness - FrC = Frame Color - FiC = Fill Color
Box(X,Y,W,H,GetWindowColor(0)) ;Windows background color in case of Image output
Circle(X+R,Y+R, R,FrC)
Circle(X+R,Y+R, R-FrT,FiC)
Circle(X+W-R,Y+R,R,FrC)
Circle(X+W-R,Y+R,R-FrT,FiC)
Circle(X+R,Y+H-R,R,FrC)
Circle(X+R,Y+H-R,R-FrT,FiC)
Circle(X+W-R,Y+H-R,R,FrC)
Circle(X+W-R,Y+H-R,R-FrT,FiC)
Box(X+R,Y,W-2*R,H,FrC)
Box(X+R,Y+FrT,W-2*R,H-2*FrT,FiC)
Box(X,Y+R,W,H-2*R,FrC)
Box(X+FrT,Y+R,W-2*FrT,H-2*R,FiC)
EndProcedure
Procedure DisGadget(GiD,Op,FiC)
;GiD = GadgetID - Op = Opacity Degree - FiC = Filter Color
GetWindowRect_(GadgetID(GiD), wr.RECT)
hWnd_2 = OpenWindow(5,wr\left ,wr\top, W+2*FrT,H+2*FrT,"test",#WS_POPUP,hWnd_1)
SetWindowColor(5,FiC)
SetWindowLongPtr_(hWnd_2,#GWL_EXSTYLE,#WS_EX_LAYERED)
SetLayeredWindowAttributes_(hWnd_2,0,Op,#LWA_ALPHA)
EndProcedure
Procedure NotifyMsg(*Parameter)
desktop.RECT
OpenWindow(1,(desktop\right-120),(desktop\bottom-20),100,20,"",#PB_Window_BorderLess)
TextGadget(10,0,0,100,20,NMsg$,#SS_CENTERIMAGE | #SS_CENTER| #WS_BORDER)
SetGadgetColor(10,#PB_Gadget_BackColor,$BCFFFF)
SetGadgetColor(10,#PB_Gadget_FrontColor,$0102FE)
SetGadgetFont(10, #PB_Default)
Repeat
Delay(T2S)
CloseWindow(1)
KillThread(Thread)
quit = 1
Until quit = 1
EndProcedure
X = 50
Y = 45
W = 100
H = 40
If H > W
Swap H,W
EndIf
R = 12 ; radius
a$ = "Hello !!!"
FiC=$01FFFE ;Fill Color
FrC=$FD0202 ;Frame Color
FrT=4 ;Frame Thickness
If H < 3*R
R = H/3
EndIf
NMsg$="Test To Go" ;Message
T2S=8000 ;Time for message to stay
quit=0
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @desktop.RECT, 0)
hWnd_1 = OpenWindow(0,0,0,640,480,"Enable \ Disable Gadgets",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowColor(0,$B5D4E6)
CreateImage(0,W,H)
StartDrawing(ImageOutput(0))
RoundedBox(0,0,W,H,R,FrT,FrC,FiC)
DrawingMode(#PB_2DDrawing_Transparent)
;Draw Text need more care (Get text length in pixels and calculate the position exact)
DrawText((W-TextWidth(a$))/2,(H-TextHeight(a$))/2,a$,$FD0202)
StopDrawing()
ButtonImageGadget(0, 20, 20, W+2*FrT,H+2*FrT, ImageID(0))
ButtonGadget(1,20,440,80,25,"Dis\En",#PB_Button_Toggle)
Repeat
SetActiveWindow(0)
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 0
Thread = CreateThread(@NotifyMsg(),23)
Case 1
Flag = Flag!1
If Flag = 1
DisGadget(0,150,$FFFFFF)
Else
CloseWindow(5)
EndIf
EndSelect
Case #PB_Event_CloseWindow
Quit = 2
EndSelect
Until Quit = 2
End