Jump to content
357mag

Naming abbreviations for controls

Recommended Posts

Is there a page out there somewhere that shows some naming conventions for the controls in C++ Builder? Like how do you abbreviate things like the Edit box or the Label etc? Do you just follow Visual Studio conventions? Just wondering what would be some good naming abbreviations.

Share this post


Link to post
12 minutes ago, 357mag said:

Just wondering what would be some good naming abbreviations

Don't.

You aren't improving anything by abbreviating control names.

  • Like 2

Share this post


Link to post

Are  you talking about changing the default name of Button1 for example to btnOpen or something?  If so, I have never seen any guidelines for C++.   I have seen a bunch of code written with a three letter lowercase prefix of the control such as the btnOpen one I just mentioned.  I have seen mnuOpen for menu item, dlgOpen for dialog, actOpen for actions etc.  I have my own system which is different.  I think the main thing is being consistent and something you can search easy enough.  Or perhaps someone will point you to some standard somewhere.

Share this post


Link to post

Just to be clear, are you referring to renaming controls that you drag and drop or naming ones you are creating dynamically?

 

I missed the previous post...

Edited by weirdo12

Share this post


Link to post
On 12/10/2024 at 10:27 PM, Gord P said:

I have seen a bunch of code written with a three letter lowercase prefix of the control such as the btnOpen one I just mentioned.  I have seen mnuOpen for menu item, dlgOpen for dialog, actOpen for actions etc.

I try to omit the control type in the name in favor of the purpose the control is used for. F.i. instead naming a TLabel as lblSomething and a TStaticText as sttSomethingElse I use dspSomethingdispSomething or even displaySomething lately. Similar I give a TEdit, TMemo or TComboBox (if not in List style) a editSomething name, while a TRadioGroup, TLIstBox or TComboBox  (when in List style) gets a name like selectSomething. The advantages are that these names usually stay as is when the controls are changing type and it contributes to documentation - at least a little bit.

Share this post


Link to post

I don't think this is anything to go by, but Embarcadero is sometimes using a suffix instead of a prefix! e.g.

 

Vcl.CustomizeDialog.dfm

      object CaptionOptionsGrp: TGroupBox

      object ApplyToAllChk: TCheckBox

      object CaptionOptionsCombo: TComboBox

 

This looks to me worse than using a prefix.  But anything is better than keeping the default names (Button1, Button2, .. Button105 etc.)

Edited by pyscripter

Share this post


Link to post

GExperts has a Rename Component expert which has two different presets for many component types.

No idea where the preset "defaults" comes from, the second one is called "twm" and you can probably guess whose initials these are.

 

(The presets are not covered in the help yet.)

 

I think, cnPack also has a similar functionality but I don't know anything about it.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×