HeaderDragDrop, get new position?
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
HeaderDragDrop, get new position?
With #PB_ListIcon_HeaderDragDrop how can I know which position the column has if the user has moved it?
I like logic, hence I dislike humans but love computers.
Code: Select all
#HDN_ENDDRAG = #HDN_FIRST - 11
#HDM_GETORDERARRAY = #HDM_FIRST + 17
;... Need this updated HDITEM structure for accessing iOrder member
;... IE 5 or greater is required so I think we're safe using it
Structure _HDITEM
mask.l
cxy.l
pszText.l
hbm.l
cchTextMax.l
fmt.l
lParam.l
iImage.l
iOrder.l
type.l
pvFilter.l
EndStructure
Procedure WinProc(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*pnmhdr.NMHDR = lParam
Select *pnmhdr\code
Case #HDN_ENDDRAG
*pnmhead.NMHEADER = lParam
*hdi._HDITEM = *pnmhead\pitem
SetWindowTitle(0, "Column " + Str(*pnmhead\iItem) + " was moved to Column " + Str(*hdi\iOrder))
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 100, 100, 310, 200, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowCallback(@WinProc())
If CreateGadgetList(WindowID(0))
ListIconGadget(0, 5, 5, 300, 190, "Col 0", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_HeaderDragDrop)
AddGadgetColumn(0, 1, "Col 1", 100)
AddGadgetColumn(0, 2, "Col 2", 100)
For i = 0 To 9
AddGadgetItem(0, -1, "Item" + Str(i) + " Col 0" + Chr(10) + "Item" + Str(i) + " Col 1" + Chr(10) + "Item" + Str(i) + " Col 2" + Chr(10))
Next
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
EndIf
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: HeaderDragDrop, get new position?
After one thousand of year..i have the same problem
That work at the moment of the drag, but the order is not changed with GetGadgetItemText()
How can i obtain the good order of the column when i close the window ?
Have a good day

That work at the moment of the drag, but the order is not changed with GetGadgetItemText()

How can i obtain the good order of the column when i close the window ?
Code: Select all
#HDN_ENDDRAG = #HDN_FIRST - 11
#HDM_GETORDERARRAY = #HDM_FIRST + 17
;... Need this updated HDITEM structure for accessing iOrder member
;... IE 5 or greater is required so I think we're safe using it
Structure _HDITEM
mask.l
cxy.l
pszText.l
hbm.l
cchTextMax.l
fmt.l
lParam.l
iImage.l
iOrder.l
type.l
pvFilter.l
EndStructure
Procedure WinProc(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*pnmhdr.NMHDR = lParam
Select *pnmhdr\code
Case #HDN_ENDDRAG
*pnmhead.NMHEADER = lParam
*hdi._HDITEM = *pnmhead\pitem
SetWindowTitle(0, "Column " + Str(*pnmhead\iItem) + " was moved to Column " + Str(*hdi\iOrder))
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 100, 100, 310, 200, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowCallback(@WinProc())
ListIconGadget(0, 5, 5, 300, 190, "Col 0", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_HeaderDragDrop)
AddGadgetColumn(0, 1, "Col 1", 100)
AddGadgetColumn(0, 2, "Col 2", 100)
For i = 0 To 9
AddGadgetItem(0, -1, "Item" + Str(i) + " Col 0" + Chr(10) + "Item" + Str(i) + " Col 1" + Chr(10) + "Item" + Str(i) + " Col 2" + Chr(10))
Next
Debug ""
For i = 0 To 2
Debug GetGadgetItemText(0, -1, i)
Next
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
Debug ""
For i = 0 To 2
Debug GetGadgetItemText(0, -1, i)
Next
EndIf

Not a destination
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: HeaderDragDrop, get new position?
I have found the soulution thanks to SHARDICK code

Code: Select all
#HDN_ENDDRAG = #HDN_FIRST - 11
#HDM_GETORDERARRAY = #HDM_FIRST + 17
;... Need this updated HDITEM structure for accessing iOrder member
;... IE 5 or greater is required so I think we're safe using it
Structure _HDITEM
mask.l
cxy.l
pszText.l
hbm.l
cchTextMax.l
fmt.l
lParam.l
iImage.l
iOrder.l
type.l
pvFilter.l
EndStructure
ArrayBufferPtr = AllocateMemory(3 * 4)
Procedure WinProc(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*pnmhdr.NMHDR = lParam
Select *pnmhdr\code
Case #HDN_ENDDRAG
*pnmhead.NMHEADER = lParam
*hdi._HDITEM = *pnmhead\pitem
SetWindowTitle(0, "Column " + Str(*pnmhead\iItem) + " was moved to Column " + Str(*hdi\iOrder))
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 100, 100, 310, 200, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowCallback(@WinProc())
ListIconGadget(0, 5, 5, 300, 190, "Col 0", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_HeaderDragDrop)
AddGadgetColumn(0, 1, "Col 1", 100)
AddGadgetColumn(0, 2, "Col 2", 100)
For i = 0 To 9
AddGadgetItem(0, -1, "Item" + Str(i) + " Col 0" + Chr(10) + "Item" + Str(i) + " Col 1" + Chr(10) + "Item" + Str(i) + " Col 2" + Chr(10))
Next
Debug ""
For i = 0 To 2
Debug GetGadgetItemText(0, -1, i)
Next
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
If SendMessage_(GadgetID(0), #LVM_GETCOLUMNORDERARRAY, 3, ArrayBufferPtr) <> #False
Debug ""
For i = 0 To 2
Debug GetGadgetItemText(0, -1, PeekL(ArrayBufferPtr + i * 4))
Next
EndIf
EndIf

Not a destination