CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    May 2005
    Posts
    48

    C# for the C++ guy...

    Hello,

    now it happend: I have to participate in a C# project.
    I am good in C++ (worked for 6 years in C++), but I have never done anything in C# or even in VS 2005.

    The assignment is: I have to write a control which looks like a tree but has instead of the normal tree items a few cells (like a row in a grid).

    It should look something like this:



    I have a grid control which I wrote myself and in C++ I would derive a class from CTreeCtrl and use my cells as the treeitems.

    Anything like this possible in C#? Can I "import" my grid classes in C# and use them or should I start entirely from scratch?

    Perhaps someone has a few hints.

    Robin.

  2. #2
    Join Date
    Jul 2005
    Posts
    22

    Re: C# for the C++ guy...

    C# is pretty easy if you have C++ experience, you just have to learn some of the differences, such as the way you initiate arrays. You could probably use your control you wrote in C++ indeed, through InterOping/Marshalling, though I don't know much about those things yet. You might have a better time writing it from scratch, since .Net is very helpful, it'd be a breeze, nothing compared to the long and boring way of C++. Just learn about control creation and you should be well on your way.

  3. #3
    Join Date
    May 2005
    Posts
    48

    Re: C# for the C++ guy...

    Quote Originally Posted by blankdev
    You might have a better time writing it from scratch, since .Net is very helpful, it'd be a breeze, nothing compared to the long and boring way of C++. Just learn about control creation and you should be well on your way.
    ok I looked into it as your post sounded very promising, but I haven't got a clue. How can derive a class from something like CTreeCtrl (I couldn't find that is there an aquivalent)?

    Robin

  4. #4
    Join Date
    Jan 2006
    Location
    Baltimore, Maryland, USA
    Posts
    104

    Re: C# for the C++ guy...

    Quote Originally Posted by robin83
    ok I looked into it as your post sounded very promising, but I haven't got a clue. How can derive a class from something like CTreeCtrl (I couldn't find that is there an aquivalent)?

    Robin
    Just by looking at your block diagram and seeing your CTreeCtrl command, I think you should look into TreeView and ListView. I'm not sure the difference between the two, but I just started looking at TreeView. Its the basic window explorer style when displaying the directories. How would you make it like your diagram, I have no clue. Again, I just started playing with TreeView recently.
    -= the best is yet to come =-

  5. #5
    Join Date
    May 2005
    Posts
    48

    Re: C# for the C++ guy...

    ok, now I am officially clueless. The thing that makes the project even harder (for me) is the target platform: it has to run on a pocketpc.
    I tried to work with TreeView, but I could not override OnPaint. It simply gets not called. WinProc is unknown, although some examples use it. Even if I could work with OnPaint, I do not know what to do with it, as it is only provided in TreeView, not in TreeNode as I would have expected.

    I hope somebody can help?

    Robin

  6. #6
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: C# for the C++ guy...

    I'd have an owner drawn ListView (or ListBox even) and do your own drawing of each of the leaves.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  7. #7
    Join Date
    May 2005
    Posts
    48

    Re: C# for the C++ guy...

    So that is my only chance then? I have to write my own treeview control, to take care of the drawing of the nodes, correct?

  8. #8

    Re: C# for the C++ guy...

    There are quite a few examples of this kind of control about, most seem to override ListView and add the Tree functions rather than the other way around. Try TreeListView for a starting point.

  9. #9
    Join Date
    Oct 2000
    Location
    India
    Posts
    4,620

    Thumbs up Re: C# for the C++ guy...

    Hi,

    For a C++ guy moving to C#, i'd suggest GDI+ first. If u have an
    understanding of GDI+ , its quite easy to draw custom controls (owner draw).

    Its better not to mix managed code (C#) and unmanaged code (C++) as
    long as u can avoid it. The interop issues are a headache and u'll slowly
    fall into the wrong groove.

    C# has a lot of easy to use classes and for a C++ guy with a lot of
    experience like u can adapt to C# in a jiffy All Luck.
    All luck and have a great day.

    Regards,
    V.Girish

    Visit www.geocities.com/contactgirish for Source code, Tutorials, FAQs and Downloads.

  10. #10
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: C# for the C++ guy...

    I've seen folks do that type of thing w/ the .net 2.0 data grid view control.

  11. #11
    Join Date
    May 2005
    Posts
    48

    Re: C# for the C++ guy...

    Yes I think luck and a little bit of effort was all I needed.
    Yesterday night and today I wrote my one control. It needs a little bit tweaking here and there but the basics (including owner draw of the nodes!!!!) is ready!!!!

    Thanks for your help

  12. #12
    Join Date
    Mar 2007
    Posts
    69

    Re: C# for the C++ guy...

    hi,

    i realise this is an old post, but would you be able to post the code you used? i have been trying to do this for a while, and i keep hitting brick wall after brick wall

    or even just a pointer in the right direction

    cheers
    adam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured