🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Using VC++ from a C++Builder perspective

#2
From: Jason W. Hinson
Date: Fri, 12 Nov 2004 00:36
57 lines
3622 bytes
Hi all...

I'll note up front that I'm copying this to a C++Builder group in case 
anyone there is interested...

Anyway, I've used Borland C++Builder for a while, and now I'm going to 
have to switch to Visual C++.  I took a look at VC++ a bit, and I must 
say it seems a lot less "c++ish" (compared to Borland C++ Builder) in 
its implementation of components.  By that I mean that in Builder you 
can programmatically create a new object (like an Edit box), place it on 
a form as desired, and set its various properties in a way very much 
like you do with any other c++ object.  I was hoping someone could 
provide an example explained below to help me understand how VC++ does 
things compared to Builder.

Say I made a button on a form, and in its OnClick event (or equivalent 
in VC++) I wanted to create a new Edit box, set its location and size, 
and give it some initial text.  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
 

Added Comments: For those that don't know, the "direct edit" of 
properties in my code example isn't as direct as it may seem.  In 
Builder, Top, Left, Width, etc. are member "properties" which act like 
member variables that you can directly interact with, but behind the 
scenes a "XYZ->Top = 5" command may actually call an internal set 
function, for example.  You the user don't have to know about or worry 
about whether you are directly setting them or whether they are actually 
calling a behind-the-scenes set function that does various checks before 
setting the actual variable.  It's all Delphi stuff, from what I 
understand, and I've seen something like it in VB as well, if I remember 
correctly.  But ANYWAY...
Technical Details
Message-ID: <hinson-6E84C1.18360311112004@news.east.cox.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!newsprint.newsread.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!p01!lakeread06.POSTED!53ab2750!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f707b,2ac2be6d0340ebc1,start
X-Google-Thread: f5c5c,2ac2be6d0340ebc1,start
X-Google-Attributes: gidf707b,gidf5c5c,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!newsprint.newsread.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!p01!lakeread06.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: Using VC++ from a C++Builder perspective
User-Agent: MT-NewsWatcher/3.4 (PPC Mac OS X)
Message-ID: <hinson-6E84C1.18360311112004@news.east.cox.net>
Lines: 57
Date: Thu, 11 Nov 2004 18:36:03 -0600
NNTP-Posting-Host: 68.105.58.247
X-Complaints-To: abuse@cox.net
X-Trace: lakeread06 1100219762 68.105.58.247 (Thu, 11 Nov 2004 19:36:02 EST)
NNTP-Posting-Date: Thu, 11 Nov 2004 19:36:02 EST
Organization: Cox Communications