357mag 2 Posted December 10 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
Anders Melander 1813 Posted December 10 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. 2 Share this post Link to post
Gord P 14 Posted December 10 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
weirdo12 21 Posted Sunday at 10:00 PM (edited) 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 Sunday at 10:05 PM by weirdo12 Share this post Link to post
Uwe Raabe 2063 Posted Monday at 12:09 AM 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 dspSomething, dispSomething 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
pyscripter 694 Posted Monday at 04:46 AM (edited) 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 Monday at 04:49 AM by pyscripter Share this post Link to post
dummzeuch 1515 Posted Monday at 08:03 AM 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