Statusbar events

Share your advanced PureBasic knowledge/code with the community.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Statusbar events

Post 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 

I am to provide the public with beneficial shocks.
Alfred Hitshock
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

works on w98fe
--jb
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Is there any way to detect which field was clicked on?

Thanks!!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post 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...

I am to provide the public with beneficial shocks.
Alfred Hitshock
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

fsw, you're officially the most helpful guy around!

Thank you very much!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Post Reply