J'ai repris un ancien code vieux de 10 ans qui ne fonctionne plus avec PB 5.70 et refait ceci.
Je me sert régulièrement de ce petit outil pratique pour le placement des gadgets.
Code : Tout sélectionner
;///////////////////////////////
; Regle a pixels v2
; PB 5.70 LTS x86
; MLD le 29/03/2019
;///////////////////////////////
;Arrêt par clic droit de la souris sur la règle
;Numérotations éléments
#fen = 1:#Button_stop = 2:#text = 3:#trackbar = 5
Global Largeur = 405
Procedure myCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_CTLCOLORSTATIC
Select lParam
Case GadgetID(5)
SetBkMode_(wParam,#TRANSPARENT)
Result = CreateSolidBrush_($FFFFFF)
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
Procedure Rgl()
Protected i.i,x.i,w.i
UpdateWindow_(WindowID(1))
W = 0:x = 0
StartDrawing(WindowOutput(1))
DrawingFont(FontID(1))
For i=0 To WindowWidth(1)
If i%20 = 0
Line(x,0,1,10,$0000FF);vingtaine haut
DrawText(x-2,12,Str(x),$0,GetWindowColor( 1));chiffres du haut
Line(x,WindowHeight(1)-1,1,-10,$0000FF);vingtaine bas
DrawText(x-2,WindowHeight(1)-20,Str(x),$0,GetWindowColor(1)) ;chiffres du bas
ElseIf i%10 = 0
Line (x,0,1,5,$CD0000);dizaine haut
Line(x,WindowHeight(1)-1,1,-5,$CD0000);dizaine bas
EndIf
x+1
Next
x = 30
For i=0 To WindowHeight(1)
If i%20 = 0
Line(1,x,10,1,$0000FF);vingtaine gauche
DrawText(15,x-5,Str(x-30),$0,$FFFFFF);chiffres gauche
Line(WindowWidth(1)-1,x,-10,1,$0000FF);vingtaine droit
DrawText(WindowWidth(1)-20,x-5,Str(x-30),$0,$FFFFFF);chifres droit
ElseIf i%10 = 0
Line (1,x,5,1,$CD0000);dizaine gauche
Line(WindowWidth(1)-1,x,-5,1,$CD0000);dizaine droit
EndIf
x+1
If x > WindowHeight(1)-30
Break
EndIf
Next
StopDrawing()
EndProcedure
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
OpenWindow(1, 450, 200, Largeur, 100, "",#PB_Window_BorderLess|#WS_THICKFRAME);|#WS_BORDER
SmartWindowRefresh(1,1)
StickyWindow(1,1)
HideWindow(1,0)
SetWindowColor(1,$FFFFFF)
SetWindowLong_(WindowID(1), #GWL_EXSTYLE, GetWindowLong_(WindowID(1), #GWL_EXSTYLE) | #WS_EX_LAYERED);transparence:
SetLayeredWindowAttributes_(WindowID(1), 0,180, #LWA_ALPHA)
TextGadget(3, 50, 30, 70, 20, "Transparence")
SetGadgetColor(3,#PB_Gadget_BackColor,$FFFFFF)
TrackBarGadget(5, 50, 45, 150, 30, 100, 255)
SetGadgetColor(5,#PB_Gadget_BackColor,$FFFFFF)
SetGadgetState(5,180)
SetWindowCallback(@myCallback())
LoadFont(1, "Noto Sans Condensed", 7,#PB_Font_HighQuality)
SetActiveGadget(5):SetActiveGadget(3)
Rgl()
;¤¤¤¤¤¤¤ Boucle générale
Repeat
Event = WaitWindowEvent()
If Event = #WM_RBUTTONDOWN
Delay(250)
CloseWindow(1)
End
EndIf
If Event = #WM_LBUTTONDOWN
SendMessage_(WindowID(1), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
If Event = #PB_Event_SizeWindow;#WM_SIZE
InvalidateRect_(WindowID(1), 0, 1)
Rgl()
EndIf
If Event = #PB_Event_Gadget
Select EventGadget()
Case 5
SetLayeredWindowAttributes_(WindowID(1), 0, GetGadgetState(5), #LWA_ALPHA)
SetActiveGadget(3)
EndSelect
EndIf
ForEver