Lock Column width in #ListIconGadget

Just starting out? Need help? Post your questions and find answers here.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Lock Column width in #ListIconGadget

Post 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? :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Post by hallodri »

User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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
Last edited by netmaestro on Fri Dec 21, 2007 4:05 am, edited 1 time in total.
BERESHEIT
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

All good ideas... I like NetMaestro's idea a great deal... it is User Fiendly! :twisted:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> netmaestros way has a flaw. It prevents header dragging and sorting

That's the point: to stop the user changing the headers.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

lol. :lol:

Another classic!
Dare2 cut down to size
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

hehe, Updated! :twisted:

(obfuscation is fun)
BERESHEIT
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

:D
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
);
Dare2 cut down to size
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

That's so sneaky, I like it!!
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

If fangs likes it it must be truly perverted :lol:

@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.
BERESHEIT
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post 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 *
Dare2 cut down to size
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Nice one netmaestro :lol:

You too Dare :lol:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Post by hallodri »

netmaestro wrote:If fangs likes it it must be truly perverted :lol:

@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.
Post Reply