1. RE: Treeview w/Edit-Labels
- Posted by Derek Parnell <Derek.Parnell at SYD.RABOBANK.COM> Jun 19, 2002
- 411 views
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C217D9.0BF2D180 charset=iso-8859-1 > -----Original Message----- > From: euman at bellsouth.net [mailto:euman at bellsouth.net] > Subject: Re: Treeview w/Edit-Labels > > > > Correct Chris, > the latest beta version of Win32lib is required. > Version: 0.57.8 17/June/2002 > dont forget sequence tvitem_handle in Win32lib.ew > will need to be set as global. > Maybe Derek will update all the handle housekeeping > to be global? > No I won't be doing that. I really want to eliminate global variables from the library. However, I've already come to your aid because getHandle() can now get a TV Item's handle. tvih = getHandle( {TV, index} ) ----------- Derek. ================================================================== De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en de afzender direct te informeren door het bericht te retourneren. ================================================================== The information contained in this message may be confidential and is intended to be exclusively for the addressee. Should you receive this message unintentionally, please do not use the contents herein and notify the sender immediately by return e-mail. ================================================================== ------_=_NextPart_000_01C217D9.0BF2D180 Content-Type: application/ms-tnef
2. RE: Treeview w/Edit-Labels
- Posted by Derek Parnell <Derek.Parnell at SYD.RABOBANK.COM> Jun 19, 2002
- 412 views
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C217DF.74424080 charset=iso-8859-1 Euman, I've completed your demo to enable it to save the text okay. I'm now updating it to edit existing text. I have to go to a meeting now so I'll get back later today with the update. --------- Derek. ================================================================== De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en de afzender direct te informeren door het bericht te retourneren. ================================================================== The information contained in this message may be confidential and is intended to be exclusively for the addressee. Should you receive this message unintentionally, please do not use the contents herein and notify the sender immediately by return e-mail. ================================================================== ------_=_NextPart_000_01C217DF.74424080 Content-Type: application/ms-tnef
3. RE: Treeview w/Edit-Labels
- Posted by Derek Parnell <Derek.Parnell at SYD.RABOBANK.COM> Jun 20, 2002
- 411 views
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C21837.C06F9040 charset=iso-8859-1 > even still, this problem is alot easier solved if done in API... > atleast I dont have to travel around the world to party with > my next door neighbor. Look, if you think Win32lib is overkill for your system then use something else and get over it. I have consistantly said that Win32lib is not the fastest way of executing Windows code. But it isn't trying to be. I hope that people find it easier than raw API to code with, that's all. > Windows creates the Edit control and I retrieve the handle to > this edit control > now I must process the edit control via subclassing. I dont > suppose you have a > one word command for this do ya Derek? Firstly, you don't *HAVE TO* subclass the edit control if you don't want to. That is your choice. Windows doesn't force you to. Secondly, yes I do have a one word command for this. I've just added this bit of code the library... --------------------- global function subClassControl(object pId, atom phWnd) integer lNewId integer lParent integer lControlType if phWnd = 0 then return 0 end if if sequence(pId) then lControlType = pId[1] lParent = pId[2] if getId(phWnd) != 0 or -- hWnd already has an ID phWnd = getHandle(lParent) or -- is its own parent lControlType < 1 or -- invalid control class lControlType > NumClasses then return 0 end if lNewId = NewControl(lControlType, lParent) else lNewId = pId end if setId( phWnd, lNewId ) -- Set up data for child control window_handle[lNewId] = phWnd window_handle_type[lNewId] = kht_Window window_func[lNewId] = w32Func( xSetWindowLong, { phWnd, GWL_WndProc, SubProcAddress } ) return lNewId end function ---------------- and with this one can write ... tvEditor = subClassControl( {EditText, myWindow}, tvhWnd) and then all the win32lib functionality comes into existance for this new control. Also, to make live a bit easier than having to make global the library's varaibles, you can replace the existing routine "getId" with... global function getId( object hWnd ) if sequence(hWnd) then return find( hWnd[2], tvitem_handle ) else return w32Func( xGetWindowLong, { hWnd, GWL_USERDATA } ) end if end function and now you can get a TV Item's ID if you know its handle. TVI = getId ( {hWndTVI} ) --------------- Now with these small mods to the library, here is your example reworked... -------------------------------------- -- tvedit.exw Version 1.0 -- Author: Euman 20/June/2002 -- This demonstrates how to edit the text of a treeview item. include win32lib.ew object VOID integer MainWin, HelpText, TV, TVPopup, MI_AddItem, MI_Rename, MI_AddChild, Edit_Id atom closefolder, openfolder sequence folders integer vEditSource vEditSource = -1 integer vNewCount vNewCount = 0 -------------------------------- function TVBeginEdit(integer id, atom hWnd, atom wParam, atom lParam) -------------------------------- atom hWnd_Edit hWnd_Edit = w32Func( xSendMessage, {getHandle(TV), TVM_GETEDITCONTROL, 0, 0 } ) Edit_Id = subClassControl({EditText, MainWin}, hWnd_Edit) if vEditSource = 1 then setWindowBackColor(Edit_Id, BrightCyan) vNewCount += 1 setText(Edit_Id, sprintf("New Item Text %d", vNewCount)) elsif vEditSource = 0 then setWindowBackColor(Edit_Id, Yellow) elsif vEditSource = 2 then setWindowBackColor(Edit_Id, BrightGreen) elsif vEditSource = 3 then setWindowBackColor(Edit_Id, Parchment) vNewCount += 1 setText(Edit_Id, sprintf("New Child Text %d", vNewCount)) end if setFocus(Edit_Id) return {kReturnNow} end function -------------------------------- function TVEndEdit(integer id, atom hWnd, atom wParam, atom lParam) -------------------------------- object lNewText integer lRC integer lTVI lNewText = fetch(lParam, TVDISPINFO_TVITEMpszText) if sequence(lNewText) then lRC = True lTVI = getId( {TV, fetch( lParam, TVDISPINFO_TVITEMhItem )} ) setTVText(lTVI, lNewText) else lRC = False end if vEditSource = -1 return {kReturnNow, lRC} end function -------------------------------- procedure Mouse_TV(integer self, integer event, sequence parms) -------------------------------- integer index if parms[1] = WM_RBUTTONDOWN then popup(TVPopup, parms[2]-10, parms[3] ) end if end procedure -------------------------------- procedure Click_MI_AddItem(integer self, integer event, sequence parms ) -------------------------------- integer index integer lParent lParent = getTVParent( getIndex(TV) ) folders &= addTVItem( TV, closefolder, openfolder, "", lParent ) index = folders[length(folders)] vEditSource = 1 VOID = w32Func( xSendMessage, {getHandle(TV), TVM_EDITLABEL, 0, getHandle({TV,index}) } ) end procedure -------------------------------- procedure Click_MI_AddChild(integer self, integer event, sequence parms ) -------------------------------- integer index integer lParent lParent = getIndex(TV) folders &= addTVItem( TV, closefolder, openfolder, "", lParent ) index = folders[length(folders)] expandItem( lParent ) vEditSource = 3 VOID = w32Func( xSendMessage, {getHandle(TV), TVM_EDITLABEL, 0, getHandle({TV,index}) } ) end procedure -------------------------------- procedure Click_MI_Rename(integer self, integer event, sequence parms ) -------------------------------- integer index index = getIndex(TV) vEditSource = 2 VOID = w32Func( xSendMessage, {getHandle(TV), TVM_EDITLABEL, 0, getHandle({TV,index}) } ) end procedure -------------------------------- procedure KeyDown_TV(integer self, integer event, sequence parms ) -------------------------------- integer index if find(parms[1],{VK_RETURN,VK_F2}) = 0 or parms[2] != 0 then return end if index = getIndex(TV) vEditSource = 0 VOID = w32Func( xSendMessage, {getHandle(TV), TVM_EDITLABEL, 0, getHandle({TV,index}) } ) end procedure ------------------------------------------------ procedure Activate_MainWin(integer self, integer event, sequence parms) ------------------------------------------------ expandItem( folders[1] ) end procedure ------------------------------------------------ -- Application Initiation ------------------------------------------------ function AppInit() integer lRC lRC = 0 Edit_Id = -1 closefolder = addIcon( extractIcon( "clsdfold.ico" )) openfolder = addIcon( extractIcon( "openfold.ico" )) MainWin = create( Window, "Treeview Edit Label Demo", 0, 1, 1, 492, 380, { WS_DLGFRAME, WS_SYSMENU}) HelpText = create( LText, "", MainWin, 5, 5, 400, 50, 0) setText(HelpText, "You can edit an item by pressing RETURN or F2\n" & "Press the Right Mouse Button for extra options") TV = create(TreeView, "TreeView", MainWin, 10, 55, 464, 260, or_all({TVS_HASLINES,TVS_LINESATROOT,TVS_HASBUTTONS,TVS_EDITLABELS, TVS_SHOWSELALWAYS}) ) folders = {} folders &= addTVItem( TV, closefolder, openfolder, "Root Item" , 0 ) folders &= addTVItem( TV, closefolder, openfolder, "Item One" , folders[1] ) TVPopup = create( Popup, "", TV, 0, 0, 0, 0, 0 ) MI_AddItem = create( MenuItem, "New Item", TVPopup, 0, 0, 0, 0, 0 ) MI_AddChild = create( MenuItem, "New Child", TVPopup, 0, 0, 0, 0, 0 ) MI_Rename = create( MenuItem, "Rename", TVPopup, 0, 0, 0, 0, 0 ) setHandler(MainWin, w32HActivate, routine_id("Activate_MainWin")) setHandler(TV, w32HMouse, routine_id("Mouse_TV")) setHandler(MI_AddItem, w32HClick, routine_id("Click_MI_AddItem")) setHandler(MI_AddChild, w32HClick, routine_id("Click_MI_AddChild")) setHandler(MI_Rename, w32HClick, routine_id("Click_MI_Rename")) setHandler(TV, w32HKeyDown,routine_id("KeyDown_TV")) VOID = setNotifyHandler( TVN_BEGINLABELEDIT, routine_id("TVBeginEdit")) VOID = setNotifyHandler( TVN_ENDLABELEDIT, routine_id("TVEndEdit")) return lRC end function if AppInit() = 0 then WinMain( MainWin, Normal) end if -------------------- anyhow, have fun with this. cheers, Derek. ================================================================== De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en de afzender direct te informeren door het bericht te retourneren. ================================================================== The information contained in this message may be confidential and is intended to be exclusively for the addressee. Should you receive this message unintentionally, please do not use the contents herein and notify the sender immediately by return e-mail. ================================================================== ------_=_NextPart_000_01C21837.C06F9040 Content-Type: application/ms-tnef
4. RE: Treeview w/Edit-Labels
- Posted by jordah ferguson <jorfergie03 at yahoo.com> Jun 22, 2002
- 428 views
I was just creating a Tutorial for Editting treeview labels but for some reason every time i press a key the Edit Control Loses Focus. Any help available, jordah ferguson Derek Parnell wrote: > > -----Original Message----- > > From: euman at bellsouth.net [mailto:euman at bellsouth.net] > > Sent: Thursday, 20 June 2002 5:41 > > To: EUforum > > Subject: Re: Treeview w/Edit-Labels > > > > > > Correct Chris, > > the latest beta version of Win32lib is required. > > Version: 0.57.8 17/June/2002 > > dont forget sequence tvitem_handle in Win32lib.ew > > will need to be set as global. > > Maybe Derek will update all the handle housekeeping > > to be global? > > > No I won't be doing that. I really want to eliminate global variables > from > the library. > > However, I've already come to your aid because getHandle() can now get a > TV > Item's handle. > > tvih = getHandle( {TV, index} ) > > ----------- > Derek. > > ================================================================== > > > ================================================================== > >