Page 1 of 1

Statusbar events

Posted: Sat Nov 01, 2003 3:36 am
by fsw
Tested under WinXP, hope it works fine also with other WinOSses...

Code: Select all

; Example Of A Statusbar Click Event
; (c) 2003 - By FSW
;
; Tested under WinXP
; do whatever you want with it
;
#Window = 10
#StatusbarFocus = 528
#StatusBar = 1

Procedure.l  LoWord (var.l)
  ProcedureReturn var & $FFFF
EndProcedure


Procedure MyWindowCallback(WindowID, Message, wParam, lParam) 
  Result = #PB_ProcessPureBasicEvents 

  wParamLo = LoWord (wParam)

  If Message = #StatusbarFocus
    If wParamLo = 513 ;Left MouseButton
      MessageRequester("Message", "Left Mouse Click In StatusBar")
    ElseIf wParamLo = 516 ;Right MouseButton
      MessageRequester("Message", "Right Mouse Click In StatusBar")
    EndIf
  EndIf
  
  ProcedureReturn Result 
EndProcedure 


If OpenWindow(#Window,0,0,355,180,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Statusbar Click")
    
  CreateStatusBar(#StatusBar, WindowID())
  StatusBarText(#StatusBar, 0, "Hello World!") 
    AddStatusBarField(270)
    AddStatusBarField(80)
  SetWindowCallback(@MyWindowCallback()) 
 
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
    
EndIf 

Posted: Sat Nov 01, 2003 6:43 am
by TronDoc
works on w98fe
--jb

Posted: Sun Nov 02, 2003 10:20 am
by Karbon
Is there any way to detect which field was clicked on?

Thanks!!

Posted: Sun Nov 02, 2003 5:48 pm
by fsw
Karbon wrote:Is there any way to detect which field was clicked on?

Thanks!!
Not a API function that I'm aware of.
BUT:

Message 528 provides you also the mouse coordinate:
Add the following to your code:

Code: Select all

Procedure.l  LoWord (var.l)
  ProcedureReturn var & $FFFF
EndProcedure
and this in your callback:

Code: Select all

lParamLo = LoWord (lParam)
now you can have information about the mouse pos.

Code: Select all

MessageRequester("Message", "Left Mouse Click In StatusBar. "+"MousePos: "+Str(lParamLo))
Now if you change your routine to:

Code: Select all

  ElseIf Message = #StatusbarFocus
    If wParamLo = 513 And lParamLo < 270 ; 270 is the width of field 1
      MessageRequester("Message", "Left Mouse Click In StatusBar Field 1. "+"MousePos: "+Str(lParamLo))
    ElseIf wParamLo = 513 And lParamLo > 270 + 2 ; there is a BAR between the 2 fields...
      MessageRequester("Message", "Left Mouse Click In StatusBar Field 2. "+"MousePos: "+Str(lParamLo))
    ElseIf wParamLo = 516
      MessageRequester("Message", "Right Mouse Click In StatusBar. "+"MousePos: "+Str(lParamLo))
    EndIf
  EndIf
you are all set.

Hope this get's you going...

Posted: Sun Nov 02, 2003 6:17 pm
by Karbon
fsw, you're officially the most helpful guy around!

Thank you very much!