Determining which column header clicked in a ListIconGadget
Posted: Sun Jul 25, 2010 11:06 pm
				
				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
			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