Subclassing TreeView

I created a class derived from a TreeView (ShellTree) that displays the 
Shell directory structure . I changed the LeftView class so that it is 
derived from my ShellTree class, and everything works as expected, except I 
cannot add any TreeView specific message handlers to my LeftView class any 
more eg. NM_DBLCLICK.  Basically in a nutshell what i want to do is display 
the directory name (which is stored in a variable in the ShellTree class) 
when the LeftView is Double clicked 


0
5/21/2005 11:36:24 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
886 Views

Similar Articles

[PageSpeed] 8

Check out http://www.codeproject.com/treectrl/enumdeskclones.asp

Which isn't perfect.. but is a good start.

    Rail
-- 
      Recording Engineer/Software Developer
      Rail Jon Rogut Software
      http://www.railjonrogut.com
      mailto:rail@railjonrogut.com

"abe froman" <cracker1234@optonline.net> wrote in message 
news:UBPje.22120$Ee6.12154@fe12.lga...
>I created a class derived from a TreeView (ShellTree) that displays the 
>Shell directory structure . I changed the LeftView class so that it is 
>derived from my ShellTree class, and everything works as expected, except I 
>cannot add any TreeView specific message handlers to my LeftView class any 
>more eg. NM_DBLCLICK.  Basically in a nutshell what i want to do is display 
>the directory name (which is stored in a variable in the ShellTree class) 
>when the LeftView is Double clicked
> 


0
railro (128)
5/21/2005 11:41:13 PM
Actually the way i asked my question wasn't very clear. I see that now as I 
read it again. When you create a Windows Explorer style  MFC app wizard 
application, it creates a LeftView class which is derived from CTreeView, so 
you can add TreeView specific message handlers to that class.  I changed my 
LeftView class to derive from my own new class (ShellTree) which itself is 
derived from CTreeView, but now I can no longer add TreeView specific 
message handlers to my LeftView class via class wizard anymore.


"Rail Jon Rogut" <railro@earthlink.net> wrote in message 
news:tGPje.8443$w21.6810@newsread3.news.atl.earthlink.net...
> Check out http://www.codeproject.com/treectrl/enumdeskclones.asp
>
> Which isn't perfect.. but is a good start.
>
>    Rail
> -- 
>      Recording Engineer/Software Developer
>      Rail Jon Rogut Software
>      http://www.railjonrogut.com
>      mailto:rail@railjonrogut.com
>
> "abe froman" <cracker1234@optonline.net> wrote in message 
> news:UBPje.22120$Ee6.12154@fe12.lga...
>>I created a class derived from a TreeView (ShellTree) that displays the 
>>Shell directory structure . I changed the LeftView class so that it is 
>>derived from my ShellTree class, and everything works as expected, except 
>>I cannot add any TreeView specific message handlers to my LeftView class 
>>any more eg. NM_DBLCLICK.  Basically in a nutshell what i want to do is 
>>display the directory name (which is stored in a variable in the ShellTree 
>>class) when the LeftView is Double clicked
>>
>
> 


0
5/22/2005 1:31:13 AM
Reply:

Similar Artilces:

Subclassing
Hello, Im very new to c++ programming so pardon me if this is a dumb question and my bad english. I made a subclass from CListBox. I want to handle all the list controls derived from this class on one function, for example, void CListBox_SC::OnRButtonUp(UINT nFlags, CPoint point) { ..... } on this function I want to manage the OnRButtonUp event, and with a switch or if statement, select the code to execute. The following does work: SetCurSel(ItemFromPoint(point, ifp)); but the following comparison is never true, (IDC_LST_TIPO is a resource for one of the ListBoxes) UINT currLst = It...

Custom Drawing CEdit : Subclassing
Hello experts, My objective is simple, but I'm not entirely sure what needs tweaking. I am using MSVC 6, and I would like to subclass the CEdit box so that it appears as the color-picker editbox of a PropertyGrid. There is a color box followed by three values. Like this: [###] 255; 192; 192 Where ### is just a color box representation of the value. So thus far, I've made a masked CEdit box, where I can edit the numbers (or click a button that visually sets the numbers from a different window), and I'm happy with that - but what I would like to do next is to subclass the dra...

Help with subclassing a RichEditCtrl
Hi folks, I could use some help. As a side project I am trying to write a DLL that will extend the functionality of an existing application that I do not have source code for, i.e., some autocompletion functionality, word lookup, etc. In the actual DLL, I am going to have to inject it into the existing app and then use FindWindow or something like that to subclass the existing RichEditCtrl. I need to be able to process the WM_CHAR and WM_KEYDOWN messages only. I started out by creating my own sample project using a RichEditCtrl in my project to code my object. I've now moved everythin...

Treeview
Hello Friends I add some values to my treeview, but now I want to write the selected value in a EDIT BOX, how can I do this ? is in the item bellow correct ? but what the command to get the value of selected item ? Regards Leandro void CTeste1Dlg::OnTvnItemexpandedTree1(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); // TODO: Add your control notification handler code here *pResult = 0; CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE1); ASSERT(pCtrl != NULL); SetDlgItemText(IDC_EDIT1,??); } Look in the help! I would...

WM_CREATE for a subclass
Hi All, I am fairly new to C++, although I have developed OO windows applications in the past using CTD and Power Builder. I am developeing an edit class based on a CEdit. I am trying to trap the WM_CREATE message to modify the style of the window (i.e. to make is multiline). For some reason the control does not appear to be getting the WM_CREATE message ( or at least it is not implementing the handler I have for it). At present I create an edit control on a form and the Subclass the edit. This appears to work as my user defined menu is used and my color modifications appear as requir...

Subclassing CWinThread
I created a subclass of CWinThread - no big deal! Now, what I would like to do is use that subclass as a base class for a couple of other, more specialized classes. How can I do this? If I create a subclass as a generic C++ class, then I'm running into the assertion, "Invalid Address specified to RtlValidateHeap( 00940000, 0042DBA0 )" when I post the quit message to the thread. I assume this might have something to do with the virtual/non-virtual constructor combination of the MFC class and the generic C++ class. Any thoughts? Create more subclasses of CWinThread, then ...

Subclassing TreeView
I created a class derived from a TreeView (ShellTree) that displays the Shell directory structure . I changed the LeftView class so that it is derived from my ShellTree class, and everything works as expected, except I cannot add any TreeView specific message handlers to my LeftView class any more eg. NM_DBLCLICK. Basically in a nutshell what i want to do is display the directory name (which is stored in a variable in the ShellTree class) when the LeftView is Double clicked Check out http://www.codeproject.com/treectrl/enumdeskclones.asp Which isn't perfect.. but is a good star...

Subclassing a subclass of CDialog, for cross-platform compilation
Hi people, I've been working on porting an app from PC to Mac. What I'm trying to do, is separate out the PC specific components into it's own subclass. So there are the PC specific functions like PCAppDlg::OnBtnClicked1, and mac specific functions like MacAppDlg::BlaBlaBla. Of course the Mac subclass doesn't compile on the PC, and the same the other way around. I've had to write my own CDialog wrapper for Mac but that's another story. Now anyhow, this leads me to a question. How to subclass a subclass? Specifically, how does the message maps work? Will there be any p...

Xml Serializing subclass problem
Hi guys. I've come across a problem when I tried to serialize a class into xml, only to discover that the parent class's XML Serialization properties weren't included in the output xml. Actually, the class I'm serializing is two steps down in the inheritance ladder. It's got a parent class which also has a parent class :( All those classes in the hierarchy are Xml Serializable, and I'd think that it should be obvious that all attributes/properties of the parents should be serialized for any given subclass, no ? Here's the two classes, subclass first, parent class...

Subclassing problem???
Hi there, I've got: LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ switch(uMsg){ case WM_NCACTIVATE: if((BOOL)wParam==FALSE){ DefWindowProc(hwnd, uMsg, wParam, lParam); CreateText(hwnd); return TRUE; } case WM_NCPAINT: DefWindowProc(hwnd, uMsg, wParam, lParam); CreateText(hwnd); break; } DefWindowProc(hwnd, uMsg, wParam, lParam); } void CreateText(HWND hwnd){ HDC hDC = GetWindowDC(hwnd); int x,y; RECT rc1,rc2; GetWindowRect(hwnd, (LPRECT)&rc2 ); x = GetSystemMetrics(SM_CXSIZE) + GetSystemMetrics(SM_CXBORDE...

subclassing CStatic
Hi, I have subclassed a few CStatic ctrls so i can quickly change their font, BG and FG colors etc... I have also handled the CFormView's CtlColor message and painted the form white and text blue. The problem that im having is the subclassed objects are painting themselves the colors i specify, then the CFormView::OnCtlColor is painting them again. This isnt too much of a problem as i can simply exclude the subclassed items from the painting using: HBRUSH CSmartMXEditLangView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { // create white brush: m_DlgBrush.DeleteObject(); ...

VC
I need a way to come up with a simple (free) combobox activeX control I can use in a third party development tool. I tried just subclassing ComboBoxEx using the ActiveX control wizard in VC6. It clearly creates the control, but it doesn't seem to be created with the properties and methods (like AddItem/New) and when I plop on a VB6 form it doesn't look like a combobox. Granted I am newbie working way over my head, by why would the ActiveX control wizard ask me which control to inherit from if it isn't going to give me _roughly_ the same functionality? Can anyone point me in a di...

subclassing CComboBox
compiler: VC++ 6.0 SP 6, running XP Pro SP 2. I subclassed CComboBox into CMyComboBox, then setup up event handlers for several of the reflected events -- one being CBN_CLOSEUP reflected event. I have an object of type CMyComboBox in an MFC program, which also needs to catch the CBN_CLOSEUP event. I used ClassWizard to create all event handlers. Problem: The event handler in CMyComboBox works ok, but the handler in the application program never gets called. Is there a way around this problem? I tried posting a message to the parent window but that didn't seem to work either (pare...

Moving subclasses to different classes
I'm having trouble figuring out how to move subclasses to different classes (to re-assign budget categories to differnt umbrella budget areas). I see a "MOVE" button at the bottom of the list of Classes but can't figure out how to make it active. Anyone know the secret to moving classes without deleting them, recreating them under a new high level class, and re-assigning the transactions? Thanks in Advance!! Never mind -- you just delete the class and ask it to reassign things to a new subclass bucket. PRODUCT WISHLIST: Have the "MOVE" button active...

Visio treeview diagram
I want to create a treeview diagram. Is there any easier way than building the diagram from scratch. Are there any downloads where you can get a pre-built treeview. Regards, Chris. ...

Subclassing AfxControlBar80su
I have a CDialogBar derived class which has a bitmap background texture. The parent's wndclass is AfxControlBar80su which still displays in gray. I'd like to give it the same background as the dialog bar and I thought it could be done by subclassing and handling the appropriate messages. But how can that be done? TIA, Hans Subclass CDialogBar and override OnPaint would be my first guess as to how to do it. The AfxControlBar80su is probably not relevant here. joe On Mon, 30 Jul 2007 01:16:15 +0200, Hans-J. Ude <news@hajue-ude.de> wrote: >I have a CDialogBar derived c...

subclassing a CTreeCtrl
All, I'm trying to subclass a CTreeCtrl control with a CHeaderCtrl derived class to obtain the result as in (http://users.pandora.be/bart.de.lathouwer/Untitled-1.jpg) I would subclass the CTreeCtrl derived class to be able to draw 'over' both the header and CTreeCtrl surface. When I subclass my CTreeCtrl derived class it reports that it is already attached. My Ctrl's live in a CWnd derived class. Question: What is the correct way to subclass my CTreeCtrl with my HeaderClass to be able to draw "over" both classes? If not possible what is an alternative? (apart from ...

Subclass question
Hi, I am writing an app in which I have a dialog bar (IDD_DLGBAR) at the top of the MDI frame window besides the standard toolbar. The dialog bar contains several controls. One of them is a combo box with id IDC_SEARCHBOX. I also created a class CSearchBox (derived from CComboBox) to process keyboard messages. My question is how do I link the combo box in the dialog bar with CSearchBox class so I can capture keyboard events (i.e., PreTranslateMessage)? Thanks in advance. >Hi, I am writing an app in which I have a dialog bar (IDD_DLGBAR) at the top >of the MDI frame window beside...

Subclass Help
During the desing of my app, I realized that I would need to have a combobox with a set of pre-defined values (collected from a database). This combobox will be used in many dialogs and for that, I decided to derive my own class. I want the combobox to be populated when created, but I can't figure out how to make it work with DDX. If I "create" it manually, I can do this in "OnCreate," but I'm attaching to a dialog. I don't know what gets called when DDX does the attaching. Any ideas? Thanks in advanced. Eddie. "Eddie Pazz" <drpazz@hotmail...

Treeview Node Uncheck Issue
Hey I'm trying to have all node checkboxes in a particular node group be unchecked if all of the child nodes are unchecked. I'm using the code below. All variables in the code are declared in the sub prior to this with code. When I run this and uncheck an item it gives me a run- time error: Run-time Error: --------------------------------------- Run-time error '91': Object variable or With block variable not set --------------------------------------- Code: ---------------------------------------------------- With Me.TreeView2 Set nod = .Nodes.Item(Node.Index).P...

SHBrowseForFolder Subclassing.
I would like to change the name of the "cancel" button. Is that possible with Subclassing, Superclassing, etc.? ....Bruce Maybe this article can help you: http://www.codeproject.com/dialog/browse_for_folder_dialog.asp -- Mav Rossi "Bruce Arnold" <b_a_r_n_o_l_d@b_l_a_s_t.n_e_t> ha scritto nel messaggio news:cka5tv4rf6mq086b1nf6t6gom5rgds0a33@4ax.com... > I would like to change the name of the "cancel" button. Is that > possible with Subclassing, Superclassing, etc.? > ...Bruce > > And this too: http://www.codeproject.com/dialog/browse...

Re: Subclassing
Hi All I wish to create my own control for subclassing. The control will essentially contain some simple text and some minor graphics. No real control functionality is required. The question is should I derive this new control from an existing control, say CButton, or directly from CWnd? Thanks in advance LarryM wrote: > Hi All > > I wish to create my own control for subclassing. The control will > essentially > contain some simple text and some minor graphics. No real control > functionality is required. > > The question is should I derive this new control...

Subclassing controls
Hi! I'm trying to create a custom control with custom NC area, but there's an odd problem: When I create the control using .Create(...), its all fine, but when I subclass the control, the NC messages are never sent! Anyone knows why this happens?? Tnx... >I'm trying to create a custom control with custom NC area, but there's an >odd problem: >When I create the control using .Create(...), its all fine, >but when I subclass the control, the NC messages are never sent! Which WM_NC* messages in particular? Presumably the WM_NCCREATE message won't be caught...

How to select other form's Treeview item #2
Examples: I want create new project and two Button. (Button Click: Control other program's Treeview like outlook have Folders. ) When I click button1 Outlook Express folders selected item is 'Inbox'.click button2 selected 'newsgroups.borland.com' ...

questions of subclassing
hi all I derieved a button class called cmybutton, I want to replace all button in my application with cmybutton so I use subclass but the question is, if the button is created by my resource templates, it works, but failed in other resource templates such as Message Boxs' buttons. That is, if I use AfxmessageBox to display a dialog box, the buttons in the dialog didn't display it seems the subclassing doesn't work what can I do many thanks That's because you cannot subclass messagebox buttons. Subclassing in MFC works only because it is a fiction maintained by MFC ...