[Custom controls] how to add your own class to the toolbox - Programmer

This is a discussion on [Custom controls] how to add your own class to the toolbox - Programmer ; Dear All, I have a class, CNewTreeCtrl (inherits from CTreeCtrl), that I want to place on my dialog in a drag-and-drop fashion like the default avaiable controls. If I add a "custom control" and then change the "class" property to ...

+ Reply to Thread
Results 1 to 17 of 17

Thread: [Custom controls] how to add your own class to the toolbox

  1. [Custom controls] how to add your own class to the toolbox

    Dear All,

    I have a class, CNewTreeCtrl (inherits from CTreeCtrl), that I want to
    place on my dialog in a drag-and-drop fashion like the
    default avaiable controls.

    If I add a "custom control" and then change the "class" property to
    CNewTreeCtrl, it does not work.

    Does somebody know a good guide for this problem?

    Thanks in advance

    -Thorsten

  2. Re: how to add your own class to the toolbox

    I've used a CEdit-derived class and done it as follows:

    Add an edit box to dialog in the usual way
    In Class Wizard, create a variable for it (Control, rather than Value)
    and select my control from the drop-down.

    Don't know if it'll work in your case, but it's worth a try.

    Paul.


  3. Re: how to add your own class to the toolbox

    Paul S. Ganney wrote:
    > I've used a CEdit-derived class and done it as follows:
    >
    > Add an edit box to dialog in the usual way
    > In Class Wizard, create a variable for it (Control, rather than Value)
    > and select my control from the drop-down.
    >
    > Don't know if it'll work in your case, but it's worth a try.


    I can't seem to find the class wizard you are referring to. Is this
    visual C++ 7.1 (my version) or something else?

    -Thorsten

  4. Re: how to add your own class to the toolbox

    In article <43ff1f4c$0$67256$157c6196
    @dreader2.cybercity.dk>, thorsten.ottosen@dezide.com
    says...

    [ ... ]

    > I can't seem to find the class wizard you are referring to. Is this
    > visual C++ 7.1 (my version) or something else?


    To get the ClassWizard, you need to upgrade to Visual
    Studio 6.0.

    Visual Studio 6.0 was only a minor upgrade over its
    predecessors, but a huge one over its successors.
    Unfortunately, the newer compilers (as opposed to the
    IDEs) really are quite a bit better.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.

  5. Re: how to add your own class to the toolbox

    Jerry Coffin wrote:
    > In article <43ff1f4c$0$67256$157c6196
    > @dreader2.cybercity.dk>, thorsten.ottosen@dezide.com
    > says...
    >
    > [ ... ]
    >
    >
    >>I can't seem to find the class wizard you are referring to. Is this
    >>visual C++ 7.1 (my version) or something else?

    >
    >
    > To get the ClassWizard, you need to upgrade to Visual
    > Studio 6.0.


    you mean downgrade?

    > Visual Studio 6.0 was only a minor upgrade over its
    > predecessors, but a huge one over its successors.
    > Unfortunately, the newer compilers (as opposed to the
    > IDEs) really are quite a bit better.


    Wow. So the newer IDE's are not backwards compatible!

    -Thorsten

  6. Re: how to add your own class to the toolbox

    In article <44007a88$0$67255$157c6196
    @dreader2.cybercity.dk>, thorsten.ottosen@dezide.com
    says...
    > Jerry Coffin wrote:
    > > In article <43ff1f4c$0$67256$157c6196
    > > @dreader2.cybercity.dk>, thorsten.ottosen@dezide.com
    > > says...
    > >
    > > [ ... ]
    > >
    > >
    > >>I can't seem to find the class wizard you are referring to. Is this
    > >>visual C++ 7.1 (my version) or something else?

    > >
    > >
    > > To get the ClassWizard, you need to upgrade to Visual
    > > Studio 6.0.

    >
    > you mean downgrade?


    No -- I mean upgrade. The newer versions are _newer_, but
    they're not even close to as good -- so even though it's
    older, it's still an upgrade.

    > > Visual Studio 6.0 was only a minor upgrade over its
    > > predecessors, but a huge one over its successors.
    > > Unfortunately, the newer compilers (as opposed to the
    > > IDEs) really are quite a bit better.

    >
    > Wow. So the newer IDE's are not backwards compatible!


    No. There have been quite a few threads about it in the
    past, and one of the most telling comments I've seen was
    when one of the advocates of newer IDEs said something
    like "I know VS 6 automated that, but you can get used to
    doing it by hand."

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.

  7. Re: how to add your own class to the toolbox

    On Sat, 25 Feb 2006 09:52:58 -0700, Jerry Coffin
    wrote:

    >> Wow. So the newer IDE's are not backwards compatible!

    >
    >No. There have been quite a few threads about it in the
    >past, and one of the most telling comments I've seen was
    >when one of the advocates of newer IDEs said something
    >like "I know VS 6 automated that, but you can get used to
    >doing it by hand."


    I wish there was a way to run the 7.1 compiler throught the 6.0 IDE.
    Um, is there? :-)

    I suggest that Micro$oft makes an extraordinary fortune on books
    (Microsoft Press) and the licensing of books from other publishers.

    I once read an interview with Gates where he stated it was vitally
    important to keep programmers interested in their products by
    constantly changing them, otherwise they might get bored and move to
    other things. I often wonder if this is actually true.

    "To perceive is to suffer." - Aristotle.

  8. Re: how to add your own class to the toolbox

    In article ,
    JustBoo@BooWho.com says...

    [ ... ]

    > I wish there was a way to run the 7.1 compiler throught the 6.0 IDE.
    > Um, is there? :-)


    Yes, there is -- in the IDE, you go to Tools -> Options
    -> Directories tab and then select "executable files" in
    the "show directories for" drop down. Add the directory
    for the newer compiler ahead of the VS 6 directories, and
    you'll get the newer compiler.

    This has a major problem though: the newer compilers
    produce debugging information in a format that's
    incompatible with VS 6's debugger, so it kills your
    ability to debug your code inside the IDE.

    One way to work around that is to install WinDebug and
    use that instead -- your IDE isn't quite as integrated
    anymore, it it works reasonably well nonetheless.

    Another possibility is to use the Intel compiler instead.
    Intel supports newer compilers with older IDEs. This is a
    considerably more expensive option though...

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.

  9. Re: how to add your own class to the toolbox

    I've been programming for some time in VC++7.1, and have recently been
    switching back to eVC3.0 which is very much like VC++6.0 - it has the Class
    Wizard, etc.

    I find it much easier to work with 7.1 -- the Class Wizard has been replaced
    by the Properties tab, which is MUCH more powerful. Everything that was
    done with Class Wizard is still there - it's just been moved around.

    Yes, it does take time to get used to it. I didn't like it at first either.

    --
    ---------------------------------------------------------------------
    DataGet® & PocketLog® www.dataget.com
    Data Collectors www.baxcode.com
    --------------------------------------------------------------------



    "Jerry Coffin" wrote in message
    news:MPG.1e6a391455df8ac99896ab@news.sunsite.dk...
    > In article <44007a88$0$67255$157c6196
    > @dreader2.cybercity.dk>, thorsten.ottosen@dezide.com
    > says...
    > > Jerry Coffin wrote:
    > > > In article <43ff1f4c$0$67256$157c6196
    > > > @dreader2.cybercity.dk>, thorsten.ottosen@dezide.com
    > > > says...
    > > >
    > > > [ ... ]
    > > >
    > > >
    > > >>I can't seem to find the class wizard you are referring to. Is this
    > > >>visual C++ 7.1 (my version) or something else?
    > > >
    > > >
    > > > To get the ClassWizard, you need to upgrade to Visual
    > > > Studio 6.0.

    > >
    > > you mean downgrade?

    >
    > No -- I mean upgrade. The newer versions are _newer_, but
    > they're not even close to as good -- so even though it's
    > older, it's still an upgrade.
    >
    > > > Visual Studio 6.0 was only a minor upgrade over its
    > > > predecessors, but a huge one over its successors.
    > > > Unfortunately, the newer compilers (as opposed to the
    > > > IDEs) really are quite a bit better.

    > >
    > > Wow. So the newer IDE's are not backwards compatible!

    >
    > No. There have been quite a few threads about it in the
    > past, and one of the most telling comments I've seen was
    > when one of the advocates of newer IDEs said something
    > like "I know VS 6 automated that, but you can get used to
    > doing it by hand."
    >
    > --
    > Later,
    > Jerry.
    >
    > The universe is a figment of its own imagination.




  10. Re: how to add your own class to the toolbox

    Do a right-click on the edit box and select "Add Variable". For "Variable
    Type", you can type in the name of your class instead of selecting one of
    the predefined classes.

    --
    ---------------------------------------------------------------------
    DataGet® & PocketLog® www.dataget.com
    Data Collectors www.baxcode.com
    --------------------------------------------------------------------



    "Thorsten Ottosen" wrote in message
    news:43ff1f4c$0$67256$157c6196@dreader2.cybercity. dk...
    > Paul S. Ganney wrote:
    > > I've used a CEdit-derived class and done it as follows:
    > >
    > > Add an edit box to dialog in the usual way
    > > In Class Wizard, create a variable for it (Control, rather than Value)
    > > and select my control from the drop-down.
    > >
    > > Don't know if it'll work in your case, but it's worth a try.

    >
    > I can't seem to find the class wizard you are referring to. Is this
    > visual C++ 7.1 (my version) or something else?
    >
    > -Thorsten




  11. Re: how to add your own class to the toolbox

    In article <1207ktvgdq66q71@corp.supernews.com>,
    lbax02.spamguard@baxcode.com says...

    [ ... ]

    > I find it much easier to work with 7.1


    I'm very glad for you.

    > -- the Class Wizard has been replaced
    > by the Properties tab, which is MUCH more powerful.


    Simply shouting "MUCH" doesn't add much. Please describe
    in concrete terms how the properties tab actually helps
    me get things done faster than the ClassWizard and
    property sheets did. So far, I've repeatedly attempted to
    find even one thing it does better, and failed utterly in
    doing so.

    > Everything that was
    > done with Class Wizard is still there - it's just been moved around.


    Would that this were true, but as far as I can tell, it's
    just not true. I've tried repeatedly too -- I'd dearly
    love to be able to use the newer IDEs, because the old
    compiler truly sucks compared to the newer ones.

    > Yes, it does take time to get used to it. I didn't like it at first either.


    Let me describe only one item I've tried (over and over)
    to figure out how to do with the newer IDEs. If
    frequently write trivial little front-ends to allow
    browsing (and occasionally editing) records from a SQL
    database. In VC++ 6, I start by telling it I want to do a
    database app, and tell it the ODBC connection to the
    database. In case you haven't done this, the application
    is basically a form view -- i.e. you have a dialog
    template to work with. You put controls (most often edit
    controls) to display data from fields.

    Up to this point, the VC++ 6 is basically similar to the
    newer versions. The difference arises after we've put a
    control onto our dialog. We now do a control-click on it
    to connect it to a variable. In VC++ 6.0, we get almost
    the same dialog we'd get if it wasn't a database
    application. The difference is that where we'd usually
    enter the variable name, we now have a drop-down list
    box. The list that drops down has the fields in the
    database we selected. Pick a field, and it generates all
    the code to connect that edit (or whatever) control
    through to the data from the database.

    The newer versions don't do that though -- the dialog
    they pop up is just like the one they pop up for non-
    database applications, so I have to type in a variable
    name instead of selecting one from a list, so I have to
    separately look up the database fields. Unfortunately,
    even that turns out to do no good. The database field
    variables are actually members of the RecordSet instead
    of the view, so from the view we refer to them like
    m_pSet->FieldName. If we try to enter that into the
    dialog by hand, the braindead versions of VC++ kindly
    inform us that it's invalid -- even though it's not only
    valid, but necessary.

    VS 6.0 assists us to do the job quickly, easily and
    accurately. About the only thing we might have to do by
    hand is adding a length if we're working with fields over
    255 characters in length. For quite a few jobs, however,
    even Access makes this harder than VS 6 -- and so far,
    I've yet to hear a hint of how to do it nearly as
    quickly, easily, or accurately with VS 7.x (or 8.0, for
    that matter).

    This is only one small example, but so far, in literally
    years of hearing people talk about how the newer IDEs
    really are just as good, I've yet to hear even on person
    describe how to do this job nearly as easily with them.
    If you can change that, I'm glad to hear it -- that
    leaves only about 9999 other things to deal with, and I
    can finally start using a newer compiler...

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.

  12. Re: how to add your own class to the toolbox


    > Let me describe only one item I've tried (over and over)
    > to figure out how to do with the newer IDEs. If
    > frequently write trivial little front-ends to allow
    > browsing (and occasionally editing) records from a SQL
    > database. In VC++ 6, I start by telling it I want to do a
    > database app, and tell it the ODBC connection to the
    > database. In case you haven't done this, the application
    > is basically a form view -- i.e. you have a dialog
    > template to work with. You put controls (most often edit
    > controls) to display data from fields.
    >
    > Up to this point, the VC++ 6 is basically similar to the
    > newer versions. The difference arises after we've put a
    > control onto our dialog. We now do a control-click on it
    > to connect it to a variable. In VC++ 6.0, we get almost
    > the same dialog we'd get if it wasn't a database
    > application. The difference is that where we'd usually
    > enter the variable name, we now have a drop-down list
    > box. The list that drops down has the fields in the
    > database we selected. Pick a field, and it generates all
    > the code to connect that edit (or whatever) control
    > through to the data from the database.



    I think this is only available in the Enterprise editions of VC++6.0 -- and
    not any of the lesser versions.


    >
    > The newer versions don't do that though -- the dialog
    > they pop up is just like the one they pop up for non-
    > database applications, so I have to type in a variable
    > name instead of selecting one from a list, so I have to
    > separately look up the database fields. Unfortunately,
    > even that turns out to do no good. The database field
    > variables are actually members of the RecordSet instead
    > of the view, so from the view we refer to them like
    > m_pSet->FieldName. If we try to enter that into the
    > dialog by hand, the braindead versions of VC++ kindly
    > inform us that it's invalid -- even though it's not only
    > valid, but necessary.


    You'll find that under Tools -> Connect to Database -> etc. It gives you a
    list of ALL your data connections, and their tables and all the fields
    within those tables on the "Server Explorer" pop-out tab. It also handles
    Views and Stored procedures.

    I don't make my database connections this way, so there's a lot more that I
    don't know about. I do see that a datagrid and ADO Data Control are part of
    the Toolbox.



  13. Re: how to add your own class to the toolbox

    In article <1209msb8gs06kf9@corp.supernews.com>,
    lbax02.spamguard@baxcode.com says...

    [ ... ]

    > I think this is only available in the Enterprise editions of VC++6.0 -- and
    > not any of the lesser versions.


    It works in the Professional Version for me.

    > You'll find that under Tools -> Connect to Database -> etc. It gives you a
    > list of ALL your data connections, and their tables and all the fields
    > within those tables on the "Server Explorer" pop-out tab. It also handles
    > Views and Stored procedures.


    I'm aware of this, but it's an entirely different sort of
    thing. This allows the programmer to browse database
    stuff inside of the IDE. I'm talking about creating a
    program I can distribute to a user and let the user
    browse through a database.

    > I don't make my database connections this way, so there's a lot more that I
    > don't know about. I do see that a datagrid and ADO Data Control are part of
    > the Toolbox.


    While I'm aware of these, they strike me as clumsy at
    best. When/if I (for example) start using an 64-bit OS, I
    may find the benefits of native 64-bit code justify
    putting up with these disadvantages, but that doesn't
    change the fact that they really are disadvantages.

    Make no mistake, I realize full well that my continued
    use of VC++ 6 is basically on borrowed time, and I'll
    have to change to something else eventually. I really do
    wish, however, that when/if I did, I didn't have to put
    up with losing its capabilities. Right now, all the newer
    alternatives from MS have enough disadvantages that I'll
    only switch to them when/if I'm left with no other
    reasonable choice at all.

    Even when that does happen, I'm not at all sure the
    switch will be to a newer MS IDE -- if I have to switch,
    to a second-rate tool that doesn't work the way I like,
    it looks to me like Eclipse is as good a choice as a
    newer MS IDE.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.

  14. Re: how to add your own class to the toolbox

    >
    > > You'll find that under Tools -> Connect to Database -> etc. It gives

    you a
    > > list of ALL your data connections, and their tables and all the fields
    > > within those tables on the "Server Explorer" pop-out tab. It also

    handles
    > > Views and Stored procedures.

    >
    > I'm aware of this, but it's an entirely different sort of
    > thing. This allows the programmer to browse database
    > stuff inside of the IDE. I'm talking about creating a
    > program I can distribute to a user and let the user
    > browse through a database.


    Looking at both, for VC++6.0, I see "Database Project" under New->Projects,
    and in VC++7.1, I find it under New->Projects->Other Projects -> Database
    Projects. I've not tried it, but from the description ("Create a new
    database project allowing direct manipulation of the database objects and
    data."), I'd guess it's the same thing.

    I've used Visual C++ since before version 1.0 (Quick C and C++ Workbench
    7.0). I'd be very surprised if they actually removed any functionality --
    unless it was for something like DAO that they badly want to depreciate.



  15. Re: how to add your own class to the toolbox

    In article <1209ukiqqdf42ef@corp.supernews.com>,
    lbax02.spamguard@baxcode.com says...

    [ ... ]

    > Looking at both, for VC++6.0, I see "Database Project" under New->Projects,
    > and in VC++7.1, I find it under New->Projects->Other Projects -> Database
    > Projects. I've not tried it, but from the description ("Create a new
    > database project allowing direct manipulation of the database objects and
    > data."), I'd guess it's the same thing.


    As I explained at some length, yes, up to that point
    they're the same. The difference comes when you decide to
    connect a control in your dialog to a field in the
    database. Up to that point (picking a database, etc.)
    they're essentially identical (i.e. some dialogs have
    changed slightly and such, but they do the same things).

    When you try to connect fields to controls, however,
    they're fundamentally different: one works, the
    other...doesn't.

    > I've used Visual C++ since before version 1.0 (Quick C and C++ Workbench
    > 7.0). I'd be very surprised if they actually removed any functionality --
    > unless it was for something like DAO that they badly want to depreciate.


    I may well have used it even longer (I can remember when
    "Microsoft C" was really a repackaged version of Lattice
    C). I was not merely surprised, but frankly flabbergasted
    when I figured out that functionality I used and depend
    upon just wasn't there. It's now something like 5 years
    since Visual Studio .NET came up, and I'm still not
    _entirely_ sure I believe it -- even though I've looked
    over and over, off and on for years now, I still half
    wonder whether I'm not just missing something semi-
    obvious. Then I try to make it work again, and waste a
    couple of hours trying to get it to work. I spend a few
    more hours reading through the help files trying to see
    what _must_ be there that I've previously missed.

    After all that, it still doesn't work, and I'm left
    wondering whether anybody at Microsoft has tried it or
    not. Come to that, I've brought the subject up once or
    twice in some of the microsoft.public.* newsgroups where
    a number of MS employees hang out on a regular basis --
    none of them has ever confirmed what I've found, but none
    of them has ever shown me what I'm doing wrong either.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.

  16. Re: how to add your own class to the toolbox

    Baxter wrote:
    > Do a right-click on the edit box and select "Add Variable". For "Variable
    > Type", you can type in the name of your class instead of selecting one of
    > the predefined classes.
    >


    Thanks!

    That was easy done. But my dialog still don't work; I
    now trigger a bunch of assertions wheh the app loads.
    Is there more I need to do?

    -Thorsten

  17. Re: how to add your own class to the toolbox

    Thorsten Ottosen wrote:
    > Baxter wrote:
    >
    >> Do a right-click on the edit box and select "Add Variable". For
    >> "Variable
    >> Type", you can type in the name of your class instead of selecting
    >> one of
    >> the predefined classes.
    >>

    >
    > Thanks!
    >
    > That was easy done. But my dialog still don't work; I
    > now trigger a bunch of assertions wheh the app loads.


    I thinkt these assertions are caused by internal problems
    rather than the procedure for adding variables.

    Thanks :-)

    -Thorsten

+ Reply to Thread