[sorry, not lack]pb lack 2 Constants #pb_FileSelected=5,

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

[sorry, not lack]pb lack 2 Constants #pb_FileSelected=5,

Post by gurj »

; pb lack 2 Constants:
; #pb_FileSelected=5
; #pb_DirectorySelected=6
; other lack:
; #pb_FileUnSelected=1
; #pb_DirectoryUnSelected=2
; [a bug: 10000==2, but it isnot Directory, it Not exist]
; #pb_NotExist=-1
; #pb_IsDirectory=-2

Code: Select all

If OpenWindow(0, 0, 0, 900, 550, "Explorer", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 LoadFont(0,"system", 12):SetGadgetFont(#PB_Default, FontID(0))
 ;ExplorerTreeGadget(0, 0, 0, 250, 500, "*.*",#PB_Explorer_AlwaysShowSelection)
 elg=ExplorerListGadget(1, 250, 0, 650, 500, "*.*",#PB_Explorer_MultiSelect|#PB_Explorer_AlwaysShowSelection)
 SetGadgetAttribute(1,#PB_Explorer_DisplayMode,#PB_Explorer_List)
 SetGadgetText(1,"c:\")
 EditorGadget(3, 0,30,250, 60,#PB_Editor_WordWrap)
 SetGadgetText(3,"please select some file and Directory,then test:")
 EditorGadget(4, 0,130,250, 410,#PB_Editor_WordWrap)
 SetGadgetText(4,~"pb lack 2 Constants:\n#pb_FileSelected=5\n#pb_DirectorySelected=6\nother lack:\n#pb_FileUnSelected=1\n#pb_DirectoryUnSelected=2\n[a bug: 10000==2, but it isnot Directory, it not exist]\n#pb_NotExist=-1\n#pb_IsDirectory=-2\n")
 
 ButtonGadget(2, 0,100,200, 20, "test")
 
 Repeat:ev=WaitWindowEvent():Select ev
   Case #PB_Event_Gadget:eg=EventGadget()
    Select eg
     Case 2
      ;*****get all Selected
      id=-1
      re:
      id=SendMessage_(elg, #LVM_GETNEXTITEM, id,#LVNI_SELECTED)
      If id>-1:st=GetGadgetItemState(1,id)
       Debug ""+id+"="+GetGadgetItemText(1,id)+"="+st
       
       If st=5 And FileId=0
        FileId=id
       ElseIf st=6 And DirId=0
        DirId=id
       EndIf
       Goto re
      EndIf
      
      ;*****Not Selected
      Debug "----------"
      SetGadgetItemState(1,FileId,0):st=GetGadgetItemState(1,FileId)
      Debug ""+FileId+"="+GetGadgetItemText(1,FileId)+"="+st
      SetGadgetItemState(1,DirId,0):st=GetGadgetItemState(1,DirId)
      Debug ""+DirId+"="+GetGadgetItemText(1,DirId)+"="+st
      Debug "----------"
      st=GetGadgetItemState(1,10000)
      Debug ""+10000+"="+GetGadgetItemText(1,10000)+"="+st
      ;*****a bug: 10000==2, but it isnot Directory, it Not exist
    EndSelect
   Case #PB_Event_CloseWindow:Break
 EndSelect:ForEver
 End
EndIf

Last edited by gurj on Mon Jan 14, 2019 1:17 am, edited 1 time in total.
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: pb lack 2 Constants #pb_FileSelected=5, #pb_DirectorySel

Post by gurj »

sorry, not lack, see doc:
GetGadgetItemState()

- ExplorerListGadget(): returns a combination of the following values
#PB_Explorer_File : The item is a file.
#PB_Explorer_Directory : The item is a Directory (or drive).
#PB_Explorer_Selected : The item is currently selected.

#PB_Explorer_File=1
#PB_Explorer_Directory=2
#PB_Explorer_Selected=4
---------------
following values:
#PB_Explorer_File|#PB_Explorer_Selected=5
#PB_Explorer_Directory|#PB_Explorer_Selected=6
my pb for chinese:
http://ataorj.ys168.com
Post Reply