Page 1 of 2
Lock Column width in #ListIconGadget
Posted: Thu Dec 20, 2007 5:08 pm
by Rook Zimbabwe
Aside from constantly checking the sizes of each column gadget in my program to insure that the user has not resized them... and then forcing them back to size...
Is there any way to just LOCK the column widths?

Posted: Thu Dec 20, 2007 5:14 pm
by hallodri
Posted: Thu Dec 20, 2007 5:27 pm
by Fluid Byte
Code: Select all
Procedure WindowCallback(hWnd,uMsg,wParam,lParam)
Select uMsg
Case #WM_NOTIFY
*lpnm.NMHDR = lParam
If *lpnm\hwndFrom = GetWindow_(GadgetID(0),#GW_CHILD) And *lpnm\code = #HDN_BEGINTRACK
ProcedureReturn 1
EndIf
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ListIconGadget(0,0,0,320,240,"Name",160)
AddGadgetColumn(0,1,"Type",80)
AddGadgetColumn(0,1,"Size",60)
SetWindowCallback(@WindowCallback())
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Posted: Thu Dec 20, 2007 7:09 pm
by netmaestro
@fluid byte, works fine but won't irritate the user nearly enough. Try this:
Code: Select all
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ListIconGadget(0,0,0,320,240,"Name",160)
AddGadgetColumn(0,1,"Type",80)
AddGadgetColumn(0,1,"Size",60)
header = SendMessage_(GadgetID(0),#LVM_GETHEADER,0,0)
Repeat
ev = WaitWindowEvent(1)
GetWindowRect_(header, @wr.rect)
If PtInRect_(wr, DesktopMouseX(),DesktopMouseY())
ShowWindow_(header, #SW_HIDE)
dc = GetDC_(GadgetID(0))
TextOut_(dc, 100,0, PeekS(?begin), 15)
ReleaseDC_(GadgetID(0),dc)
Else
ShowWindow_(header, #SW_SHOW)
EndIf
Until ev = #WM_CLOSE
DataSection
begin:
Data.q 7453301692552738114,9400190730641523
Posted: Thu Dec 20, 2007 7:21 pm
by Rook Zimbabwe
All good ideas... I like NetMaestro's idea a great deal... it is User Fiendly!

Posted: Thu Dec 20, 2007 9:25 pm
by Fluid Byte
Altough I was laughing hard netmaestros way has a flaw. It prevents header dragging and sorting. If you really want insist in limiting your gadet this way you can directly use #LVS_NOCOLUMNHEADER.
Posted: Fri Dec 21, 2007 2:19 am
by PB
> netmaestros way has a flaw. It prevents header dragging and sorting
That's the point: to stop the user changing the headers.
Posted: Fri Dec 21, 2007 3:44 am
by Dare
lol.
Another classic!
Posted: Fri Dec 21, 2007 4:06 am
by netmaestro
hehe, Updated!
(obfuscation is fun)
Posted: Fri Dec 21, 2007 4:25 am
by Dare
Keep going and we'll promote you to cane toad!
BTW, I didn't realise you could use PtInRect this way: PtInRect_(handle, x, y). My SDK says:
Code: Select all
BOOL PtInRect(
CONST RECT *lprc, // rectangle
POINT pt // point
);
Posted: Fri Dec 21, 2007 4:28 am
by Fangbeast
That's so sneaky, I like it!!
Posted: Fri Dec 21, 2007 4:37 am
by netmaestro
If fangs likes it it must be truly perverted
@dare, yes the sdk is wrong on this doc. the function expects separate values for the x and y instead of a pointer to a point structure.
Posted: Fri Dec 21, 2007 4:52 am
by Dare
Thanks for the info mate.
BTW, if fangs likes it you probably need to go seek some professional help.
* hehe - double whammy, 2 birds with one stone - flees thread chortling *
Posted: Fri Dec 21, 2007 5:17 am
by Sparkie
Nice one netmaestro
You too Dare

Posted: Fri Dec 21, 2007 8:34 am
by hallodri
netmaestro wrote:If fangs likes it it must be truly perverted
@dare, yes the sdk is wrong on this doc. the function expects separate values for the x and y instead of a pointer to a point structure.
No, is a byval problem, the sdk ist right . Freak can tell you more about that.