It is currently Sat May 18, 2013 12:33 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: ListIcon: Header Clicks, drags & identification
PostPosted: Wed Mar 21, 2012 4:58 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 791
With a ListIcon, you can permit the user to drag the Headers with #PB_ListIcon_HeaderDragDrop, but there is no Event associated with it. How do you know which column the user is over if they can move the columns without an event? To make it even more difficult, the column number stays with the column data, so you can't even use GetGadgetItemText() to tell.

Also, the Header is clickable, allowing it to highlight. To detect this, are we required to manually identify the mouse location and clicks? How can this be possible when the scrollbars do not send an event so we can calculate the position?

Thanks!


Top
 Profile  
 
 Post subject: Re: ListIcon: Header Clicks, drags & identification
PostPosted: Wed Mar 21, 2012 9:18 pm 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 1467
Change the Column Order does not change the Column Index
See yourself
Code by RASHAD

Code:

If OpenWindow(0, 100, 100, 500, 400, "Column Order Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 5, 5, 490, 290, "Name :", 100, #PB_ListIcon_HeaderDragDrop|#PB_ListIcon_AlwaysShowSelection )
  SendMessage_(GadgetID(0),#LVM_SETEXTENDEDLISTVIEWSTYLE,#LVS_EX_GRIDLINES,#LVS_EX_GRIDLINES)
  AddGadgetColumn(0, 1, "Gender :", 100)
  AddGadgetColumn(0, 2, "Age :", 100)
  AddGadgetColumn(0, 3, "No. :", 100)
  For x = 1 To 10
     AddGadgetItem(0, -1, "Data "+Str(x)+"-1" + Chr(10) + "Data "+Str(x)+"-2" + Chr(10) + "Data "+Str(x)+"-3" + Chr(10) + "Data "+Str(x)+"-4")
  Next
  ButtonGadget(1, 10, 360, 120, 25, "Set column order")
  ButtonGadget(2, 130, 360, 120, 25, "ReSet column order")
  ButtonGadget(3, 250, 360, 120, 25, "Get New Column Order")
  hHwnd  = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
  ColumnCount = SendMessage_(hHwnd,  #HDM_GETITEMCOUNT, 0, 0) - 1
 
  Dim col(ColumnCount)
  Dim col_2(ColumnCount)
 
  SendMessage_(GadgetID(0), #LVM_GETCOLUMNORDERARRAY, ColumnCount+1, col_2()) 
 
  Repeat
    event = WaitWindowEvent()
    If event = #PB_Event_Gadget And EventGadget() = 1
          SendMessage_(GadgetID(0), #LVM_SETCOLUMNORDERARRAY, ColumnCount+1, col_2())
          InvalidateRect_(GadgetID(0),0,1)
          col(0) = 2  ;2+1 = 3
          col(1) = 4  ;4+1 = 1 (Last become First)
          col(2) = 3  ;3+1 = 4
          col(3) = 1  ;1+1 = 2
          SendMessage_(GadgetID(0), #LVM_SETCOLUMNORDERARRAY, ColumnCount+1, col())
          InvalidateRect_(GadgetID(0),0,1)
         
    ElseIf event = #PB_Event_Gadget And EventGadget() = 2
        SendMessage_(GadgetID(0), #LVM_SETCOLUMNORDERARRAY, ColumnCount+1, col_2())
        InvalidateRect_(GadgetID(0),0,1)
    ElseIf event = #PB_Event_Gadget And EventGadget() = 3
        For i = 0 To ColumnCount
            Debug i
            Debug  GetGadgetItemText(0, -1,i)
            Debug ""
        Next
    EndIf
  Until event = #PB_Event_CloseWindow
EndIf
End

_________________
Egypt my love


Top
 Profile  
 
 Post subject: Re: ListIcon: Header Clicks, drags & identification
PostPosted: Wed Mar 21, 2012 10:17 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 791
RASHAD wrote:
Change the Column Order does not change the Column Index
See yourself
Code by RASHAD


Exactly my point!

If they are reordered (by end user), then you have no way of knowing if they are trying to drag from column 2 or column 3, even if the mouse is where column 2 was originally positioned. I am trying to use it like an excel file, but it appears to be much too weak.


Top
 Profile  
 
 Post subject: Re: ListIcon: Header Clicks, drags & identification
PostPosted: Wed Mar 21, 2012 10:33 pm 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 1467
With the next code you can know which cell you clicked
See if that can help

Code:

Global Oldli,Oldr,Oldc,hCWnd,header,hi.LVHITTESTINFO

Procedure GetSubItem(ListIconID) 
  GetCursorPos_(@p.POINT)
  ScreenToClient_(ListIconID, p)
  hCWnd = ChildWindowFromPoint_ (ListIconID, p\y<< 32+p\x)
  header = SendMessage_(ListIconID,#LVM_GETHEADER,0,0)
  ;If hCWnd <> header And hCWnd <> 0
  hi\pt\x = p\x
  hi\pt\y = p\y 
  SendMessage_(ListIconID,#LVM_SUBITEMHITTEST,0,@hi)
  ;EndIf
  ProcedureReturn @hi
EndProcedure

Procedure GetInfo(ListIcon)
  *hi.LVHITTESTINFO = GetSubItem(GadgetID(ListIcon))
  SetGadgetState(ListIcon,-1)
  SetGadgetItemColor(Oldli,OLdr,#PB_Gadget_FrontColor,#Black ,Oldc)
  SetGadgetItemColor(Oldli,Oldr, #PB_Gadget_BackColor, $E8FFFF,Oldc)
  If hCWnd <> header And hCWnd <> 0
      SetGadgetItemColor(ListIcon,*hi\iitem,#PB_Gadget_FrontColor,#White ,*hi\isubitem)
      SetGadgetItemColor(ListIcon,*hi\iitem, #PB_Gadget_BackColor,GetSysColor_(#COLOR_HIGHLIGHT),*hi\isubitem)
      Oldli = listicon
      Oldr = *hi\iitem
      Oldc = *hi\isubitem
      SetGadgetText(4, GetGadgetItemText(ListIcon, *hi\iitem,*hi\isubitem))
      SetGadgetText(5, "ListIcon "+Str(ListIcon)+" / Row "+ Str(*hi\iitem)+" / Column " + Str(*hi\isubitem))
  Else
      SetGadgetText(4, "ListIcon " + Str(ListIcon) + "  " + GetGadgetItemText(ListIcon, -1,*hi\isubitem))
      SetGadgetText(5, "")
  EndIf   
   ;
EndProcedure

OpenWindow(0,0,0,630,460,"ListIcon Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

ListIconGadget(0,10,10,300,200,"Column 0",90,#PB_ListIcon_GridLines)
SetGadgetColor(0, #PB_Gadget_BackColor, $E8FFFF)
AddGadgetColumn(0,1,"Column 1",90)
AddGadgetColumn(0,2,"Column 2",90)

ListIconGadget(1,320,10,300,200,"Column 0",90,#PB_ListIcon_GridLines)
SetGadgetColor(1, #PB_Gadget_BackColor, $E8FFFF)
AddGadgetColumn(1,1,"Column 1",90)
AddGadgetColumn(1,2,"Column 2",90)

ListIconGadget(2,10,220,300,200,"Column 0",90,#PB_ListIcon_GridLines)
SetGadgetColor(2, #PB_Gadget_BackColor, $E8FFFF)
AddGadgetColumn(2,1,"Column 1",90)
AddGadgetColumn(2,2,"Column 2",90)

ListIconGadget(3,320,220,300,200,"Column 0",90,#PB_ListIcon_GridLines)
SetGadgetColor(3, #PB_Gadget_BackColor, $E8FFFF)
AddGadgetColumn(3,1,"Column 1",90)
AddGadgetColumn(3,2,"Column 2",90)

For x = 0 To 3
  For i=0 To 8
    AddGadgetItem(x,-1,"R"+Str(i)+"/C0"+Chr(10)+"R"+Str(i)+"/C1"+Chr(10)+"R"+Str(i)+"/C2")
  Next
Next

StringGadget(4, 10,430,300, 20,"",#PB_String_ReadOnly)
SetGadgetColor(4, #PB_Gadget_BackColor, $EDFFEE)
StringGadget(5, 320, 430, 300,20,"")
SetGadgetColor(5, #PB_Gadget_BackColor, $EDFFEE)


Repeat
  Select WaitWindowEvent()
     
      Case #PB_Event_CloseWindow
          Q = 1
         
      Case #WM_LBUTTONDOWN,#WM_LBUTTONUP
          Result = GetActiveGadget()
            Select Result
              Case 0 To 3
                  GetInfo(GetActiveGadget())
                 
              Case 4
             
              Case 5
             
            EndSelect
             
;       Case #WM_LBUTTONUP
;           Result = GetActiveGadget()             
;           If Result = 0 Or Result = 1 Or Result = 2 Or Result = 3
;            GetInfo(GetActiveGadget())
;           EndIf


  EndSelect
Until Q = 1


_________________
Egypt my love


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: blueb and 3 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