Page 1 of 2
ListIconGadget questions...
Posted: Thu Mar 15, 2007 1:00 am
by Joakim Christiansen
I need to know if the ListIconGadget header was right clicked, how should I do this?
And btw the ListIconGadget is a
HELL to work with, I think we should be able to use the same code to fill it even if a column was deleted!
Because now I have to check exactly how the columns is and make a super duper big procedure with every combination to fill it right!
Code: Select all
AddGadgetItem(0,-1,"Item 1"+#LF$+"Item 2"+#LF$+"Item 3")
This doesn't fill right if I remove column 2, because then column 3 will receive the item which was supposed to be in column 2!
Is there any way I can use API to fill it in a more intelligent way maybe, or any other suggestions?
Yes, I really need my users to be able to choose which columns they want visible, move them too.
And btw, how can my program change the columns positions after they are created?
Posted: Thu Mar 15, 2007 2:21 am
by netmaestro
I need to know if the ListIconGadget header was right clicked, how should I do this?
Like this:
Code: Select all
; Subclassing the ListIcon Gadget Header Control
; 03/2007 by netmaestro
Procedure callback(hwnd, msg, wparam, lparam)
Protected oldproc = GetProp_(hwnd, "oldproc")
result=CallWindowProc_(oldproc,hwnd,msg,wparam,lparam)
If msg = #WM_RBUTTONUP
hti.hd_hittestinfo
hti\pt\x = lparam&$FFFF
hti\pt\y = lparam>>16
SendMessage_(hwnd, #HDM_HITTEST,0,@hti)
Debug "Right Button Up On Header item: "+Str(hti\iItem)
ElseIf msg = #WM_RBUTTONDOWN
hti.hd_hittestinfo
hti\pt\x = lparam&$FFFF
hti\pt\y = lparam>>16
SendMessage_(hwnd, #HDM_HITTEST,0,@hti)
Debug "Right Button Down On Header item: "+Str(hti\iItem)
EndIf
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,300,400,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ListIconGadget(0,0,0,300,400,"Column 0",100)
AddGadgetColumn(0, 1,"Column 1",200)
; find header control hwnd and subclass it
header = GetWindow_(GadgetID(0),#GW_CHILD)
oldproc=SetWindowLong_(header,#GWL_WNDPROC, @callback())
SetProp_(header, "oldproc", oldproc)
Repeat:Until WaitWindowEvent()=#WM_CLOSE
And btw the ListIconGadget is a HELL to work with
Welcome to the wonderful world of Windows programming, JLC!

Posted: Thu Mar 15, 2007 2:25 am
by Sparkie
Joakim Christiansen wrote:And btw, how can my program change the columns positions after they are created?
That can be done using API #LVM_SETCOLUMNORDERARRAY.
Code: Select all
#LVM_SETCOLUMNORDERARRAY = #LVM_FIRST + 58
;...Array for holding default column order
Dim colArray(2)
If OpenWindow(0, 100, 100, 500, 400, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
ListIconGadget(0, 5, 5, 490, 290, "Column A", 160, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_GridLines)
AddGadgetColumn(0, 1, "Column B", 160)
AddGadgetColumn(0, 2, "Column C", 160)
ButtonGadget(1, 10, 360, 200, 25, "Change column order")
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 1
colArray(0) = 1
colArray(1) = 0
colArray(2) = 2
;...Switch column 0 with column 1
;...This allows us to edit the reminder data
SendMessage_(GadgetID(0), #LVM_SETCOLUMNORDERARRAY, 3, colArray())
DisableGadget(1, 1)
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
End
Posted: Thu Mar 15, 2007 2:29 am
by srod
Holy slow coach, beaten by the deadly duo; batman + netmaestro yet again!
Oh well, I'll post what I hacked up anyhow:
Code: Select all
#LVM_GETHEADER = #LVM_FIRST+31
Procedure.l callback(hWnd, uMsg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_NOTIFY
*nmh.NMHDR=lParam
Select *nmh\code
Case #NM_RCLICK
If *nmh\hwndFrom = SendMessage_(GadgetID(0),#LVM_GETHEADER,0,0)
;Now identify which item was clicked.
GetCursorPos_(hdhittest.HD_HITTESTINFO\pt)
ScreenToClient_(*nmh\hwndFrom, hdhittest\pt)
SendMessage_(*nmh\hwndFrom, #HDM_HITTEST, 0, @hdhittest)
Debug "Clicked header item " + Str(hdhittest\iItem)
EndIf
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "Address", 250)
AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
SetWindowCallback(@callback())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
EndIf
@Joakim Christiansen: to alleviate your AddGadgetItem() woes, you could simply use AddGadgetItem() with an empty string and then set individual cells with SetGadgetItemText() etc. This might be slightly less problematic.
Posted: Thu Mar 15, 2007 2:43 am
by Sparkie
srod wrote:Holy slow coach, beaten by batman yet again!
It's been a while since anyone has beaten the Great ListIconGadgetGuru named srod.
I figure you must have been taking a little snooze...zzzzzzz

Posted: Thu Mar 15, 2007 2:46 am
by netmaestro
It's well posted anyway as srod and I chose different avenues to achieve the rightclick test.
Posted: Thu Mar 15, 2007 2:50 am
by srod
No time for sleep... must work... must debug spahgetti code... must co... zzzzzz!
Actually, I realised after I posted that it was netmaestro who had already produced code to solve the problem I was working on. Must have got your avatars mixed up somehow!
I was getting to the set column order array, but was way too slow for that one!

Posted: Thu Mar 15, 2007 2:57 am
by Sparkie
Hey srod...I want to swap rankings with you...here's my
PureBasic Expert which you have more than earned. Now if you will kindly hand over your
Addict ranking I'll be on my way.

Posted: Thu Mar 15, 2007 2:59 am
by netmaestro
grrr... Mitts off mine, it hasn't had time to get dusty yet!
Posted: Thu Mar 15, 2007 3:10 am
by Sparkie
Not to worry netmaestro. Yours suits you just fine. Mine just doesn't feel right. I don't know.... maybe it's the weight I gained since I quit smoking

Posted: Thu Mar 15, 2007 3:10 am
by srod
Sparkie wrote:Hey srod...I want to swap rankings with you...here's my
PureBasic Expert which you have more than earned. Now if you will kindly hand over your
Addict ranking I'll be on my way.

Are you kidding man?

Your knowledge of api stuff far outweigh's mine and on a technical level, some of your posts are beyond reproach. Beside's one of my posts in the bug section this week warrants that I get busted back down to 'Novice' at best!

No, in as much as the rankings are pretty meaningless, you two are the real experts here. I just don't have a great deal of time at the moment to help out in the forums as I once did.
No, I could list half a dozen users who should be elevated way before myself - and there are undoubtedly many more.
Now, how about we swap bank accounts instead?

Posted: Thu Mar 15, 2007 3:14 am
by Sparkie
srod wrote:Now, how about we swap bank accounts instead?
Two weeks ago maybe I'd have said yes....but now that I have deposited my tax refund check...hmmmm....I don't think so my friend

Posted: Thu Mar 15, 2007 3:17 am
by Sparkie
srod wrote:Beside's one of my posts in the bug section this week warrants that I get busted back down to 'Novice' at best!
Done that once or twice myself. No need for

as it just shows that we are human just like everyone else

Posted: Thu Mar 15, 2007 3:18 am
by srod
Not even if I throw my 'Addict' ranking in for free?
Oh well, worth a try!

Posted: Thu Mar 15, 2007 3:20 am
by Fangbeast
Done that once or twice myself. No need for

as it just shows that we are human just like everyone else
Human?? We have a frog, a bat, a homer simpsons character and a visiting fanged beast in the room!!