; **************************************************************************** ; * By PBFrance : http://www.pbfrance.com/?url=source&cmd=viewer&val=74 ; **************************************************************************** ; +======================================================+ ; | ROUTINE DE DEPLACEMENT D'UN GADGET DANS UNE FENÊTRE. | ; +------------------------------------------------------+ ; | COPYRIGHT(C)2007-2015, ALL RIGHT RESERVED KOAKDESIGN | ; +--------------+---------------------------------------+ ; | Program/Vers | PUREBASIC 5.31 | ; +--------------+---------------------------------------+ ; | VER & REV | 0.0.1 | ; +--------------+---------------------------------------+ ; | Program name | | ; +======================================================+ ; +======================================================+ ; | Original Version: 0.0.1 | ; +--------------+---------------------------------------+ ; | Created by | GallyHC | ; | Graphix by | | ; +--------------+---------------------------------------+ ; | Comments: | | ; +--------------+ | ; | | ; | | ; | | ; +======================================================+ ; +======================================================+ ; | Système d'Exploitation | ; +--------------+---------------------------------------+ ; | Window | Oui | ; | Linux | Non | ; | MacOS | Non | ; +======================================================+ ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ DisableASM EnableExplicit ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ Enumeration #window_main #window_button EndEnumeration Enumeration 513 #PB_Event_LeftClickDown #PB_Event_LeftClickUp EndEnumeration ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ Procedure GadgetHoverCheck(x, y, Gadget) ; If IsGadget(Gadget) <> 0 ProcedureReturn Bool(((Not x=(GadgetX(Gadget)+GadgetWidth(Gadget))) And (Not y>=(GadgetY(Gadget)+GadgetHeight(gadget)))) EndIf EndProcedure ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; **************************************************************************** ; +--------------------------------------------------------------------------+ ; | | ; +--------------------------------------------------------------------------+ Define.b cmouse Define.i event, mposx, mposy Define.point calcXY Define hWnd.i = OpenWindow(#window_main, 0, 0, 800, 600, #Null$, #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered) If hWnd <> 0 ButtonGadget (#window_button, 10, 60, 200, 30, "déplacement moi") Repeat event = WaitWindowEvent() mposx = WindowMouseX(#window_main) mposy = WindowMouseY(#window_main) Select event Case #PB_Event_LeftClickDown If GadgetHoverCheck(mposx, mposy, #window_button) cmouse = #True calcXY\x = mposx - GadgetX(#window_button) calcXY\y = mposy - GadgetY(#window_button) EndIf Case #PB_Event_LeftClickUp cmouse = #False EndSelect If cmouse = #True ResizeGadget(#window_button, mposx - calcXY\x, mposy - calcXY\y, #PB_Ignore, #PB_Ignore) EndIf Until event = #PB_Event_CloseWindow EndIf End