
@++
Code : Tout sélectionner
;///////////////////////////////
; Mesure 1.1 : 27/12/2009 - by Z@ph0d
; PB 4.40
; Modifications MLD le 01/01/2010
;///////////////////////////////
EnableExplicit
Enumeration
#Window_0
EndEnumeration
Enumeration
#Button_0
#text_1
#text_2
#combo_1
#trackbar_0
#checkbox_0
EndEnumeration
Global Largeur = 405
Procedure.i gettpp(f.i)
Protected hdc.i,r.i
;
hdc=GetDC_(GetDesktopWindow_())
If f=0
r= 1440/GetDeviceCaps_(hdc,#LOGPIXELSX)
Else
r= 1440/GetDeviceCaps_(hdc,#LOGPIXELSY)
EndIf
ReleaseDC_(GetDesktopWindow_(),hdc)
;
ProcedureReturn r
EndProcedure
Procedure ruler()
Protected px.i,py.i,i.i,x.i,w.i,f.i
;
UpdateWindow_(WindowID(#window_0))
;
f=GetGadgetState(#combo_1)
Select f
Case 0
w=1440/2.54+1
Case 1
w=1440
EndSelect
;
px= (w/gettpp(0))/10
py= (w/gettpp(1))/10
;
x=0
;
StartDrawing(WindowOutput(#window_0))
DrawingFont(FontID(1))
;
If f<>2
For i=0 To WindowWidth(#window_0)
If i%10=0
Line(x,0,1,10)
DrawText(x-2,12,Str(i/10),#Black,GetWindowColor( #Window_0))
Line(x,WindowHeight(#window_0)-1,1,-10)
DrawText(x-2,WindowHeight(#window_0)-20,Str(i/10),#Black,GetWindowColor( #Window_0))
ElseIf i%5=0
Line (x,0,1,5)
Line(x,WindowHeight(#window_0)-1,1,-5)
Else
Line(x,0,1,2)
Line (x,WindowHeight(#window_0)-1,1,-2)
EndIf
;
x+px
Next
Else
For i=0 To WindowWidth(#window_0)
If i%20=0
Line(x,0,1,10)
DrawText(x-2,12,Str(x),#Black,GetWindowColor( #Window_0))
Line(x,WindowHeight(#window_0)-1,1,-10)
DrawText(x-2,WindowHeight(#window_0)-20,Str(x),#Black,GetWindowColor( #Window_0))
ElseIf i%10=0
Line (x,0,1,5)
Line(x,WindowHeight(#window_0)-1,1,-5)
EndIf
;
x+1
Next
EndIf
;
x=30
If f<>2
For i=0 To WindowHeight(#window_0)
If i%10=0
Line(1,x,10,1)
DrawText(15,x-5,Str(i/10),#Black,GetWindowColor( #Window_0))
Line(WindowWidth(#window_0)-1,x,-10,1)
DrawText(WindowWidth(#window_0)-20,x-5,Str(i/10),#Black,GetWindowColor( #Window_0))
ElseIf i%5=0
Line (1,x,5,1)
Line(WindowWidth(#window_0)-1,x,-5,1)
Else
Line(1,x,2,1)
Line (WindowWidth(#window_0)-1,x,-2,1)
EndIf
;
x+py
If x>WindowHeight(#window_0)-30
Break
EndIf
Next
Else
For i=0 To WindowHeight(#window_0)
If i%20=0
Line(1,x,10,1)
DrawText(15,x-5,Str(x-30),#Black,GetWindowColor( #Window_0))
Line(WindowWidth(#window_0)-1,x,-10,1)
DrawText(WindowWidth(#window_0)-20,x-5,Str(x-30),#Black,GetWindowColor( #Window_0))
ElseIf i%10=0
Line (1,x,5,1)
Line(WindowWidth(#window_0)-1,x,-5,1)
EndIf
;
x+1
If x>WindowHeight(#window_0)-30
Break
EndIf
Next
EndIf
;
StopDrawing()
EndProcedure
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 450, 200, Largeur, 100, "",#PB_Window_BorderLess|#WS_BORDER|#WS_THICKFRAME)
SetWindowColor( #Window_0,$E3DFE0)
StickyWindow(#window_0,1)
;transparence:
SetWindowLong_(WindowID(#window_0), #GWL_EXSTYLE, GetWindowLong_(WindowID(#window_0), #GWL_EXSTYLE) | #WS_EX_LAYERED)
SetLayeredWindowAttributes_(WindowID(#window_0), 0, 200, #LWA_ALPHA)
TextGadget(#Text_1, 30, 30, 70, 20, "Transparence")
TrackBarGadget(#TrackBar_0, 20, 45, 150, 30, 150, 255);, #PB_TrackBar_Ticks)
SetGadgetState(#trackbar_0,230)
ComboBoxGadget(#Combo_1, 190, 40, 70, 20)
AddGadgetItem(#combo_1, -1,"cm")
AddGadgetItem(#combo_1, -1,"inch")
AddGadgetItem(#combo_1, -1,"pixel")
SetGadgetState(#combo_1,2)
ButtonGadget(#Button_0, 280, 55, 50, 20, "Quitter")
CheckBoxGadget(#CheckBox_0, 280, 32, 80, 15, "Second plan")
;
LoadFont(1, "small font", 7,#PB_Font_HighQuality)
;
ruler()
EndIf
EndProcedure
;////////////////////////////////////////
;
OpenWindow_Window_0()
SmartWindowRefresh(#window_0,1)
Repeat
Select WaitWindowEvent()
; ///////////////////
Case #PB_Event_Gadget
Select EventGadget()
Case #Button_0
CloseWindow(#window_0)
Break
Case #trackbar_0
SetLayeredWindowAttributes_(WindowID(#window_0), 0, GetGadgetState(#trackbar_0), #LWA_ALPHA)
Case #combo_1
If EventType()=#CBN_SELCHANGE
InvalidateRect_(WindowID(#Window_0), 0, 1)
ruler()
EndIf
Case #checkbox_0
If GetGadgetState(#checkbox_0)
StickyWindow(#window_0,0)
Else
StickyWindow(#window_0,1)
EndIf
EndSelect
; ////////////////////////
Case #WM_SIZE
InvalidateRect_(WindowID(#Window_0), 0, 1)
ruler()
SetWindowTitle(#window_0,"Règle : W:"+Str(WindowWidth(#window_0))+"/H:"+Str(WindowHeight(#window_0)))
Case #WM_LBUTTONDOWN
SendMessage_(WindowID(#window_0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Window_0
CloseWindow(#Window_0)
Break
EndSelect
EndSelect
ForEver