Code : Tout sélectionner
; Auteur : Cederavic
; Version PB : 3.93
; Date : 13/03/05
; Description : Cache la fenetre en dehors de l'ecran apres un certain temps en laissant une partie sur l'ecran pour la réafficher
; Merci comtois pour TexteVertical()
Declare TexteVertical(texte$,x,y)
Declare GetLoWord(param)
Declare GetHiWord(param)
Declare MakeTitleBar()
#BS_FLAT = $8000
LoadFont(0, "Verdana", 10, #PB_Font_HighQuality)
LoadFont(1, "Verdana", 10, #PB_Font_HighQuality | #PB_Font_Bold)
OpenWindow(0, 0, 0, 300, 400, #PB_Window_BorderLess, "")
SetWindowLong_(WindowID(),#GWL_EXSTYLE,#WS_EX_TOOLWINDOW)
SetWindowPos_(WindowID(), #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE)
CreateGadgetList(WindowID())
ButtonGadget(0, WindowWidth() - 18, WindowHeight() - 18, 16, 16, "X", #BS_FLAT)
SetGadgetFont(0, UseFont(0))
ButtonGadget(1, WindowWidth() - 18, WindowHeight() - 38, 16, 16, "<", #PB_Button_Toggle | #BS_FLAT)
SetGadgetFont(1, UseFont(0))
AutoHide = 1
AutoHide_Timer1 = GetTickCount_()
ShowTime = 3000
ShowSize = 20
Cursor.point
MakeTitleBar()
ExamineDesktops()
Repeat
OldcX = Cursor\x
OldcY = Cursor\y
GetCursorPos_(@Cursor)
wfp = WindowFromPoint_(cursor\x, cursor\y)
If wfp = WindowID() Or wfp = GadgetID(0) Or wfp = GadgetID(1)
If AutoHide = 2 Or AutoHide = 3
MoveWindow(0, WindowY())
SetFocus_(WindowID())
ActivateWindow()
EndIf
AutoHide = 0
AutoHide_Timer1 = GetTickCount_()
AutoHide_Timer2 = 0
Else
If AutoHide = 0 And GetGadgetState(1) = 0
AutoHide = 1
EndIf
EndIf
If AutoHide = 1
AutoHide_Timer2 = GetTickCount_() - AutoHide_Timer1
EndIf
If AutoHide_Timer2 >= ShowTime And AutoHide = 1
AutoHide = 2
EndIf
If AutoHide = 2
MoveWindow(WindowX() - (WindowWidth() / 60), WindowY())
EndIf
If WindowX() <= -WindowWidth() + ShowSize
MoveWindow(-WindowWidth() + ShowSize, WindowY())
AutoHide = 3
EndIf
If Moving = #True
ny = Cursor\y - MovingY
If ny < 0 : ny = 0 : EndIf
If ny > DesktopHeight(0) - WindowHeight() : ny = DesktopHeight(0) - WindowHeight() : EndIf
MoveWindow(0, ny)
EndIf
If Cursor\x >= WindowWidth() - 4 And Cursor\x <= WindowWidth() And Moving = #False
SetClassLong_(WindowID(), #GCL_HCURSOR, LoadCursor_(0, #IDC_SIZEWE))
CanSizeX = #True
ElseIf Cursor\y >= WindowY() + WindowHeight() - 4 And Cursor\y <= WindowY() + WindowHeight()
SetClassLong_(WindowID(), #GCL_HCURSOR, LoadCursor_(0, #IDC_SIZENS))
CanSizeY = #True
Else
If Moving = #False
CanSizeX = #False
SetClassLong_(WindowID(), #GCL_HCURSOR, LoadCursor_(0, #IDC_ARROW))
EndIf
EndIf
If SizingX = #True And Cursor\x <> OldcX
nw = WindowWidth() + (Cursor\x - OldcX)
If nw < 60 : nw = 60 : EndIf
ResizeWindow(nw, WindowHeight())
ResizeGadget(0, WindowWidth() - 18, WindowHeight() - 18, 16, 16)
ResizeGadget(1, WindowWidth() - 18, WindowHeight() - 38, 16, 16)
StartDrawing(WindowOutput())
Box(0, 0, WindowWidth(), WindowHeight(), #White)
StopDrawing()
UpdateWindow_(WindowID())
EndIf
If SizingY = #True And Cursor\y <> OldcY
nh = WindowHeight() + (Cursor\y - OldcY)
If nh < 60 : nh = 60 : EndIf
ResizeWindow(WindowWidth(), nh)
ResizeGadget(0, WindowWidth() - 18, WindowHeight() - 18, 16, 16)
ResizeGadget(1, WindowWidth() - 18, WindowHeight() - 38, 16, 16)
StartDrawing(WindowOutput())
Box(0, 0, WindowWidth(), WindowHeight(), #White)
StopDrawing()
MakeTitleBar()
UpdateWindow_(WindowID())
EndIf
Select WindowEvent()
Case #WM_CLOSE
End
Case #PB_Event_Gadget
Select EventGadgetID()
Case 0
Quit = 1
Case 1
If GetGadgetState(1) = 0
SetGadgetText(1, "<")
Else
SetGadgetText(1, ">")
EndIf
EndSelect
Case #WM_LButtonDown
If wfp = WindowID()
MovingX = GetLoWord(EventlParam())
MovingY = GetHIWord(EventlParam())
If MovingX >= WindowWidth() - ShowSize And MovingX <= WindowWidth() - 4 And MovingY >= 0 And MovingY <= WindowHeight() - 40
SetClassLong_(WindowID(), #GCL_HCURSOR, LoadCursor_(0, #IDC_SIZEALL))
Moving = #True
ElseIf CanSizeX = #True
SetClassLong_(WindowID(), #GCL_HCURSOR, LoadCursor_(0, #IDC_SIZEWE))
SizingX = #True
ElseIf CanSizeY = #True
SetClassLong_(WindowID(), #GCL_HCURSOR, LoadCursor_(0, #IDC_SIZENS))
SizingY = #True
EndIf
EndIf
Case #WM_LButtonUp
SetClassLong_(WindowID(), #GCL_HCURSOR, LoadCursor_(0, #IDC_ARROW))
Moving = #False
SizingX = #False
SizingY = #False
EndSelect
StartDrawing(WindowOutput())
DrawImage(UseImage(0), WindowWidth() - ShowSize, 0)
DrawingMode(4)
Box(0, 0, WindowWidth(), WindowHeight(), RGB(32, 32, 32))
Box(0, 0, WindowWidth() - ShowSize, WindowHeight(), RGB(32, 32, 32))
For y = 0 To WindowHeight() Step 4
If GetGadgetState(1) = 0
LineXY(0, y, WindowWidth() - ShowSize - 1, y, RGB(32, 32, 255))
Else
LineXY(0, y, WindowWidth() - ShowSize - 1, y, RGB(255, 32, 32))
EndIf
Next
StopDrawing()
Until Quit = 1
End
Procedure MakeTitleBar()
CreateImage(0, 19, WindowHeight() - 40)
StartDrawing(ImageOutput())
For y = 0 To WindowHeight() - 40
rs.f = (255 - 60) / (WindowHeight() - 40)
gs.f = (255 - 100) / (WindowHeight() - 40)
bs.f = (255 - 140) / (WindowHeight() - 40)
r = 60 + y * rs
g = 100 + y * gs
b = 140 + y * bs
If r > 255 : r = 255 : EndIf
If g > 255 : g = 255 : EndIf
If b > 255 : b = 255 : EndIf
LineXY(0, y, 19, y, RGB(r, g, b))
Next
TexteVertical("Auto Hide", 9, 6)
StopDrawing()
EndProcedure
Procedure TexteVertical(texte$, x, y)
X1 = x - 1
Y1 = y - 1
dy = 15
DrawingFont(UseFont(1))
DrawingMode(1)
For i = 0 To Len(texte$)-1
FrontColor(164, 164, 164)
Caractere$ = Mid(texte$, i + 1, 1)
CentreX = x - TextLength(Caractere$) / 2
Locate(CentreX, y + i * dy)
DrawText(Caractere$)
FrontColor(64, 64, 64)
CentreX - 1
Locate(CentreX, Y1 + i * dy)
DrawText(Caractere$)
Next
EndProcedure
Procedure GetLoWord(param)
ProcedureReturn param & $ffff
EndProcedure
Procedure GetHiWord(param)
ProcedureReturn param >> 16
EndProcedure