Je cherche de l'aide sur ces points :
1-Probleme lorsque la souris est au dessus du bouton
2-Chercher curseur (fleche vers la gauche barre barre fleche vers la droite)
3-ombre de déplacement
Code : Tout sélectionner
cf fin de page
Code : Tout sélectionner
cf fin de page
Code : Tout sélectionner
Global MySplitter_ArrowCursorH, cur1
Global Splitter_Activate
Global SkinButton.l
Procedure MySplitterGadget(Gadget, X, Y, Width, Height)
ButtonGadget(Gadget, X, Y, Width, Height,"", #BS_OWNERDRAW)
MySplitter_ArrowCursorH = LoadCursorFromFile_(@"SPLITH.CUR")
CreateImage(0,Width,Height)
StartDrawing(ImageOutput(0))
Box(0,0,Width ,Height , GetSysColor_(#COLOR_3DSHADOW))
Box(0,0,Width-2,Height-2, GetSysColor_(#COLOR_3DHILIGHT))
Box(2,2,Width-4,Height-4, GetSysColor_(#COLOR_3DFACE))
StopDrawing()
SkinButton = CreatePatternBrush_(ImageID(0))
ProcedureReturn
EndProcedure
Procedure IsMouseOver(wnd)
GetWindowRect_ (wnd,re.RECT)
re\left = re\left
re\top = re\top
re\right = re\right
re\bottom = re\bottom
GetCursorPos_ (pt.POINT)
ProcedureReturn PtInRect_ (re,pt\x,pt\y)
EndProcedure
Procedure ResizeInterface(Window.l, Splitter.l, Gadget1.l, Gadget2.l)
Protected Delta.l
If WindowMouseX(Window) = -1
; hors de la fenetre
If DesktopMouseX() > WindowX(Window) + WindowWidth(Window)
; à droite de la fenetre
Delta = WindowWidth(Window)
ElseIf DesktopMouseX() < WindowX(Window)
; à gauche de la fenetre
Delta = - GadgetX(Splitter)
EndIf
Else
Delta = WindowMouseX(Window) - GadgetX(Splitter)
EndIf
If GadgetWidth(Gadget1) + Delta < 0
Delta = 0 - GadgetWidth(Gadget1)
EndIf
If GadgetWidth(Gadget2) - Delta < 0
Delta = GadgetWidth(Gadget2)
EndIf
ResizeGadget(Gadget1, #PB_Ignore, #PB_Ignore, GadgetWidth(Gadget1) + Delta, #PB_Ignore)
ResizeGadget(Splitter, GadgetX(Splitter) + Delta, #PB_Ignore, #PB_Ignore, #PB_Ignore)
ResizeGadget(Gadget2, GadgetX(Gadget2) + Delta, #PB_Ignore, GadgetWidth(Gadget2) - Delta, #PB_Ignore)
ProcedureReturn
EndProcedure
Procedure WindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
If Splitter_Activate = #True
;SetCursor_(MySplitter_ArrowCursorH)
SetCursor_(cur1)
EndIf
Select Message
Case #WM_MOUSEMOVE
If IsMouseOver(GadgetID(3))
;SetCursor_(MySplitter_ArrowCursorH)
SetCursor_(cur1)
EndIf
Case #WM_PARENTNOTIFY
Select wParam
Case #WM_LBUTTONDOWN
If IsMouseOver(GadgetID(3))
Splitter_Activate = #True
EndIf
EndSelect
Case #WM_DRAWITEM
*dis.DRAWITEMSTRUCT
*dis = lParam
If *dis\itemState & #ODS_CHECKED
FillRect_(*dis\hdc, *dis\rcItem, SkinButton)
ElseIf *dis\itemState & #ODS_SELECTED
FillRect_(*dis\hdc, *dis\rcItem, SkinButton)
Else
FillRect_(*dis\hdc, *dis\rcItem, SkinButton)
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
hWnd=OpenWindow(0,200,200,240,190,"SplitterGadget Example",#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
ListViewGadget(0, 005, 005, 110, 180)
ListViewGadget(1, 125, 005, 110, 180)
Splitt=MySplitterGadget(3, 116, 010, 008, 170)
SetClassLong_(Splitt,#GCL_HCURSOR,0)
cur1 = LoadCursor_(0, #IDC_SIZEWE); curseur d'élargissement
MySplitter_ArrowCursorH = cur1
For k=0 To 10
AddGadgetItem(0, -1, "0 - " + Str(k))
AddGadgetItem(1, -1, "1 - " + Str(k))
Next
SetWindowCallback(@WindowCallback())
Repeat
Event = WaitWindowEvent()
Select Event
Case #WM_LBUTTONUP
If Splitter_Activate = #True
Splitter_Activate = #False
ResizeInterface(0, 3, 0, 1)
EndIf
EndSelect
Until Event = #PB_Event_CloseWindow
DestroyCursor_(cur1)
End
Global OriginProc,test.b,a.l,b.l,hbruh
Procedure NouvelleProc( hWnd, msg, wParam, lParam)
Select msg
Case 512 ;déplacement
If test=1
a=wParam
b=lParam
GetCursorPos_ (@point.POINT)
GetWindowRect_ (hWnd,@rect.RECT)
If point\y>=rect\top And point\y<=rect\bottom
SetWindowPos_ ( WindowID (1),0,rect\left,point\y-1,rect\right-rect\left,3, #SWP_NOSIZE | #SWP_NOACTIVATE )
EndIf
ProcedureReturn 0
EndIf
Case 513 ;appuyé
test=1
OpenWindow (1, 0, 0, 100, 100, "SplitterGadget" , #PB_Window_BorderLess|#PB_Window_Invisible )
hbruh= CreateSolidBrush_ ( RGB (0,0,255))
SetClassLong_ ( WindowID (1), #GCL_HBRBACKGROUND , hbruh)
InvalidateRect_ ( WindowID (1),0,1)
GetWindowRect_ (hWnd,@rect.RECT)
GetCursorPos_ (@point.POINT)
SetWindowPos_ ( WindowID (1),0,rect\left,point\y-1,rect\right-rect\left,3, #SWP_NOACTIVATE| #SWP_SHOWWINDOW )
Case 514 ;relaché
test=0
DestroyWindow_ ( WindowID (1))
DeleteObject_ (hbruh)
SendMessage_ (hWnd, 512,a,b)
EndSelect
ProcedureReturn CallWindowProc_ (OriginProc,hWnd,msg,wParam,lParam)
EndProcedure
If OpenWindow (0, 0, 0, 230, 210, "SplitterGadget" , #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
If CreateGadgetList ( WindowID (0))
#Bouton1 = 0
#Bouton2 = 1
#Separateur = 2
ButtonGadget ( #Bouton1 , 0, 0, 0, 0, "Bouton 1" )
ButtonGadget ( #Bouton2 , 0, 0, 0, 0, "Bouton 2" )
SplitterGadget ( #Separateur , 5, 5, 220, 120, #Bouton1 , #Bouton2 , #PB_Splitter_Separator )
OriginProc = SetWindowLong_ ( GadgetID ( #Separateur ), #GWL_WNDPROC , @NouvelleProc())
SetProp_ ( GadgetID ( #Separateur ), "OriginProc" , OriginProc)
TextGadget (3, 10, 135, 210, 70, "Le composant d'interface graphique ci-dessus affiche deux boutons automatiquement redimensionnés à l'intérieur de la zone séparée de taille 220x120." , #PB_Text_Center )
Repeat
Until WaitWindowEvent () = #PB_Event_CloseWindow
EndIf
EndIf
Code : Tout sélectionner
cf fin de page
Code : Tout sélectionner
Procedure IsMouseOver(wnd)
GetWindowRect_ (wnd,re.RECT)
re\left = re\left ; les 4 lignes là ne servent à rien !!!!!
re\top = re\top
re\right = re\right
re\bottom = re\bottom
GetCursorPos_ (pt.POINT)
ProcedureReturn PtInRect_ (re,pt\x,pt\y)
EndProcedure
Non non mes bretelles vont bienPar contre y'a un pb dans ton code (qq1 qui te l'as piqué c'est fait remonté les bretelles par Dridi dans un autre topic)
Code : Tout sélectionner
; German forum: http://robsite.de/php/pureboard/viewtopic.php?t=895&highlight=
; [b]Author: Andreas
; Date: 05. May 2003 [/b]
; purebasic 4.00
Global Button.l
Procedure IsMouseOver(wnd)
GetWindowRect_ (wnd,re.RECT)
re\left = re\left
re\top = re\top
re\right = re\right
re\bottom = re\bottom
GetCursorPos_ (pt.POINT)
Result = PtInRect_ (re,pt\X,pt\Y)
ProcedureReturn Result
EndProcedure