🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#5
From: Filip Konvicka
Date: Fri, 12 Nov 2004 14:14
77 lines
4626 bytes
Jason,

personally I think that the "simply-set-a-member" approach is rather
confusing, and indeed delphish. A single assignment looks as though it is an
atomic operation, but it is in fact calling a cascade of functions... in my
opinion this leads to much less efficient code, because you re-read or
re-set the attributes more often (instead of caching the values). Not only
that - the example you provided suggests that instead of calling 1 function
to set window position, you do 4 "assignments" (which are no doubt
implemented by calling the aforementioned function 4 times!) But, all this
is just my opinion. I think that it's a good thing for you to learn the
WIN32 API or the (more or less thin) MFC wrapper so that in the end you can
use the API more efficiently. In VC++, I think that you have no other choice
anyway :-)

Best Regards,
Filip

"Jason W. Hinson" <hinson@physicsguy.com> p�e v diskusn�m p��sp�vku
news:hinson-6E84C1.18360311112004@news.east.cox.net...
> 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: <ejgc6HMyEHA.3120@TK2MSFTNGP12.phx.gbl>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!prodigy.com!newsfeed.cwix.com!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
References: <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
From: "Filip Konvicka" <filip.konvicka.remove_this_antispam_token_please@logis.cz>
References: <hinson-6E84C1.18360311112004@news.east.cox.net>
Subject: Re: Using VC++ from a C++Builder perspective
Date: Fri, 12 Nov 2004 15:14:50 +0100
Lines: 79
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <ejgc6HMyEHA.3120@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.vc.ide_general,borland.public.cppbuilder.vcl.components.using
NNTP-Posting-Host: con.logis.cz 193.84.12.20
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!prodigy.com!newsfeed.cwix.com!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl