Date: 02-16-2022
Return to Index
created by gbSnippets
'Often the lParam/wParam message arguments are pointers to a structure
'where the structure varies with the message involved. Here's how to
'use structures, depending on whether the structure is sent with the
'message or returned by the message.
'Primary Code:
'When a structure is returned by a message:
Local lpTV As NM_TREEVIEW PTR 'define variable as pointer to a structure
lptv = CB.lParam 'set variable = to the message argument (wparam or lparam)
hTemp = @lpTV.ItemNew.hItem 'access elements of the structure
'Compilable Example: (Jose Includes)
'This example uses a pointer to get the handle and text of the item that has
'been expanded in a TreeView Control. A pointer to a structure is returned
'by the message in the lParam argument.
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Include "CommCtrl.inc"
%IDC_TreeView = 100
Global hDlg As DWord, hTree as DWord, hItem As DWord, hTemp As DWord
Function PBMain() As Long
Dialog New Pixels, 0, "TreeView",200,200,155,250, %WS_SysMenu, 0 To hDlg
Control Add TreeView, hDlg, %IDC_TreeView, "", 10,10,130,180
TreeView Insert Item hDlg, %IDC_TreeView, 0, %TVI_Last, 0,0,"Root" To hItem
TreeView Insert Item hDlg, %IDC_TreeView, hItem, %TVI_Last, 0,0,"Mother" To hTemp
TreeView Insert Item hDlg, %IDC_TreeView, hItem, %TVI_Last, 0,0,"Father" To hTemp
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc () as Long
Select Case CB.Msg
Case %WM_Notify
Select Case CB.NmID
Case %IDC_TreeView
Select Case CB.Nmcode
Case %TVN_ItemExpanded
Local lpTV As NM_TREEVIEW PTR, temp$, hTemp as DWord
lptv = CB.lParam
hTemp = @lpTV.ItemNew.hItem 'get handle of selected item
TreeView Get Text hDlg, %IDC_TreeView, hTemp To temp$ 'use handled to get Text
MsgBox temp$
End Select
End Select
End Select
End Function
'gbs_00078
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm