Text is not displayed in string gadget
Posted: Mon Jan 03, 2005 1:07 pm
Hello NG,
I got a problem that drives me nuts, I have two String Gadgets which should display the Screen Coordinates of the Mouse and if the Left Mouse Button is down.
Here is the Code
Declare.l GetMouseX()
Declare.l GetMouseY()
Declare.s LeftMouseButtonState()
#WindowID = 0
#cmd_Starten = 1
#cmd_Beenden = 2
#lbl_Ausgabe = 3
#lbl_MouseState = 4
quit.l = 0
lngEventID.l
str_XPos.s
str_YPos.s
str_Ausgabe.s
lng_Run.l = 0
bMouseState.b = 0
str_MouseState.s
If OpenWindow(#WindowID, 0, 0, 200, 150, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "ScreenCapture")
If CreateGadgetList(WindowID())
ButtonGadget(#cmd_Starten, 5, 5, 190, 20, "Starten")
ButtonGadget(#cmd_Beenden, 5, 30, 190, 20, "Beenden")
StringGadget(#lbl_Ausgabe, 5, 55, 190, 20, "")
StringGadget(#lbl_MouseState, 5, 80, 190, 20, "")
EndIf
EndIf
Repeat
lngEventID = WaitWindowEvent()
If lngEventID = #PB_Event_Gadget
Select EventGadgetID()
Case #cmd_Starten
lng_Run = 1
Case #cmd_Beenden
lng_Run = 0
EndSelect
EndIf
If lng_Run <> 0
lng_XPos = GetMouseX()
lng_YPos = GetMouseY()
str_Ausgabe = "X-Pos: " + Str(lng_XPos) + " Y-Pos: " + Str(lng_YPos)
SetGadgetText(#lbl_Ausgabe, str_Ausgabe)
str_MouseState = LeftMouseButtonState()
If Len(str_MouseState) > 0
SetGadgetText(#lbl_MouseState, str_MouseState)
Else
SetGadgetText(#lbl_MouseState, "empty")
EndIf
Delay(1)
EndIf
If lngEventID = #PB_Event_CloseWindow
quit = 1
SetGadgetText(#lbl_Ausgabe, "")
SetGadgetText(#lbl_MouseState, "")
EndIf
Until quit = 1
Procedure.l GetMouseX()
lngCheck.l = 0
pointStruct.POINT
lngCheck = GetCursorPos_(@pointStruct)
If lngCheck <> 0
ProcedureReturn pointStruct\x
EndIf
EndProcedure
Procedure.l GetMouseY()
lngCheck.l = 0
pointStruct.POINT
lngCheck = GetCursorPos_(@pointStruct)
If lngCheck <> 0
ProcedureReturn pointStruct\y
EndIf
EndProcedure
Procedure.s LeftMouseButtonState()
lngState.l
str_Message.s
VK_LBUTTON.l = 1
lngState = getasynckeystate_(VK_LBUTTON)
If lngState = 0
str_Message = "Mouse up"
Else
str_Message = "Mouse down"
EndIf
ProcedureReturn str_Message
EndProcedure
When I run the code i got no display of the Mouse Down Status. I'm absolutely desperated. PLEASE HELP.
Thanks in Advance
I got a problem that drives me nuts, I have two String Gadgets which should display the Screen Coordinates of the Mouse and if the Left Mouse Button is down.
Here is the Code
Declare.l GetMouseX()
Declare.l GetMouseY()
Declare.s LeftMouseButtonState()
#WindowID = 0
#cmd_Starten = 1
#cmd_Beenden = 2
#lbl_Ausgabe = 3
#lbl_MouseState = 4
quit.l = 0
lngEventID.l
str_XPos.s
str_YPos.s
str_Ausgabe.s
lng_Run.l = 0
bMouseState.b = 0
str_MouseState.s
If OpenWindow(#WindowID, 0, 0, 200, 150, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "ScreenCapture")
If CreateGadgetList(WindowID())
ButtonGadget(#cmd_Starten, 5, 5, 190, 20, "Starten")
ButtonGadget(#cmd_Beenden, 5, 30, 190, 20, "Beenden")
StringGadget(#lbl_Ausgabe, 5, 55, 190, 20, "")
StringGadget(#lbl_MouseState, 5, 80, 190, 20, "")
EndIf
EndIf
Repeat
lngEventID = WaitWindowEvent()
If lngEventID = #PB_Event_Gadget
Select EventGadgetID()
Case #cmd_Starten
lng_Run = 1
Case #cmd_Beenden
lng_Run = 0
EndSelect
EndIf
If lng_Run <> 0
lng_XPos = GetMouseX()
lng_YPos = GetMouseY()
str_Ausgabe = "X-Pos: " + Str(lng_XPos) + " Y-Pos: " + Str(lng_YPos)
SetGadgetText(#lbl_Ausgabe, str_Ausgabe)
str_MouseState = LeftMouseButtonState()
If Len(str_MouseState) > 0
SetGadgetText(#lbl_MouseState, str_MouseState)
Else
SetGadgetText(#lbl_MouseState, "empty")
EndIf
Delay(1)
EndIf
If lngEventID = #PB_Event_CloseWindow
quit = 1
SetGadgetText(#lbl_Ausgabe, "")
SetGadgetText(#lbl_MouseState, "")
EndIf
Until quit = 1
Procedure.l GetMouseX()
lngCheck.l = 0
pointStruct.POINT
lngCheck = GetCursorPos_(@pointStruct)
If lngCheck <> 0
ProcedureReturn pointStruct\x
EndIf
EndProcedure
Procedure.l GetMouseY()
lngCheck.l = 0
pointStruct.POINT
lngCheck = GetCursorPos_(@pointStruct)
If lngCheck <> 0
ProcedureReturn pointStruct\y
EndIf
EndProcedure
Procedure.s LeftMouseButtonState()
lngState.l
str_Message.s
VK_LBUTTON.l = 1
lngState = getasynckeystate_(VK_LBUTTON)
If lngState = 0
str_Message = "Mouse up"
Else
str_Message = "Mouse down"
EndIf
ProcedureReturn str_Message
EndProcedure
When I run the code i got no display of the Mouse Down Status. I'm absolutely desperated. PLEASE HELP.
Thanks in Advance