Merci beaucoup Dobro !
Au moment ou j'ai reçu un email m'informant d'une reponse j'ai trouvé une solution.Mais la tienne me parait plus simple, côté compatibilité la mienne doit aussi marché sur Linux. Voici mon code (pour la gloire)
Mais je vais sans doute utiliser le code de Dobro
Code : Tout sélectionner
Procedure WindowMouseButton(Wnd, ButtonNr)
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
;Linux Version
Protected gdkWnd.l, x.l, y.l, mask.l
If Wnd
*Window.GTKWindow = Wnd
gdkWnd = *Window\bin\child\window
gdk_window_get_pointer_(gdkWnd, @x, @y, @mask)
Select ButtonNr
Case 0
If (mask & #GDK_BUTTON1_MASK)
ProcedureReturn 1
EndIf
Case 1
If (mask & #GDK_BUTTON3_MASK)
ProcedureReturn 1
EndIf
Case 2
If (mask & #GDK_BUTTON2_MASK)
ProcedureReturn 1
EndIf
EndSelect
EndIf
CompilerElse
;Windows Version
If Wnd And GetForegroundWindow_() = Wnd
Select ButtonNr
Case 0
If GetAsyncKeyState_(#VK_LBUTTON) > 0
ProcedureReturn 1
EndIf
Case 1
If GetAsyncKeyState_(#VK_RBUTTON) > 0
ProcedureReturn 1
EndIf
Case 2
If GetAsyncKeyState_(#VK_MBUTTON) > 0
ProcedureReturn 1
EndIf
EndSelect
EndIf
CompilerEndIf
ProcedureReturn 0
EndProcedure
CreateImage(0,100,100)
If OpenWindow(0, 100, 200, 195, 260, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
CreateGadgetList(WindowID(0))
ImageGadget(1, 20, 20, 100, 100, ImageID(0), #PB_Image_Border)
Repeat
EventID = WaitWindowEvent()
If EventGadget()=1 And WindowMouseButton(WindowID(0), 0);EventType()=#PB_EventType_LeftClick
StartDrawing(ImageOutput(0))
Circle(WindowMouseX(0)-GadgetX(1),WindowMouseY(0)-GadgetY(1),5,#Red)
StopDrawing()
SetGadgetState(1,ImageID(0))
EndIf
If EventID = #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = 1
EndIf
Until Quit = 1
EndIf
End ; All the opened windows are closed automatically by PureBasic