Explorer Combo in Callback Function

Windows specific forum
fabio
User
User
Posts: 11
Joined: Fri Jan 15, 2010 4:52 pm

Explorer Combo in Callback Function

Post by fabio »

Hello, I need some 'winapi' help. How can I get the messages of the Explorer Combo in the Callback Function?
I cannot get any message in the callback...

Code: Select all


;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #ExplorerComb_0
EndEnumeration

Macro LOWORD(Value)
  Value & $FFFF
EndMacro

Macro HIWORD(Value)
  Value >> 16
EndMacro 

Procedure Open_Window_0()
  If OpenWindow(#Window_0, 258, 99, 386, 215, "Explorer Combo",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    ExplorerComboGadget(#ExplorerComb_0, 10, 10, 366, 24, "", #PB_Explorer_Editable)

  EndIf
EndProcedure

Procedure WindowCallback_0(hWnd, uMsg, wParam, lParam) 
  ; Windows fills the parameter automatically, which we will use in the callback...
  
  Select uMsg 
    Case #WM_COMMAND
      Select LOWORD(wParam)
        Case #ExplorerComb_0
          Select HIWORD(wParam)
            Case #CBN_EDITCHANGE
              Debug "COMBO - TEXT CHANGE"
            Case #CBN_SELCHANGE
              Debug "COMBO - SELECTION CHANGE"
          EndSelect 
      EndSelect 
  EndSelect 
  
  ProcedureReturn #PB_ProcessPureBasicEvents 
EndProcedure 

Open_Window_0()

Repeat
  EventID = WaitWindowEvent()
  WindowN = EventWindow()
  GadgetN = EventGadget()
  
  Select EventID
    Case #PB_Event_Gadget
      Select WindowN
        Case #Window_0
          Select GadgetN
            Case #ExplorerComb_0
              ; COMBO EVENT
          EndSelect
      EndSelect 
    Case #PB_Event_CloseWindow
      Select WindowN
        Case #Window_0
          Quit = 1
      EndSelect
  EndSelect 
Until Quit = 1
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: Explorer Combo in Callback Function

Post by Arctic Fox »

Call this after Open_Window_0()

Code: Select all

SetWindowCallback(@WindowCallback_0(), #Window_0)
Something seems wrong, though. The returned low-order word is not the gadget number. :?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Explorer Combo in Callback Function

Post by ts-soft »

Code: Select all

Procedure WindowCallback_0(hWnd, uMsg, wParam, lParam)
  ; Windows fills the parameter automatically, which we will use in the callback...
 
  Select uMsg
    Case #WM_COMMAND
      Select GetDlgCtrlID_(hWnd)
        Case #ExplorerComb_0
          Select HIWORD(wParam)
            Case #CBN_EDITCHANGE
              Debug "COMBO - TEXT CHANGE"
            Case #CBN_SELCHANGE
              Debug "COMBO - SELECTION CHANGE"
          EndSelect
      EndSelect
  EndSelect
 
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure 
Open_Window_0()
SetWindowCallback(@WindowCallback_0(), #Window_0) 
 
fabio
User
User
Posts: 11
Joined: Fri Jan 15, 2010 4:52 pm

Re: Explorer Combo in Callback Function

Post by fabio »

I forgot to add SetWindowCallback (...), Arctic Fox, thanks for the correction :).
ts-soft: Your code works, but only when #ExplorerComb_0 is zero. With any other value fails, here is the code again (using #ExplorerComb_0 = 10):

Code: Select all


;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #ExplorerComb_0 = 10
EndEnumeration

Macro LOWORD(Value)
  Value & $FFFF
EndMacro

Macro HIWORD(Value)
  Value >> 16
EndMacro 

Procedure Open_Window_0()
  If OpenWindow(#Window_0, 258, 99, 386, 215, "Explorer Combo",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    ExplorerComboGadget(#ExplorerComb_0, 10, 10, 366, 24, "", #PB_Explorer_Editable)
   
  EndIf
EndProcedure

Procedure WindowCallback_0(hWnd, uMsg, wParam, lParam) 
  ; Windows fills the parameter automatically, which we will use in the callback...
  
  Select uMsg 
    Case #WM_COMMAND
      Select GetDlgCtrlID_(hWnd)
        Case #ExplorerComb_0
          Select HIWORD(wParam)
            Case #CBN_EDITCHANGE
              Debug "COMBO - TEXT CHANGE"
            Case #CBN_SELCHANGE
              Debug "COMBO - SELECTION CHANGE"
          EndSelect 
      EndSelect 
  EndSelect 
  
  ProcedureReturn #PB_ProcessPureBasicEvents 
EndProcedure 

Open_Window_0()
SetWindowCallback(@WindowCallback_0(), #Window_0)

Repeat
  EventID = WaitWindowEvent()
  WindowN = EventWindow()
  GadgetN = EventGadget()
  
  Select EventID
    Case #PB_Event_Gadget
      Select WindowN
        Case #Window_0
          Select GadgetN
            Case #ExplorerComb_0
              ; COMBO EVENT
          EndSelect
      EndSelect 
    Case #PB_Event_CloseWindow
      Select WindowN
        Case #Window_0
          Quit = 1
      EndSelect
  EndSelect 
Until Quit = 1
fabio
User
User
Posts: 11
Joined: Fri Jan 15, 2010 4:52 pm

Re: Explorer Combo in Callback Function

Post by fabio »

Solved. It works using GetDlgCtrlID_(lParam).
But I still don't understand (like Arctic Fox detected) why LOWORD(wParam) does not return the ID of the combo.
Thank you very much guys for the help provided.

Fabio
Post Reply