detect is listview has focus?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Searched the forum but not a real solution found

I want with shift-UP shift_Down keys change the order of items in a listview, but first of course the listview must have focus first.

any suggestions?

Using Windows 98 SE
Registered Purebasic
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
http://www.chordplanet.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

Code: Select all

#ListView = 1

Procedure WindowCallback(Window.l, Message.l, wParam.l, lParam.l)
  result = #PB_ProcessPureBasicEvents
  
  If Message = #WM_COMMAND
  
    If wParam>>16 = #LBN_SETFOCUS And lParam = GadgetID(#ListView)
    
      AddGadgetItem(#ListView, -1, "got focus!")
      
    ElseIf wParam>>16 = #LBN_KILLFOCUS And lParam = GadgetID(#ListView)
    
      AddGadgetItem(#ListView, -1, "lost focus!")
    
    EndIf

  
  EndIf
  
  ProcedureReturn result
EndProcedure




OpenWindow(0,0,0,500,500,#PB_Window_SystemMenu|#PB_Window_Screencentered, "ListView Focus")
CreateGadgetList(WindowID())

ListViewGadget(#ListView, 100, 100, 200, 200)
AddGadgetItem(#ListView,-1,"Listview, click to get Focus")

StringGadget(0,100,350,250,25,"Click here to get focus from ListView")

SetWindowCallback(@WindowCallback())

While WaitWindowEvent()  #PB_EventCloseWindow: Wend
End
--------------

Hope that helps...

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Thanks Timo,

It's working

Using Windows 98 SE
Registered Purebasic
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
http://www.chordplanet.com
Post Reply