In a larger program I ran into this problem - editing a TreeView item results in at %WM_Command/%IDOK notification.
In this example, I enter edit mode in the TreeView (triple click on something) and then press a key, such as "a".
The msgbox pops up showing that I got a %WM_Command/%IDOK notification.
Why would that be?
In this example, I enter edit mode in the TreeView (triple click on something) and then press a key, such as "a".
The msgbox pops up showing that I got a %WM_Command/%IDOK notification.
Why would that be?
Code:
#Compile Exe #Dim All #Include "Win32api.inc" #Include "commctrl.inc" %ID_TreeView = 100 Function PBMain() As Long Local hDlg As Dword, hItem As Dword Local hTemp As Dword, hTemp2 As Dword, hTemp3 As Dword Dialog New Pixels, 0, "TreeView",200,200,155,250, %WS_SysMenu, 0 To hDlg Control Add Treeview, hDlg, 100, "", 10,10,130,200, _ %WS_Child Or %WS_Visible Or %WS_TabStop Or %TVS_HasButtons Or _ %TVS_HasLines Or %TVS_LinesAtRoot Or %TVS_EditLabels Or _ %TVS_ShowSelAlways Or %TVS_TrackSelect Or %TVS_InfoTip, _ %WS_Ex_ClientEdge Or %WS_Ex_StaticEdge Or %WS_Ex_DlgModalFrame Or _ %WS_Ex_AcceptFiles Or %WS_Ex_Left Or %WS_Ex_LtrReading Or _ %WS_Ex_RightScrollbar Treeview Insert Item hDlg, 100, 0, %TVI_Last, 2,2,"Top" To hItem Treeview Insert Item hDlg, 100, hItem, %TVI_Last, 2,4,"Mother" To hTemp Treeview Insert Item hDlg, 100, hTemp, %TVI_Last, 2,4,"Dan" To hTemp2 Treeview Insert Item hDlg, 100, hTemp, %TVI_Last, 1,4,"Bob" To hTemp3 Treeview Insert Item hDlg, 100, hTemp3, %TVI_Last, 2,4,"Foot" To hTemp2 Treeview Insert Item hDlg, 100, hTemp3, %TVI_Last, 1,4,"Arm" To hTemp2 Treeview Insert Item hDlg, 100, hItem, %TVI_Last, 1,4,"Father" To hTemp Treeview Insert Item hDlg, 100, hTemp, %TVI_Last, 2,4,"Helen" To hTemp2 Treeview Insert Item hDlg, 100, hTemp, %TVI_Last, 1,4,"Amy" To hTemp3 Treeview Insert Item hDlg, 100, hTemp3, %TVI_Last, 2,4,"Leg" To hTemp2 Treeview Insert Item hDlg, 100, hTemp3, %TVI_Last, 1,4,"Finger" To hTemp2 Control Add Button, hDlg, 200, "Walk", 10,220,40,20 Control Add Label, hDlg, 300, "<node>", 70,220,50,20, %WS_Border Dialog Show Modal hDlg Call DlgProc End Function CallBack Function DlgProc() As Long Dim hTree As Dword, hUpNode As Dword, hTVEdit As Dword, temp$, temp2$ Static hNode As Dword If Cb.Msg = %WM_Command And Cb.Ctl = 200 Then If hNode = 0 Then Treeview Get Select Cb.Hndl, %ID_TreeView To hNode End If If Cb.Msg = %WM_Command And Cb.Ctl = %IdOk Then MsgBox "ok button" End If If Cb.Msg = %WM_Notify And Cb.Ctl = 200 Then Select Case Cb.NmCode Case %TVN_BeginLabelEdit Control Handle Cb.Hndl, 200 To hTree hTVEdit = Treeview_GetEditControl(hTree) 'handle of TreeView edit control Control Get Text Cb.Hndl, GetDlgCtrlID(hTVEdit) To temp$ 'get original text Control Send Cb.Hndl, GetDlgCtrlID(hTVEdit), %EM_LIMITTEXT, 25, 0 '25 char max Case %TVN_EndLabelEdit hTVEdit = Treeview_GetEditControl(hTree) 'handle of TreeView edit control Control Get Text Cb.Hndl, GetDlgCtrlID(hTVEdit) To temp2$ 'get new text Function = 1 '1=new text 0=original text End Select End If End Function
Comment