Article View: microsoft.public.vc.ide_general
Article #3Re: Using VC++ from a C++Builder perspective
From: Scott McPhillips MVP
Date: Fri, 12 Nov 2004 01:14
Date: Fri, 12 Nov 2004 01:14
48 lines
3105 bytes
3105 bytes
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
>
>
> This to me is very "c++ish" in that you create an instance of a class
> and then set its properties to edit it. It may be less Builder-like and
> more "pure c++ish" if you had to call, for example,
> myEdit->SetLeft(100)--see comments below--but the same basic logic
> applies (you create an object and edit it via its member
> functions/variables).
>
> Could some kind soul please write the code to do this set of actions via
> Visual C++ just so I can see how its done???
>
> Thanks!!!
>
>
> -Jason
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.
--
Scott McPhillips [VC++ MVP]
Technical Details
Message-ID:
<#eu5gVFyEHA.1452@TK2MSFTNGP11.phx.gbl>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!204.71.34.3!newsfeed.cwix.com!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gblReferences:
<hinson-6E84C1.18360311112004@news.east.cox.net>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 Date: Thu, 11 Nov 2004 20:14:39 -0500 From: "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> Organization: McPhillips Designs User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Subject: Re: Using VC++ from a C++Builder perspective References: <hinson-6E84C1.18360311112004@news.east.cox.net> In-Reply-To: <hinson-6E84C1.18360311112004@news.east.cox.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <#eu5gVFyEHA.1452@TK2MSFTNGP11.phx.gbl> Newsgroups: microsoft.public.vc.ide_general,borland.public.cppbuilder.vcl.components.using NNTP-Posting-Host: pcp220481pcs.elkrdg01.md.comcast.net 68.55.209.237 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!204.71.34.3!newsfeed.cwix.com!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl Lines: 1