Callback, Windows being stupid? (or PB?)

Just starting out? Need help? Post your questions and find answers here.
TimmyTom
User
User
Posts: 36
Joined: Mon Aug 18, 2003 8:32 am

Callback, Windows being stupid? (or PB?)

Post by TimmyTom »

Code: Select all

Procedure CheckFocus(WinID.l, message, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents
  Select message
    Case #WM_SETFOCUS
      Debug "got focus"
    Case #WM_KILLFOCUS
      Debug "lost focus"
  EndSelect
  ProcedureReturn Result
EndProcedure
A simple callback to check focus.. you'd think...

What happens is that when i change tab in my tabber gadget, it tells me that my window lost focus...

what's going on here? and how do i detect that my window looses focus (instantly i need to know this when it happens) without just changing tabs in the app telling me that my window (in which this tabber resides) has lost focus?

Tim
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

If you're using #WM_KILLFOCUS and #WM_SETFOCUS, you'll have to check wParam and only react to the handle to your app's window. Otherwise you'll be catching keyboard focus activity for gadgets as well. ;)

Try catching #WM_ACTIVATEAPP instead.

Code: Select all

#MainWindow = 0
Procedure MyWindowCallback(hWnd.l, msg.l, wParam.l, lParam.l) 
  result = #PB_ProcessPureBasicEvents 
  Select msg 
    Case #WM_ACTIVATEAPP
      Select wParam
        Case #True
          Debug "Received focus" 
        Case #False
          Debug "Lost focus" 
      EndSelect
   EndSelect 
  ProcedureReturn result 
EndProcedure 

If OpenWindow(#MainWindow, 0, 0, 322, 150, #PB_Window_SystemMenu|#PB_Window_ScreenCentered, "#WM_ACTIVATEAPP") And CreateGadgetList(WindowID(0)) 
  SetWindowCallback(@MyWindowCallback())
  PanelGadget(0, 0, 0, 322, 150)
  AddGadgetItem(0, 0, "Tab 0")
  AddGadgetItem(0, 1, "Tab 1")
  CloseGadgetList()
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf 
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

Damn Sparkie.. always crisp and clean.

So, what do you have out there.. you have some custom apps.. I would
like to see your stuff, if you have some..

- np
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

NoahPhense wrote:I would like to see your stuff, if you have some..
Damn! I know there's a good comeback for that line, but I can't come up with it. :D

Seriously though, I have about 3 projects going at this time. The one I'm working on at the moment is a reminder type app for myself.

My wife is always asking me to remind her of this and remind her of that. She knows I can't even remember my own things to do, let alone keep track of her "stuff", but yet she asks me anyways. I just adore her loving confidence in me. :)

This app has the added bonus of helping my boss communicate with me at work. She's forever neglecting to tell me what print jobs are due for the week. (I'm a t-shirt screen printer by day). Now all she has to do is fill in the blanks and I'm a happy camper with no more last minute surprises :) (Oh if it were only that easy!) :roll:

So enter my project. It's about 75% done. More features to add as well as some resize optimization to reduce flickering. Noting fancy, just the facts as I need them 8)

Screenshot 1
Screenshot 2
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

Very nice.. so, can you place my bills up in your calendar.. then *you*
can pay them? :D

- np
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Thanks np :)

I'll be happy to pay your bills...







...just have to wait for that major lottery jackpot to come my way :P
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply