It is currently Mon Nov 20, 2017 1:07 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: edit ListIconG text [Windows]
PostPosted: Tue Nov 14, 2017 6:24 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 434
Location: china
edit ListIconG text [Windows]
Code:
;edit ListIconG text.pb
;codes used from Author 'El Choni' and from 'WinApi Library'
; OS: Windows

Procedure LoWord(value)
 ProcedureReturn value & $FFFF
EndProcedure

Procedure HiWord(value)
 ProcedureReturn value >> 16 & $FFFF
EndProcedure

If OpenWindow(0, 0, 0, 400, 290, "edit ListIconG text", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)=0:End:EndIf
CheckBoxGadget(10, 10,  10, 90, 20, "edit")
ListIconG = ListIconGadget(1, 10, 40, 380, 240, "", 70, #PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines|#LVS_NOSORTHEADER)
;-{****使用#PB_ListIcon_FullRowSelect就没如下问题};-{pInfo\iItem>-1;****为排除问题
#CCM_SETVERSION = #CCM_FIRST+7
SendMessage_(ListIconG, #CCM_SETVERSION, 5, 0)

AddGadgetColumn(1, 0, "time\day", 35)
AddGadgetColumn(1, 1, "Sun", 35)
AddGadgetColumn(1, 2, "Mon", 35)
AddGadgetColumn(1, 3, "Tue", 35)
AddGadgetColumn(1, 4, "Wed", 35)
AddGadgetColumn(1, 5, "Thu", 35)
AddGadgetColumn(1, 6, "Fri", 35)
AddGadgetColumn(1, 7, "Sat", 35)

For i=18 To 34
 hour12 = i
 If hour12>25
  hour12-24
  Hour$ = " pm"
 Else
  Hour$ = " am"
 EndIf
 If hour12&1
  Hour$=Str(hour12/2)+":30"+Hour$
 Else
  Hour$=Str(hour12/2)+":00"+Hour$
 EndIf
 AddGadgetItem(1, -1, Hour$+Chr(10)+Str(hour12/2)+"1"+Chr(10)+Str(hour12/2)+"2"+Chr(10)+Str(hour12/2)+"3"+Chr(10)+Str(hour12/2)+"4"+Chr(10)+Str(hour12/2)+"5"+Chr(10)+Str(hour12/2)+"6"+Chr(10)+Str(hour12/2)+"7")
Next i

SendMessage_(ListIconG, #LVM_SETBKCOLOR, 0, RGB(255, 255, 123))

sg=StringGadget(2,0,0,0,0,"",#PB_String_BorderLess|#ES_NOHIDESEL)
;SetGadgetColor(2,#PB_Gadget_BackColor,#Red)因为下行而无效
SetWindowLongPtr_(sg,#GWLP_HWNDPARENT,ListIconG)
For i=0 To 7
 SendMessage_(ListIconG, #LVM_SETCOLUMNWIDTH, i, #LVSCW_AUTOSIZE_USEHEADER)
Next i

pInfo.LVHITTESTINFO
hItem.HD_ITEM
lvc.LV_COLUMN
lvc\mask = #LVCF_TEXT
rc.RECT
re.RECT
r2.RECT
header=SendMessage_(ListIconG,#LVM_GETHEADER,0,0)
GetWindowRect_(header, @re)
hh=re\Bottom-re\Top
GetWindowRect_(ListIconG,re)
hItem\mask = #HDI_TEXT
textBuff$ = Space(255)
hItem\pszText = @textBuff$
hItem\cchTextMax = 255
SetGadgetState(10,1)
Repeat:ev=WaitWindowEvent():Select ev
   
   Case #WM_LBUTTONDBLCLK:If GetGadgetState(10)
    GetCursorPos_(pt.POINT) :q.q=PeekQ(@pt)
    If PtInRect_(re,q) And PtInRect_(r2,q)=0
     lParam=EventlParam()
     pInfo\pt\x = LoWord(lParam)
     pInfo\pt\y = HiWord(lParam):y=pInfo\pt\y-hh
     SendMessage_(ListIconG, #LVM_SUBITEMHITTEST, 0, pInfo)
     rc\top = pInfo\iSubItem
     rc\left = #LVIR_BOUNDS
     SendMessage_(ListIconG, #LVM_GETSUBITEMRECT, pInfo\iItem, rc)
     If pInfo\iSubItem =0
      rc\right = rc\left+SendMessage_(ListIconG, #LVM_GETCOLUMNWIDTH, 0, 0)
     EndIf
     ;-{pInfo\iItem>-1;****为排除问题
     If pInfo\iItem>-1;****为排除问题:1列a行正编辑时若双击0列a行非文本则有问题
                      ;Debug GetGadgetState(1):
      If y>0
       ResizeGadget(2,rc\left,rc\top,rc\right-rc\left,rc\bottom-rc\top)
       SetGadgetText(2,GetGadgetItemText(1,pInfo\iItem,pInfo\iSubItem));:EndIf
      Else:SendMessage_(header, #HDM_GETITEM, pInfo\iSubItem, @hItem)
       ResizeGadget(2,rc\left,0,rc\right-rc\left,hh)
       SetGadgetText(2,textBuff$)
      EndIf
      GetWindowRect_(sg,r2)
      ;HideGadget(2,0)
      SetActiveGadget(2)
   SendMessage_(sg, #EM_SETSEL,0, -1):EndIf:EndIf:EndIf
  Case #PB_Event_Gadget:eg=EventGadget()
   Select eg
     Case 2:If EventType()=#PB_EventType_Change;#PB_EventType_LostFocus
      If y>0:SetGadgetItemText(1, pinfo\iItem, GetGadgetText(2), pInfo\iSubItem)
      Else:textBuff$=GetGadgetText(2)
       lvc\pszText = @textBuff$
       SendMessage_(ListIconG,#LVM_SETCOLUMN,pInfo\iSubItem,@lvc)
       HideGadget(2,1):HideGadget(2,0):SetActiveGadget(2);****为使0行正常
      EndIf
      ;HideGadget(2,1)
     EndIf
     Case 10:If GetGadgetState(10):HideGadget(2,0)
      Else:HideGadget(2,1):EndIf
   EndSelect
 EndSelect
Until ev=#PB_Event_CloseWindow

End

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
 Post subject: Re: edit ListIconG text [Windows]
PostPosted: Thu Nov 16, 2017 11:17 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 377
Location: Berlin and Ibiza
Image

_________________
ImageImageImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: edit ListIconG text [Windows]
PostPosted: Fri Nov 17, 2017 12:06 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 434
Location: china
@RSBasic:
thanks Andre Beer / PureBasic-Team for 'PureBasic CodeArchiv v4.0 Beta'
thanks RASHAD and RSBasic for 'WinApi Library'

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: skywalk and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye