🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: microsoft.public.vc.ide_general
Article #8

Re: Using VC++ from a C++Builder perspective

#8
From: Jason W. Hinson
Date: Fri, 12 Nov 2004 23:04
81 lines
5118 bytes
In article <#eu5gVFyEHA.1452@TK2MSFTNGP11.phx.gbl>,
 "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote:

> Jason W. Hinson wrote:
> 
> > Here's what you would do in Builder:
> > 
> > TEdit* myTEdit = new TEdit; // new edit box owned by "this" form
> > myEdit->Parent = this;  // edit box sits on this form
> > myEdit->Top = 20;  // top position on form in pixels
> > myEdit->Left = 100; // left position on form in pixels
> > myEdit->Width = 150; // width of edit box in pixels
> > myEdit->Font->Color = clHighlight;  // set font color to standard 
> > windows highlight for fun
> > myEdit->Text = "Type Something Here"; // edit the text inside the edit 
> > box
> 
> Using the MFC library that comes with VC++...
> 
> CEdit* myEdit = new CEdit();
> CRect rect(left, top, right, bottom);
> myEdit->Create(WS_VISIBLE | WS_BORDER, rect, this, IDC_MYEDIT);
> myEdit->SetFont(GetFont());
> myEdit->SetWindowText("Something");
> 
> MFC control objects have almost no member variables.  Instead, numerous 
> CWnd functions (like SetFont) are inherited by all of them to get/set 
> the properties that are stored within Win32.  MFC does not try to be 
> very "C++ish".  Rather, it is for the most part a thin wrapper over the 
> Win32 APIs.  It provides the essential interface needed between the C 
> language API callbacks and C++ member functions.  You can see a lot of 
> it quickly by working through the SCRIBBLE tutorial in the help.

Thanks for the reply, Scott...

This is not bad at all.  You created the object directly with a new 
command, and you didn't have to refer to it by its ID number to set its 
variables (though it looks like you did have to give it an ID and make 
sure it was unique).  I'm obviously new to VC++, and I didn't know if 
such actions were the standard way of doing things or not.

Just to note, the visual component library (VCL) in Builder also has a 
lot of inherited members from more basic visual components.  For 
example, obviously every such component needs a Top, Left, Width, and 
Height.  However, obviously some higher-level components need additional 
members specific to their tasks.  For example, a combo box needs a list 
of items to display, so in Builder there is an Items member to the 
TComboBox to which you can add, edit, delete, etc items to be displayed 
in the box.

Another quick question: When you build a CEdit with the VC7 IDE, it is 
given an ID number, if I understand correctly.  Does it not have a name 
as well?  From the VERY limited exposure I've had, it seems you always 
have to get the item (I forget the call) using its ID, then that gives 
you a CWnd pointer (not a CEdit pointer).  So if there are 
CEdit-specific members, how do you access them?  If you create a combo 
box at run-time and want to add members to it, is that something you can 
do once you have a CWnd pointer to it, or is there some other way you 
have to access that type of component?

I also noticed that you could assign an IDE-created CEdit a variable, 
but (again, from my limited exposure) it seemed that this only gave you 
direct edit capabilities for the text in the CEdit rather than pointing 
you to the CEdit object itself.  However, when you create a variable 
for, say,  a button, it seems to point to the button object itself.  If 
I got that right, it sure is confusing.

Another annoyance I noted (and I'd like to think there were an easy way 
around this) is that if I created a button, added some code for its 
click event, then deleted the button, VC7 did not seem to do a good job 
of cleaning up the code that used to go with the button.  In fact, at on 
point it seems it didn't even get rid of some of the creation routines 
for the button, and so it refused to run just because I used the IDE to 
delete a button.  Is that just the way it is, or did I miss something?

Sorry for all the added questions, but I really appreciate any help you 
can offer!  I'll also find the SCRIBBLE tutorial for some added 
experience.


-Jason
Technical Details
Message-ID: <hinson-DFA459.17044712112004@news.east.cox.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!p01!lakeread04.POSTED!53ab2750!not-for-mail
References: <hinson-6E84C1.18360311112004@news.east.cox.net> <#eu5gVFyEHA.1452@TK2MSFTNGP11.phx.gbl>

Show Full Headers
Complete Article Headers
X-Google-Thread: f707b,2ac2be6d0340ebc1
X-Google-Thread: f5c5c,2ac2be6d0340ebc1
X-Google-Attributes: gidf707b,gidf5c5c,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!p01!lakeread04.POSTED!53ab2750!not-for-mail
From: "Jason W. Hinson" <hinson@physicsguy.com>
Newsgroups: microsoft.public.vc.ide_general,borland.public.cppbuilder.vcl.components.using
Subject: Re: Using VC++ from a C++Builder perspective
References: <hinson-6E84C1.18360311112004@news.east.cox.net> <#eu5gVFyEHA.1452@TK2MSFTNGP11.phx.gbl>
User-Agent: MT-NewsWatcher/3.4 (PPC Mac OS X)
Message-ID: <hinson-DFA459.17044712112004@news.east.cox.net>
Lines: 81
Date: Fri, 12 Nov 2004 17:04:47 -0600
NNTP-Posting-Host: 68.105.58.247
X-Complaints-To: abuse@cox.net
X-Trace: lakeread04 1100300688 68.105.58.247 (Fri, 12 Nov 2004 18:04:48 EST)
NNTP-Posting-Date: Fri, 12 Nov 2004 18:04:48 EST
Organization: Cox Communications