Determining which column header clicked in a ListIconGadget

Just starting out? Need help? Post your questions and find answers here.
vwchest@va.tds.net
New User
New User
Posts: 7
Joined: Wed Oct 21, 2009 11:31 pm

Determining which column header clicked in a ListIconGadget

Post by vwchest@va.tds.net »

I am writing a program for doing various calculations on paper rolled onto a core (I work in a paper mill). When the user has selected a row in the table they should be able to click a column header and have an dialogue box pop up that allows either English or Metric input for the specific subitem (Lineal Feet, Weight, etc.). I know this involves a callback routine and #LVN_COLUMNCLICK. I can get the row number from GetGadgetState(#Gadget). I have tried similar code from other posts but doesn't work.
Here's the framework for my callback routine:
Procedure SpecialEventCallback(hwnd, msg, wParam, lParam)
SpecialEvent\Awaits = #YES
Select msg
Case #WM_NOTIFY
; WHAT GOES IN HERE???
EndSelect

ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

I have a global structure defined as:
Structure SE
Awaits.i
GadgetID_SE.i
EventTypeID_SE.i
Column_SE.i
EndStructure

Global SpecialEvent.SE

I know I have a special event in the main program loop by:
If MainWindow
MainWindowID = WindowID(MainWindow)
IncludeFile "MainWindowGadgets.pb"
SetWindowCallback(@SpecialEventCallback())
Repeat
WindowEventID = WaitWindowEvent()
WindowEventOccurred = EventWindow()
Select WindowEventOccurred
Case MainWindow
.......
EndSelect
If SpecialEvent\Awaits = #YES
SpecialEvent\Awaits = #NO ; reset queue
....... ; call the english/metric input dialogue
EndIf
Until ProgramHalt = #YES
Else
MessageRequester("Program Failed", "Could Not Create Main Window" , #PB_MessageRequester_Ok)
EndIf ; Main Window was created





TempColWidth.i = 130
ListIconGadget(#MW_English_Basestock_Table, 5, 25, 990, 200, "Roll #", 70 , #PB_ListIcon_CheckBoxes|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
SetGadgetColor(#MW_English_Basestock_Table, #PB_Gadget_BackColor, RGB(222, 250, 251))
GadgetToolTip(#MW_English_Basestock_Table, "Basestock List in English Units")
AddGadgetColumn(#MW_English_Basestock_Table, 1, "Lineal Feet", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 2, "Weight", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 3, "Caliper", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 4, "Basis Weight", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 5, "Width", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 6, "Roll Diameter", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 7, "Core Diameter", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 8, "Outer Laps", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 9, "Waste Diameter", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 10, "LF Available", TempColWidth)

ListIconGadget(#MW_Metric_Basestock_Table, 5, 25, 990, 200, "Roll #", 70 , #PB_ListIcon_CheckBoxes|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
SetGadgetColor(#MW_Metric_Basestock_Table, #PB_Gadget_BackColor, RGB(222, 250, 251))
GadgetToolTip(#MW_Metric_Basestock_Table, "Basestock List in Metric Units")
AddGadgetColumn(#MW_Metric_Basestock_Table, 1, "Lineal Meters", TempColWidth)
AddGadgetColumn(#MW_Metric_Basestock_Table, 2, "Weight", TempColWidth)
AddGadgetColumn(#MW_Metric_Basestock_Table, 3, "Caliper", TempColWidth)
AddGadgetColumn(#MW_Metric_Basestock_Table, 4, "GSM", TempColWidth)
AddGadgetColumn(#MW_Metric_Basestock_Table, 5, "Width", TempColWidth)
AddGadgetColumn(#MW_Metric_Basestock_Table, 6, "Roll Diameter", TempColWidth)
AddGadgetColumn(#MW_Metric_Basestock_Table, 7, "Core Diameter", TempColWidth)
AddGadgetColumn(#MW_Metric_Basestock_Table, 8, "Outer Laps", TempColWidth)
AddGadgetColumn(#MW_Metric_Basestock_Table, 9, "Waste Diameter", TempColWidth)
AddGadgetColumn(#MW_Metric_Basestock_Table, 10, "LM Available", TempColWidth)


SplitterGadget(#MW_Basestock_Table_Splitter, 5, 25, 990, 200, #MW_English_Basestock_Table, #MW_Metric_Basestock_Table, #PB_Splitter_Separator)
GadgetToolTip(#MW_Basestock_Table_Splitter, "Click and Drag with Left Mouse Button to Resize English and Metric Windows")

http://docs.google.com/leaf?id=0B6tbAc8 ... y=CPHuzvYB
Last edited by vwchest@va.tds.net on Sun Jul 25, 2010 11:38 pm, edited 1 time in total.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Determining which column header clicked in a ListIconGad

Post by netmaestro »

Code: Select all

#MW_English_Basestock_Table = 0

Procedure WinProc(hwnd, msg, wparam, lparam)
  result = #PB_ProcessPureBasicEvents
  Select msg
    Case #WM_NOTIFY
      *nmh.NMHEADER = lparam
      If *nmh\hdr\code = #HDN_ITEMCLICK 
        Debug "Column " + Str(*nmh\iitem)+ " clicked"
      EndIf
  EndSelect
  ProcedureReturn result
EndProcedure

winflags = #PB_Window_ScreenCentered|#PB_Window_SystemMenu
winflags |#PB_Window_SizeGadget|#PB_Window_MinimizeGadget
OpenWindow(0,0,0,640,480,"", winflags)
TempColWidth.i = 130
ListIconGadget(#MW_English_Basestock_Table, 5, 25, 990, 200, "Roll #", 70 , #PB_ListIcon_CheckBoxes|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
SetGadgetColor(#MW_English_Basestock_Table, #PB_Gadget_BackColor, RGB(222, 250, 251))
GadgetToolTip(#MW_English_Basestock_Table, "Basestock List in English Units")
AddGadgetColumn(#MW_English_Basestock_Table, 1, "Lineal Feet", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 2, "Weight", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 3, "Caliper", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 4, "Basis Weight", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 5, "Width", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 6, "Roll Diameter", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 7, "Core Diameter", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 8, "Outer Laps", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 9, "Waste Diameter", TempColWidth)
AddGadgetColumn(#MW_English_Basestock_Table, 10, "LF Available", TempColWidth)


SetWindowCallback(@WinProc() )

Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
BERESHEIT
vwchest@va.tds.net
New User
New User
Posts: 7
Joined: Wed Oct 21, 2009 11:31 pm

Re: Determining which column header clicked in a ListIconGad

Post by vwchest@va.tds.net »

Thanks netmaestro,
The debug window pops up and shows me what column was clicked. How can I extract from which gadget the column was clicked as well. I will have other ListIconGadgets that I need to determine the column chosen as well.

Wayne C
Purebasic v4.50 (x86)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Determining which column header clicked in a ListIconGad

Post by netmaestro »

Code: Select all

    Case #WM_NOTIFY
      *nmh.NMHEADER = lparam
      If *nmh\hdr\code = #HDN_ITEMCLICK 
        Debug "Column " + Str(*nmh\iitem)+ " clicked in gadget #: "+Str(GetDlgCtrlID_(GetParent_(*nmh\hdr\hwndFrom)))
      EndIf
BERESHEIT
vwchest@va.tds.net
New User
New User
Posts: 7
Joined: Wed Oct 21, 2009 11:31 pm

Re: Determining which column header clicked in a ListIconGad

Post by vwchest@va.tds.net »

Thanks again,
You're a true guru
Post Reply