problem with releasemouse + openwindowscreen
Posted: Sat Nov 13, 2004 3:02 pm
hi,
This application opens a window with a graphic screen inside. I thus have a graphic cursor which is trotted with the mouse.
but the mouse hesitates much to return in the graphic screen.
would you have an idea to arrange that?
or a better solution...
thanks
patrick88
This application opens a window with a graphic screen inside. I thus have a graphic cursor which is trotted with the mouse.
but the mouse hesitates much to return in the graphic screen.
would you have an idea to arrange that?
or a better solution...
thanks
patrick88
Code: Select all
;- déclaration constante
#WINDOW_DEPLACED = 161
Enumeration
#WIN_MAIN
#GDT_STATUSBAR
#GDT_STATUSBAR_COORDX
#GDT_STATUSBAR_COORDY
EndEnumeration
;- déclaration structure
Structure STRU_INFO_WINDOW
;relatif à la fenêtre principale
main_x.w
main_y.w
main_width.w
main_height.w
main_flag.l
main_version.s
;relatif à la zone de dessin
draw_x.w
draw_y.w
draw_width.w
draw_height.w
draw_AutoStretch.l
draw_RightOffset.w
draw_BottomOffset.w
draw_TopOffset.w
etat.w
EndStructure
;- déclaration variable
Global INFO_WINMAIN.STRU_INFO_WINDOW
Global a_qui_est_la_souris.b
Procedure initialisation()
;relatif à la fenêtre principale
INFO_WINMAIN\main_x = 50
INFO_WINMAIN\main_y = 50
INFO_WINMAIN\main_width = 600
INFO_WINMAIN\main_height = 350
INFO_WINMAIN\main_flag = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget
INFO_WINMAIN\main_version = "Draw-01-00"
;relatif à la zone de dessin
INFO_WINMAIN\draw_x = 25
INFO_WINMAIN\draw_y = 25
INFO_WINMAIN\draw_RightOffset = 25
INFO_WINMAIN\draw_BottomOffset = 25
INFO_WINMAIN\draw_TopOffset = 4
INFO_WINMAIN\draw_width = INFO_WINMAIN\main_width - INFO_WINMAIN\draw_x-INFO_WINMAIN\draw_RightOffset
INFO_WINMAIN\draw_height = INFO_WINMAIN\main_height - INFO_WINMAIN\draw_y-INFO_WINMAIN\draw_BottomOffset
INFO_WINMAIN\draw_AutoStretch = 1
If InitSprite() = 0 Or InitKeyboard()=0 Or InitMouse() = 0
MessageRequester( "Erreur" , "Impossible d'initialiser DirectX 7 Ou plus" , 0 )
End
ElseIf OpenWindow(#WIN_MAIN,INFO_WINMAIN\main_x,INFO_WINMAIN\main_y,INFO_WINMAIN\main_width,INFO_WINMAIN\main_height,INFO_WINMAIN\main_flag,INFO_WINMAIN\main_version) = 0
MessageRequester( "Erreur", "Impossible d'ouvrir la fenêtre")
End
EndIf
If OpenWindowedScreen( WindowID(#WIN_MAIN), INFO_WINMAIN\draw_x,INFO_WINMAIN\draw_y,INFO_WINMAIN\draw_width,INFO_WINMAIN\draw_height, INFO_WINMAIN\draw_AutoStretch, INFO_WINMAIN\draw_RightOffset, INFO_WINMAIN\draw_BottomOffset ) = 0
MessageRequester( "Erreur" , "Impossible d'ouvrir l'écran " , 0 )
End
EndIf
If CreateStatusBar(#GDT_STATUSBAR, WindowID(#WIN_MAIN))
AddStatusBarField(80)
AddStatusBarField(80)
EndIf
a_qui_est_la_souris=0
INFO_WINMAIN\etat = 0
EndProcedure
initialisation()
Repeat
ClearScreen(255,255,255)
result = ExamineMouse()
If INFO_WINMAIN\etat = 0
INFO_WINMAIN\etat =1
MouseLocate(INFO_WINMAIN\draw_width/2,INFO_WINMAIN\draw_height/2)
EndIf
mx.w = MouseX() : my.w = MouseY()
If StartDrawing(ScreenOutput())
FrontColor(255,0,0)
LineXY(0,my,INFO_WINMAIN\draw_width,my)
LineXY(mx,0,mx,INFO_WINMAIN\draw_height)
StopDrawing()
EndIf
StatusBarText(#GDT_STATUSBAR, 0, "X:"+Str(mx))
StatusBarText(#GDT_STATUSBAR, 1, "Y:"+Str(my))
wmx = WindowMouseX() : wmy = WindowMouseY()
ReleaseMouse(0)
If wmx <= INFO_WINMAIN\draw_x+5 Or wmx >=INFO_WINMAIN\draw_width + INFO_WINMAIN\draw_x Or wmy <= INFO_WINMAIN\draw_y+5 Or wmy >=INFO_WINMAIN\draw_height + INFO_WINMAIN\draw_y
ReleaseMouse(1)
Else
ReleaseMouse(0)
EndIf
;- gestion des évenement windows
Select WindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_LBUTTONDOWN
; If a_qui_est_la_souris = 1
; a_qui_est_la_souris = ReleaseMouse(0)
; INFO_WINMAIN\etat =0
; EndIf
;-Gadgets
Case #PB_Event_Gadget
Select EventGadgetID()
EndSelect
Default
EndSelect
FlipBuffers()
Delay(1)
Until Quit>0
End