Tips-A2Z home page


Sub-categories

Algorithms (3)
Delphi Code snippets (9)
Releasing
Video tutorials (1)

All  |   Discussion (0)Delphi (General)

Vista-ready: Old Delphi Applications can be upgraded for use with Windows Vista through the use of a Task Dialog unit ( link ), a tool like "xptheme", and, if necessary, a manifest file to instruct Vista's User Account Control system what kind of privileges your application requires. More info on Vista and Delphi is here: link .   [guest]

– –– ——— –– –

Auto-complete: To automatically create an implementation stub for newly declared type procedures, hover the mouse over the procedure's parameter until it shows as a link, then press Shift-Ctl-C. E.g. procedure SetFilename(const Value: string) // 'Value' is a parameter.   [guest]

– –– ——— –– –

Save run-time memory: Under Tools/Options/VCL Explorer, uncheck 'Autocreate forms'. In the program (*.exe) delete any other Application.CreateFormX other than the MainForm. Now declare any unit variables in the Main Form as global variables, instead of in child units, and create/destroy them in the Main Form. This means instances are created only when needed. Otherwise, they'll all be created at run-time, then continue to suck up resources while remaining hidden.   [guest]

– –– ——— –– –

To make non-resizeable dialog boxes, change the Object Explorer BorderStyle property to BsDialog.   [guest]

– –– ——— –– –

Child classes inherit parent functionality, unless the common function ends with '; virtual;' in the parent, and '; override;' in the child.   [guest]

– –– ——— –– –

A variable of a parent class can actually be created in implementation as a child class. This is called polymorphing. For example,
var SomePerson: TPerson;
// where TPerson is the parent class
begin
SomePerson := TEmployee.Create
// where TEmployee is the child class
But the polymorph variable cannot use child functions that the parent doesn't have.   [guest]

– –– ——— –– –

Grandchildren without 'overrides' take the child's functionality. The rendering works up the inheritance chain from youngest to the base class (the parent).   [guest]

– –– ——— –– –

Visibility: classes' members are divided into private, public, protected, and published:
  • Private: visible to other members in the same class or other classes in the same unit;

  • Public: visible to other members in the same class, descendents of the same class, and other users of the unit;

  • Protected: visible to members in the same class, and descendents only;

  • Published: run-time type information, visible only at run-time, e.g. what the IDE can see in the object inspector.
   [guest]

– –– ——— –– –

Additional visibility: 'strict private' and 'strict protected'. This means no friendship between classes in the same unit.   [guest]

– –– ——— –– –

Object Inspector: arrange items alphabetically by right-clicking on OI and choosing arrange by name.   [guest]

– –– ——— –– –

Right-click the executable program in file structure menu to view source.   [guest]

– –– ——— –– –

When making dialog boxes modal, make sure the Object Inspector property 'ModalResult' is set to mrOk.   [guest]

– –– ——— –– –

Scroll-bars: add these to a form by selecting ssBoth in the Object Inspector ScrollBars property.   [guest]

– –– ——— –– –

Menu Item dropdown list separator bar: Using the ActionList component, click on a new item space in the mini-designer, then enter a dash (-) in the Object Inspector Caption property.   [guest]

– –– ——— –– –

To help tell the difference between objects, prefix names with letters:
T = Type
F = Field
A = Parameter
U = Unit
frm = form   [guest]

– –– ——— –– –

Another short-cut: Shift between interface and implementation declarations with Ctl+Shift+arrows.   [guest]

– –– ——— –– –

Dynamic components: You don't have to drop components on your form, but can create them dynamically. e.g., in the general case, component := tcomponent.create(self);
or in the specific case,
btn := tbutton.create(self);
This provides advantages when you want to compile your program on different machines, or when you want to use different versions of the same component. This method can also be used to access third party components in Turbo Delphi (ie, the free version of Delphi), which doesn't allow the installing of components into the IDE.   Kevin Solway (173)

– –– ——— –– –

Creating short-cuts:
- Prefix the desired short-cut letter of a caption with the symbol '&' , in the Object Inspector.
E.g. Button1 / Caption: &Delete
or
- Using an ActionList (non-visual component), choose a ShortCut for the list item from the drop-down list in the Object Inspector, or type in one of your own creation.   kellyjones00 (593)

– –– ——— –– –

Some keyboard shortcuts:
  • <ctrl><shift><i> : indent selected rows
  • <ctrl><shift><u> : unindent selected rows
  • <ctrl><shift><0..9> : set or remove the bookmark 0..9.
  • <ctrl><0..9> : jump to bookmark 0..9 in the currently opened file.
  • <ctrl><shift><g> : create a new GUID.
  • <ctrl>t : delete word
  • hold <shift> key down : then use arrows, home and end keys, to select text.
  • <ctrl><home> : jump to start of file
  • <ctrl><end> : jump to end of file
  • F12 : switch between form and code   Kevin Solway (173)
  • – –– ——— –– –

    Moving and sizing a component precisely:
  • To move a component to an exact spot, select the component, then press and hold the CONTROL key, then use the cursor keys to move the component in 1 dot increments.
  • To resize a component precisely, select the component, then press and hold the SHIFT key, then use the cursor keys to resize the component in 1 pixel increments.   Kevin Solway (173)
  • – –– ——— –– –


     


     

    To post a new tip, sign up for a free account.
    (Unfortunately this is a necessary spam prevention measure)

    Who is online
    In total there are 47 users online :: 0 registered and 47 guests (based on users active over the past 5 minutes)