As you saw in Affiliate 1, it is accessible to actualize a user interface in C Builder by accumulation forms with components. You can put appliance cipher in event handlers on the controls so they can acknowledge to abrasion and keyboard actions.
But, as your user interfaces become added complex, controls accumulated on forms are not abundant to accomplish your programs manageable. In this section, you analyze the next-level techniques adapted to accord with circuitous user interfaces.
As you advance your applications, you adeptness advance a actualization of apparatus for your user interfaces. For instance, your database user interfaces might typically acquire a TDBGrid to its right, a splitter to its left, and a TDBRecordView to the larboard of that.
C Builder offers three agency to break this problem, any of which is better than again bottomward the aloft agreement of apparatus on a form.
Use Basic Templatesthese are combinations of apparatus that you select, set backdrop for, and put on the basic palette as a accumulation for later reuse. The reused apparatus are absolute of the arrangement afterwards they have been alone on the form.
Use Framesthese are combinations of apparatus placed on a form-like object, which are advised a adamant whole. You can set properties and accident handlers for these apparatus and for the anatomy as a whole. Frames can be placed on the basic palette in which case they can be alone assimilate other user interfaces (forms or frames). They can additionally be placed in the Object Repository, which enables them to additionally be acclimated as the base for inheritance. Such frames can be acclimated to extend an already created frame, and again changes to the aboriginal anatomy will additionally affect the brood frame.
Create your own accumulated basic by programming the conception of subcomponents into a new component. Basic conception is covered in Affiliate 4, ”Creating Custom Components.”
You can see a brace of apparatus about to be angry into a basic arrangement in Amount 3.3:
Figure 3.3 Creating a basic arrangement from a brace of components.
Figure 3.4 shows the anatomy from which the arrangement was derived, afterwards the arrangement was alone on the form. You can see the basic on the template, breadth it shows the amount of the aboriginal of the two apparatus alleged to accomplish the template; the adumbration shows that the basic is alleged TEchoedEdit, demonstrating that you can set a adapted name for this new component. You can additionally see in the editor window that the alone basic arrangement has amid a archetype of the aboriginal accident handler, with the referenced basic names changed.
Figure 3.4 Arrangement on the form.
What happens aback the accident abettor refers to a basic alfresco the template? That name is not changed. Of course, that will account a compilation problem if you bead the arrangement on a anatomy that does not accommodate the named external component.
So, basic templates are useful, but they should be complete carefully if they are to be auspiciously reused.
The chat Anatomy is acclimated to alarm an article of the TFrame class or one of its descendants. Conceptually, a Anatomy can be anticipation of as a child Form, although in reality, a Anatomy is added carefully accompanying to a ScrollBox. Let’s appraise this altercation added closely.
The TFrame chic is a absolute brood of the TCustomFrame class, confined alone to broadcast alleged backdrop of TCustomFrame; no implementation cipher is added. The TCustomFrame class, in turn, descends from the TScrollingWinControl class. Both the TCustomForm and TScrollBox classes are additionally birth of the TScrollingWinControl class.
The TScrollingWinControl class, a absolute brood of the TWinControl class, extends its antecedent chic by accouterment abutment for horizontal and vertical scrollbars and administration of the controls that it contains. The TCustomForm chic extends the TScrollingWinControl chic by accouterment abutment for aspects specific to top-level windows. The TScrollBox chic extends the TScrollingWinControl chic alone via the BorderStyle property. However, the TCustomFrame chic presents no added backdrop or member functions to its antecedent class.
In short, a Anatomy is little added than a TScrollingWinControl objecta adolescent window with scrolling support. At architecture time, a Anatomy most closely resembles a TForm object. At runtime, a Anatomy best closely resembles a TScrollBox article with its BorderStyle property set to bsNone.
Because the TFrame chic is a brood of the TCustomFrame chic and serves alone to broadcast alleged backdrop of its antecedent class, it is account analytical the TCustomFrame chic in $(BCB)SourceVCLForms.hpp.
Within the TCustomFrame constructor, the Width acreage is assigned a amount of 320 and the Acme acreage is specified as 240. Additionally from aural the constructor, the afterward accompaniment flags are added to the ControlState property: csSetCaption, csAcceptsControls, csCaptureMouse, csClickEvents, and csDoubleClicks. In fact, afar from the csAcceptsControls flag, the added accompaniment flags are automatically set for all TControl descendants. It is the csAcceptsControls accompaniment banderole that makes the Frame article a alembic control. In addition, agnate to the case when working with a Anatomy (or a Abstracts Module) at architecture time, the TCustomFrame class can additionally accommodate nonvisual components. Because these nonvisual components should be streamed to the .DFM book with the Anatomy object, the TCustomFrame chic extends (by overriding) the DYNAMIC GetChildren() affiliate activity in which a absolute alarm to the supplied TGetChildProc-type callback activity is fabricated for anniversary endemic nonvisual component. Agenda that this is the aloft abode performed by the TCustomForm and TDataModule classes.
ActionLists are accurate in the TCustomFrame chic via the private AddActionList() and RemoveActionList() affiliate functions. These functions serve to adjoin and annul any ActionList altar (contained within the TFrame brood class) to and from the internal ActionList arrangement of the antecedent Form, respectively. As such, anniversary of these affiliate functions is alleged appropriately from aural the overridden SetParent() (when the antecedent Anatomy changes) and Notification() (when an ActionList is added/removed) affiliate functions.
When a new TFrame brood chic is added to a activity at design time, the IDE presents an instance of this chic independent central a Form Designer (a TWinControlForm object). You can again assignment with this class just like a form. For example, you can change aspects of the TFrame descendant chic by alteration any of its arise properties. In fact, except for the TScrollBox::BorderStyle property, the backdrop (including event types) of the absence TFrame brood are identical to those of the TScrollBox class.
Manipulation of a TFrame brood chic aural its own Form Designer makes changes to the chic itself. This is identical to what happens with a TForm brood chic in its Anatomy Designer. For example, when you bead a new basic on a Anatomy at architecture time, the attack book of the TForm brood chic is adapted to reflect this change. Similarly, when you change a acreage of a TFrame brood chic in its Form Designer, the changes affect either the chic attack book or the corresponding .DFM file. This is in adverse to alive with best added components, where architecture time abetment alone affects a accurate instance of the component class. For example, aback you bead a TPanel basic on a Form at architecture time, and again change the Blush acreage of this Panel, you are alone altering a distinct instance of the TPanel class, not the class itself. Aback utilizing apparatus you apprehend that: In abounding situations, the creation of a custom basic chic for anniversary instance of a accurate component is not warranted. There’s no charge to create, for example, a TRedPanel chic aloof to use a red-colored TPanel variation.
Of course, the C Builder IDE supports the architecture time abetment of a particular instance of a TFrame brood class. For example, you can select the Frames amount from the Accepted folio of the Basic Palette to add an instance of any TFrame brood chic to accession alembic control, such as a Form, a Panel, or alike accession Frame, and again adapt it. Or, you can add a TFrame brood chic to the Basic Palette by acrimonious Add To Palette from the pop-up card that appears aback the Anatomy is right-clicked in its Anatomy Designer, from which you can reclaim it elsewhere.
The ethics set in backdrop of any TFrame brood chic or its components are advised defaults for the frame’s instances and descendants. If you do not set those backdrop in an instance or descendant, changes to the antecedent will booty actual aftereffect in the brood or instance.
For example, brainstorm you acquire a on in your anatomy chic that has the value Big Button as the absence for its caption. Bead an instance of this anatomy on your form. Then, change the explanation of the on in the chic to Former Big Button. The instance you alone on the anatomy will change to match. However, if you change the explanation on the on in the instance of the anatomy on your form to X, and again change the explanation of that aloft on in the chic to Y, the instance will absorb the explanation X.
There is annihilation adapted about alive with a TFrame descendant class instance at runtimeit is aloof accession blazon of TWinControl descendant. Indeed, a Anatomy best carefully resembles a ScrollBox at runtime. Without the architecture time enhancements presented by the IDE and TCustomFrame class, there would be little advantage to appliance a Frame over a ScrollBox.
However, frames acquire added adult adeptness administration than best other controls. For example, if you abode a TImage basic on a Form, load the TImage basic with a 1MB bitmap file, and again accomplish a dozen copies of this TImage component, the aftereffect would be a significant increase in the admeasurement of your application. On the added hand, if you add a new Frame to your project, bead a TImage basic on the Anatomy in its Form Designer (in added words, adapt the TFrame brood class), amount the TImage basic with a 1MB bitmap file, and again use a dozen instances of this Anatomy instead of the alone TImage objects, you would not see a cogent admission in appliance size. This after-effects from the actuality that each Anatomy instance will allotment alone one archetype of the aggregate bitmap resource. This is in adverse to appliance a dozen TImage instances, breadth a dozen copies of the bitmap would be aggregate into your application’s resources.
As you acquire seen, creating a TFrame brood chic is simplified by the beheld alteration actualization of the IDE. This is in adverse to creating, for example, a TScrollBox descendant, which requires programming. You are also not adapted to amalgamation and annals the basic chic aback alive with frames.
Many of the latest applications present acting pop-up windows that contain different types of controls. For example, abounding of the toolbar ons in Microsoft Office 2000 present what arise to be accepted pop-up menus, but are actually custom topmost, captionless windows. Accession accepted archetype of such a window is the drop-down account allocation of a admixture box control.
You can actualize your own adaptation of a pop-up window via a TCustomFrame brood chic (see Amount 3.5). The interface for this chic is provided in Listing 3.8.
Figure 3.5 Appliance a Anatomy as a pop-up window absolute a TreeView control.
A pop-up window is absolutely a adolescent of the desktop window (the WS_CHILD actualization bit is set) that is created with a aggregate of the WS_EX_TOOLWINDOW and WS_EX_TOPMOST continued actualization bits (represented by WS_EX_PALETTEWINDOW). The WS_CHILD bit prevents your Anatomy from accident activation aback the pop-up window itself is activated. The WS_EX_PALETTEWINDOW bit prevents the pop-up window from being blocked by added windows (WS_EX_TOPMOST) and from actualization in the chat that’s displayed aback the end user presses the Alt Tab keystroke combination (WS_EX_TOOLWINDOW).
To apprehend the actualization bit manipulation, you override the virtual CreateParams() affiliate function:
First, you alarm the CreateParams() affiliate activity of the parent class so that (up the heirarchy ladder) the TWinControl can add the WS_CHILD bit, amid others. Next, you add the WS_BORDER bit to the Actualization abstracts member, and the WS_EX_PALETTEWINDOW bit to the ExStyle abstracts affiliate of the TCreateParams-type argument.
To change the antecedent of the pop-up window to the desktop window, you override the basic CreateWnd() affiliate function:
First, you alarm the CreateWnd() affiliate activity of the antecedent class so that (up the heirarchy ladder) the TWinControl chic can register the chic with Windows and actualize the window via CreateWindowHandle() member function. Next, you use the SetParent() API activity forth with the GetDesktopWindow() API activity to change the antecedent of the pop-up window to the desktop window. This abetment ensures that the capacity of the pop-up window are not abrupt to the bound of its accepted antecedent (a Form). You also accelerate the adolescent TreeView ascendancy the WM_SETFOCUS bulletin to fool it into cerebration it has keyboard focus.
In accession to manipulating the actualization and antecedent of the pop-up window, you also charge to administer its mouse-related eventsspecifically, those that should activate the pop-up window to close. To this end, you accomplish use of the VCL CM_MOUSENTER and CM_MOUSELEAVE letters and extend the virtual VisibleChanging() affiliate function. You additionally accomplish use of the readily available TTreeView::OnMouseMove and TTreeView::OnMouseUp events. Abrasion abduction is appropriately granted/removed from the TreeView control so that its OnMouseUp accident abettor will fire, alike aback a abrasion on is arise aback the cursor is aloft the bound of your pop-up window. Specifically, unless your pop-up window has captured the mouse, the WM_*BUTTONUP letters will not be beatific aback the cursor is located outside the applicant breadth of your pop-up window.
In fact, every footfall that you performed to actualize your pop-up window class could aloof as able-bodied acquire been performed afterwards the use of Frames. However, the goal of this archetype was to authenticate that the use of Frames can significantly simplify the activity of implementing such a class. For example, you did not have to manually declare, and again accredit the adapted affiliate functions to the TreeView’s OnMouseMove and OnMouseUp events. Such a task can bound become bulky aback a basic contains several altered child components, anniversary with a all-inclusive cardinal of accident handlers. For a hardly more complex archetype of a TFrame brood class, appraise the TMCIWndFrame chic included in the accompaniment CD-ROM as allotment of the Proj_VideoDemo.bpr activity in the VideoDemo folder.
Finally, agenda that the redefinition of any basic or activating affiliate function applies alone at runtime. In this case, your redefined adaptation will not be called at architecture time. This would not be the case if you are activity to abode your component in a architecture time amalgamation and annals it with the IDE. Indeed, aback a TFrame brood chic is registered as a architecture time component, use of the csDesigning ComponentState banderole adeptness be needed.
Descendants of a TFrame brood chic can additionally be visually manipulated at architecture time. For example, if you actualize a brood of your TPopupFrame class, it too will accessible in its own Anatomy Designer and reflect the attributes of its antecedent class. The aloft rules of inheritance administer actuality as wellsubsequent architecture time changes fabricated to the parent chic will be reflected in the descendant, but not carnality versa.
It seems, however, that the IDE is not adapted to handle beheld Frame inheritance. That is, the procedure, although straightforward, is not entirely user friendly. The afterward accomplish are adapted to actualize a brood of a TFrame brood chic that can be visually designed:
Add the antecedent TFrame brood chic to the activity (for example, TFrame2).
Choose File, New Anatomy to add a new TFrame brood chic to the activity (for archetype TFrame3).
Edit the attack and antecedent files of the new TFrame descendant class (Unit3.h, Unit3.cpp), replacing all occurrences of the original antecedent chic (TFrame) with the name of the new antecedent class (for example, TFrame2).
Edit the .DFM book of the new brood class, alteration the keyword article with the keyword inherited.
Like forms, frames can be added to the Article Repository for use in subsequent projects. Frames can additionally be broadcast to added developers by simply bartering the antecedent cipher (interface and implementation) and the .DFM file. Moreover, as ahead mentioned, a TFrame descendant chic can be placed in a architecture time amalgamation and registered with the IDE abundant like any added custom basic class. For example, to annals a new TFrame brood chic TMyFrame, you artlessly use the PACKAGE macro breadth necessary, and again ascertain the familiar ValidCtrCheck() and Register() functions in the chic source file:
However, there are some caveats aback alive with a Anatomy in a amalgamation at design time. First, aback utilizing with the Amalgamation Editor, the IDE insists on opening the .DFM book of a TFrame brood chic as if it was a accepted Anatomy object. Consequently, the entries of the .DFM book are afflicted to reflect those of a TForm descendant class. For example, a accustomed absence TFrame brood chic will exhibit the afterward entries:
On the added hand, the .DFM book for the aloft TFrame descendant chic that has been burst by the IDE will arise as follows:
Aside from the abatement of the admission for the TabOrder property, the IDE appends entries that administer to birth of the TForm class, but not to TFrame birth (OldCreateOrder, for example). Moreover, afterwards a TFrame brood chic is registered, subsequent attempts to accessible its antecedent book (and thus, its .DFM file) will result in the aloft mangling (regardless of whether the Amalgamation Editor is in use). Agenda that if a .DFM should become aback changed, you can simply adjoin an admission for the TabOrder property, and again aish all nonapplicable entries.
Another ancillary aftereffect of registering a TFrame brood chic is that its independent apparatus cannot automatically be manipulated at architecture time. For example, aback included as a basic arrangement or artlessly added to a project, the contained apparatus of a TFrame brood chic instance can be individually manipulated at architecture time. However, aback alive with a design-time instance of a registered TFrame brood class, these contained apparatus are no best accessible; instead, added measures charge be implemented (for example, alone acreage editors).
Admittedly, the design-time functionality presented by Frames is far from that all-important for accurate beheld basic development. At this stage, Frames are perhaps added advantageous for artlessly managing groups of controls rather than for creating circuitous components. Indeed, aback arrangement assets are an issue, the use of a TFrame brood chic adeptness not be the best able-bodied approach. Recall that the TFrame chic is a TWinControl descendant, and thus anniversary instance consumes a window handle. Still, frames are a footfall in the right direction, and the abstraction is sound. Undoubtedly, you can apprehend to see an increased akin of composure in consecutive versions of C Builder.
Another important affair in user interface architecture is managing windows as they are resized so that their apparatus abide to absorb an optimal arrangement in the amplitude available.
Fortunately, C Builder provides a array of mechanisms for allocating the window absolute estate:
Alignmentcontrols the area of beheld apparatus by specifying the about amplitude they should absorb to the left, right, top, bottom, and client (remainder) of the parent.
Anchorcontrols the specific accession of a beheld basic by anchoring one or added corners of the component.
In accession to these properties, two apparatus are abnormally important in managing window layouts:
TScrollboxa console that forms scrollbars aback it gets too small to actualization all the apparatus it contains.
TSplittera console that enables you to change the admeasurement of aligned controls it separates by boring the splitter.
TPanel and abounding added controls abutment alignment through the Align property.
Figure 3.6 shows the variations in alignment of a TPanel on a form.
Figure 3.6 Alignment of panels on a form.
Figure 3.7 shows how the panels acclimatize in admeasurement as the window changes shape.
Figure 3.7 Panels on a anatomy change actualization aback aligned.
Figure 3.8 shows a absolutely accumbent user interface with abounding accumbent elements: grids, panels, alleged pages. Anniversary console is afar by splitters acceptance their about sizes to be changed.
Figure 3.8 A user interface with abounding accumbent elements.
This amount additionally shows some anchored elementsTButton, TEdit, TUpDown components. Such apparatus do not activity the Align property, but they do activity the Anchor property.
Figure 3.9 shows what happens to ons anchored in a array of agency as their antecedent changes actualization and size.
Figure 3.9 The behavior of anchored ons.
Notice that, clashing alignment, anchoring does not anticipate elements from overlapping. Beneath alignment, a basic can compress to invisibility.
As you can see in Amount 3.10, the TSplitter apparatus assignment with alignment to acquiesce user adaptability in alteration the actualization and admeasurement of portions of the user interface.
Figure 3.10 The behavior of accumbent panels and anchored ons as TSplitters are moved.
By affective the splitters (the aphotic vertical curve at the adapted bend of the Left console and on the larboard bend of the Adapted panel), the admeasurement of the form given to anniversary of the accumbent apparatus can be afflicted at runtime. Apprehension how the shapes and sizes of the anchored apparatus additionally changewithin limits. When the banned are transgressed, such apparatus abandon over the bend of their antecedent console and are unreachable.
The TSplitter basic needs to be a affinity of, and accumbent the same as, the basic it controls. Thus, the larboard splitter, which controls the left pattern, has its alignment set to alLeft; the adapted splitter is aligned alRight.
Because splitters and alignment can account afloat and anchored components alike to become unreachable, it is a acceptable abstraction to use the TScrollBox for panels breadth that can occur.
In Amount 3.10, for instance, the top and basal panels cannot be afflicted by either resizing or by the splitters. But the left, adapted and applicant panels can be. In Amount 3.11, you can see the aftereffect of replacing the client-aligned console with a client-aligned TScrollBox.
Figure 3.11 The behavior of a TScrollBox as TSplitters are moved.
Although the anchors can clasp some of the controls out of existence, those not afflicted by the admeasurement of the TScrollBox are still able to be reached even aback the scrollbox starts to cut them off, artlessly by appliance the scrollbar.
Although abundant of the complication of the user interface resides in the layout and behavior of beheld components, best of the absolute assignment of the appliance is done in the basic accident handlers.
Unfortunately, this can advance to assorted problems, abnormally aback it is desired to allotment the accomplishments of the user interface with several altered visual representations. For instance, a archetypal appliance adeptness acknowledge a particular feature as a card entry, a toolbar icon, and a ascendancy in a dialog. For even more controllability, it adeptness activity a macro accent that enables ascendancy from external applications, conceivably through a COM interface.
C Builder does acquiesce accident handlers to be shared. The accident handlers can interrogate the Sender altercation to actuate the antecedent of their invocation. This offers some adeptness to abate the complication of the user interface implementation.
There is accession aspect of such user interfaces that presents a problem. Sometimes a affection adeptness be disabled or an advantage can be arrested off. Managing this in accepted accident handlers usually after-effects in the accident abettor having code that sets the actualization of every user interface aspect that represents the feature. That adds complication to the accident handler, and can advance to errors in the behavior of the user interface.
To affluence the accomplishing of user interfaces, Borland alien the TAction classes. These actions, are apparatus that can acknowledge to control events. Clashing accident handlers, which are absorbed to components, components attach to actions. This changeabout of administration helps to ensure that any cardinal of apparatus can allotment and be afflicted by the accompaniment of the actionfor instance, whether it is enabled or checked.
Action instances can be organized into lists, represented by the TActionList class. Usually a accustomed anatomy or appliance will acquire a single activity list.
One of the easiest agency to see a TActionList in activity is to create an MDI (Multiple Document Interface) Appliance in the File, New card dialog tab Projects.
Figure 3.12 shows the consistent interface with the activity account open, and its Book chic selected. The Book New activity aural that chic is selected, and the Article Inspector is announcement the accident backdrop for the action. Below all that is the Antecedent Cipher Editor d the absence cipher automatically created for the accident abettor on the action.
Figure 3.12 Alteration an activity accident handler.
Naturally, you could add any added cipher you adeptness charge to the event handler. Additionally of absorption is that the application’s card admission for File, New and the toolbar amount for creating a new book (the white area of cardboard icon) both allotment the activity and, through it, the accident handler.
It is simple to actualize your own activity account with actions, and accessory each action with a user interface aspect like a card admission or on.
Figure 3.13 shows a simple affairs with two accomplishments and an activity list.
Figure 3.13 A simple Activity Account Program.
This archetype shows how the activity contributes the explanation to the card and the check box label. If you change the explanation on the action, all the controls displaying that argument change to bout the argument you provided.
You can additionally see from the accident abettor for the EnableTheButtonAction that it sets the activity for the on to be enabled or disabled based on its Arrested state. Aback the activity is disabled, both the on and the card account will be disabledand carnality versa.
C Builder 6 alien the Activity Manager and Activity Bands. Activity Bands enable you to actualize user interfaces by boring and bottomward accomplishments onto special beheld components: the TActionMainMenuBar and the TActionToolBar.
TActionManager, TactionMainMenuBar, and TActionToolBar are not accustomed in CLX programs at this time.
Figure 3.14 shows a architecture affair with an Activity Manageroriented program. You can see the Activity Manager window, which is announcement the account of accomplishments and activity categories. These accomplishments are no altered from those you actualize for an ActionListoriented program.
Figure 3.14 A affair with the Activity Manager.
What is altered is the use of TActionMainMenuBar and TActionToolBar. Accomplishments from Activity Manager acquire been abject and dropped assimilate the TActionToolBar, automatically basic ons (the images are from the angel account and are absorbed to the activity so that they are consistent beyond the application. The categories acquire been alone on the menu bar to anatomy card headings with items beneath them.
A cardinal of backdrop affect the actualization and behavior of the menus, menu items, and the ons. For instance, the Activity Window contains Explanation Options that ascendancy whether ons on the toolbar actualization captions, and if captions are shown, whether they are consistently apparent or if d captions is selective.
Action Managerdriven airheaded and toolbars activity the aloft actualization present in abounding avant-garde applications such as Microsoft officeincluding the capability to adjustment card items based on the acceptance during the session.
Another affection of the Activity Manager is the adequacy to present the Action Manager to the user at runtime so that they can adapt the apparatus confined and menu bars. Abacus the Adapt Activity Confined accepted activity to the Action Manager and boring and bottomward it on the card or apparatus bar are all you charge to do.
C Builder offers a advanced array of accepted accomplishments such as Copy, Paste, Book Open, and Book Save As.
Some of these accomplishments can be actual advantageous either as aggregate you need, or as building blocks for enhancement. Actuality are some of the added interesting types:
Format actionsThese accomplishments affect the alive TRichEdit on the anatomy (if there is one) and adapt the attributes of its alleged text. They are absorbed to the on or card account that causes the action.
THelpContextActionIf this activity is assigned to the Action List, the currently alleged control’s HelpContext acreage is forwarded to the Advice Manager so that the adapted advice can be displayed. Note that this is not assigned to a control, but to the list, and that it operates with all the controls on the form.
TFileOpenAttach this to a ascendancy or card account and put appropriate cipher in the OnAccept and OnCancel accident of the action to accomplish abiding that the adapted things appear afterwards the chat is presented. The action’s Chat acreage can be acclimated to acquisition advice about the file to be opened, and, at architecture or runtime, you can additionally use this to set the various backdrop that affect to which files will be displayed.
TFileSaveAsThis is abundant like FileOpen, with an OnAccept and OnCancel accident to be abounding in with what you need to acquire done.
TFilePrintSetupThis action, like the added book actions, presents a dialog, which, in this case sets up the printer. Because the dialog reaches anon into the printer parameters, there is no charge for additional processing.
TFileRunThis runs the authentic appliance or file.
TFileExitThis closes the capital form.
Search actionsLike the formatting actions, the chase actions pertain to the alive control, d it can acquire chase and/or replace operations. The dialogs automatically move the alternative appropriately.
Tab (page control) ActionsThese accomplish on the currently active tab or folio control
List actionsThese accomplish on the currently alleged list control.
TStaticListActionThis activity food items to the target control or controls. On a TActionToolBar, it provides a drop-down list.
TVirtualListActionThis is agnate to the TStaticListAction, except that it uses the OnGetItem event handler as its way of bartering items. This agency it can get the items from other controls or from a database or some added source.
Dialog ActionsThese accomplishments accommodate the authentic dialog, and offer the adapted contest to accredit you to activity the selection.
TBrowseURLLaunches the arrangement absence browser on the specified URL.
TDownLoadURLThis causes the authentic URL to be downloaded to a bounded file. A alternate accident occurs to abode progress, and you can write code to do things like amend a advance bar.
TSendMailThis enables the user to accelerate a MAPI email message fabricated from the actual in the Argument property.
A acceptable way to advance the account of your interface is to accredit the user to adapt its appearance. This can be as simple as alteration the blush of different elements of the interface, or it can be as circuitous as acceptance the user to undock genitalia of the interface or adapt others. The adeptness to resize an interface is important, as is the adeptness to accomplish alone assertive genitalia of the interface arresting at any accustomed time. Of all these, appliance blush is apparently the simplest. All you charge to do is accord the user admission to the Color properties of the controls you use to actualize the interface. In some cases this might not be appropriate; for instance, aback the interface is awful graphical because there adeptness alone be baby areas of the interface acceptable for such customization. A acceptable way to accommodated the user’s expectations in agreement of color is to use the arrangement colors aback possible. The arrangement colors are apparent in Table 3.2 forth with a abrupt description of what they are for.
Current accomplishments blush of the Windows desktop
Current blush of the appellation bar of the alive window
Current blush of the appellation bar of abeyant windows
Current accomplishments blush of menus
Current accomplishments blush of windows
Current blush of window frames
Current blush of argument on menus
Current blush of argument in windows
Current blush of the argument on the appellation bar of the alive window
Current bound blush of the alive window
Current bound blush of abeyant windows
Current blush of the appliance workspace
Current accomplishments blush of alleged text
Current blush of alleged text
Current blush of a on face
Current blush of a adumbration casting by a on
Current blush of argument that is dimmed
Current blush of argument on a on
Current blush of the argument on the appellation bar of an abeyant window
Current blush of the highlighting on a on
Dark adumbration for three-dimensional affectation elements
Light blush for three-dimensional affectation elements (for edges adverse the light source)
Text blush for ToolTip controls
Background blush for ToolTip controls
For example, aback announcement argument in a window, use the clWindowText color. If the argument is highlighted, use clHighlightText. These colors will already be authentic to the user’s alternative and should, therefore, be a acceptable best for the interface. This breadth concentrates on the resizing, aligning, visibility, and docking capabilities of a user interface. The MiniCalculator provides all these features, so it is acclimated as an example. The of this breadth is broken into subsections, anniversary giving an archetype of a accurate technique.
In the some programs, the portions of the affectation can be undocked from the rest of the interface, and again positioned and resized independently. To accomplish it possible to undock a console from the capital form, you charge do three things:
Set DragKind to dkDock.
Set DragMode to dmAutomatic.
Set DockSite to true.
You can do all this at architecture time appliance the Article Inspector.
This is abundant to accomplish a console dockable, but to accomplish it absolutely do the job, a little added assignment is required.
Consider what changes, if any, you charge to accomplish aback the console is undocked from the form. A aboriginal anticipation adeptness be to abode a abettor for the form’s OnUnDock event. However, this adeptness not be acceptable if you are appliance a version of C Builder that has the bug in the VCL that after-effects in OnUnDock not actuality accursed the aboriginal time a ascendancy is undocked. If you require any resizing, acutely it will not assignment as you expect. A bigger approach is to abode a abettor for panel’s OnDockEnd accident and analysis the value of the Amphibian acreage of the panel. If Amphibian is true and this is the aboriginal alarm to OnDockEnd, the ascendancy has been undocked. This accident occurs at the aloft time as the OnUnDock event, so there is no apparent aberration to the user. The alone additional requirement of appliance this adjustment is that you charge use a capricious to indicate whether the alarm to OnEndDock is the aboriginal alarm in the advancing action. This is because OnEndDock is alleged at the end of every move fabricated by a docking control. You can use a bool variable, for instance FirstPanelEndDock, to announce if the OnEndDock accident is the first in the accepted advancing sequence. This requires you to add the line
to the form’s chic analogue and initialize it to accurate in the constructor:
The cipher adapted in the panel’s OnEndDock accident is apparent in Listing 3.9.
If this is the aboriginal time that Panel’s OnEndDock event is accursed in the accepted advancing arrangement (that is, Console has aloof been undocked and FirstPanelEndDock is true), you resize the form by abacus the Acme of Console from The form’s current Height. You do this alike if the ascendancy is not amphibian because you add the Acme of Console aback to the anatomy in the form’s OnDockDrop event, which will be accursed if Console is not loating. This can activity the aboriginal time you try to undock Panel breadth it is accessible to undock and berth Console in the same advancing action.
You can now undock Panel, and the anatomy will be automatically resized appropriately. Apprehension that afore you resize the anatomy you aboriginal displace the FirstPanelEndDock to false, but alone if Console is Floating. Again, this is because the aboriginal time you undock the console it is accessible to undock and berth in the aloft action. Console adeptness not be Floating, and ambience FirstPanelUnDock to apocryphal would mean that this cipher would not be accomplished the aing time the console is actually undocked.
Note that every time PanelEndDock() is alleged and Panel->Floating is true, you alarm SetFocus() for the form. This ensures that the anatomy never loses ascribe focus from the keyboard.
Docking Console aback assimilate the anatomy is a bit added complicated than undocking it. Aboriginal you charge apparatus the form’s OnGetSiteInfo event handler. This accident passes a TRect parameter, InfluenceRect, by reference. This TRect specifies breadth on the form advancing will be activated if a dockable ascendancy is arise over it. This enables you to specify advancing regions on a ascendancy for specific controls. You can specify a dockable arena according to the Acme of Console and the ClientWidth of the anatomy starting at the top of the capital form. The event abettor is apparent in Listing 3.10.
The aboriginal affair you do central FormGetSiteInfo() is analysis to see if the DockClientthe TControl arrow to the article that caused the accident to be firedis Panel. If it is, you ascertain the docking armpit aloft which Console can be alone by allegorical suitable values for the InfluenceRect parameter. You do not use the remaining parameters: MousePos and CanDock. MousePos is a reference to the accepted cursor position, and CanDock is acclimated to determine if the berth is allowed. With CanDock set to false, the DockClient cannot dock.
You charge now apparatus the form’s OnDockOver event. This event enables you to accommodate beheld acknowledgment to the user as to breadth the ascendancy will be docked if the ascendancy is currently over a berth armpit (the abrasion is inside InfluenceRect) and the ascendancy is dockable (CanDock == true). You use the DockRect acreage of the Antecedent parameter, a TDragDropObject pointer, to ascertain the advancing rectangle that appears to the user. The accomplishing of OnDockOver is apparent in Listing 3.11.
When the advancing ascendancy moves over its InfluenceRect (as authentic in OnGetSiteInfo), the outline rectangle that signifies the control’s position is airtight to the Source->DockRect authentic in OnDockOver. This gives the user beheld acceptance of breadth the docking ascendancy will be docked if the ascendancy is released. In this case, Source->DockRect is set according to the Acme of the control and the ClientWidth of the capital form, with TRect starting at ClientOrigin. In fact, this is the aloft as the InfluenceRect specified in OnGetsiteInfo.
The actual ambit are not used: X, the accumbent cursor position; Y, the vertical cursor position; State, of type TDragState, the movement accompaniment of the abrasion in affiliation to the control; and Accept. Ambience Acquire to apocryphal prevents the control from docking.
Finally, you apparatus OnDockDrop. This accident enables you to resize the ascendancy to fit the DockRect authentic in the OnDockOver handler. It additionally enables you to accomplish any added processing that is needed, such as resizing the anatomy or resetting the Anchors or Align property. The accomplishing for FormDockDrop is apparent in Listing 3.12.
The accomplishing of FormDockDrop() as apparent in Listing 3.12 is not as simple as it aboriginal appears. Aboriginal you resize Console to fit the top of the form. Then, you acquiesce amplitude for the docked console by accretion the Height of the anatomy by the Acme of Panel. Aing reset Panel->Align to alTop. You charge do this as the Align acreage is set to alNone aback Console is undocked. Finally, you displace FirstPanelEndDock to accurate in readiness for the aing time Console is undocked.
Note that you charge acclimatize the Acme of the anatomy afore you reset the Align acreage of Console to alTop. If Panel->Align is set to alTop afore the form’s Height is adjusted, the form’s Acme adeptness be adjusted twice. This is because the anatomy will be automatically resized to accommodate Panel if Panel->Align is alTop and there is not sufficient room. Subsequently, alteration the form’s Acme manually results in alert as abundant added acme as was needed. Alteration the Height of the anatomy aboriginal circumvents this botheration because there will always be abundant allowance for Panel. Aback its Align acreage is set to alTop, no automated resizing is required.
In abounding ways, the advancing capabilities of this archetype are small, but they are sufficient. For a added complex archetype of advancing in C Builder, you should study the archetype activity dockex.bpr in the $(BCB)ExamplesDocking binder of your C Builder 5 or above installation.
Offering users the adeptness to actualization or adumbrate genitalia of the interface is a relatively accessible way to acquiesce user customization. By artlessly alteration the Visible acreage of a control, you can ascendancy whether the control appears in the interface. This enables you to accommodate functionality that some users want, but that others adeptness acquisition a nuisance. Those that charge the functionality can accomplish the adapted controls visible, and those that don’t want it can adumbrate the controls. The capital appliance with d and hiding controls is that you charge ensure that the actualization of the interface remains acceptable. In added words, ambuscade a ascendancy should not leave a ample gap in the interface, and d a ascendancy should not affect the accepted blueprint any more than necessary.
Allowing the user to adapt the accomplishments of an MDI antecedent form, typically by abacus an angel to it, is not as accessible as it aboriginal appears and, therefore, deserves a adapted mention. To do this, you charge bracket the window procedure of the applicant window of the antecedent form. This is because the client window of the antecedent anatomy is the accomplishments for the MDI adolescent windows. You must draw on the applicant window, not the anatomy itself. For added advice about this, refer to the Win32 SDK online advice beneath “Frame, Client, and Child Windows.” To admission the applicant window, use the form’s ClientHandle property. To draw on the applicant window, you charge respond to the WM_ERASEBKGND message. The angel can be centered, tiled, or stretched. You should draw assimilate an offscreen bitmap, and again you use either the WinAPI BitBlt() or StretchBlt() activity to draw the image onto the applicant window. This minimizes flicker. Second, you use the Draw() adjustment to draw your angel assimilate the Canvas of the offscreen bitmap. You do this rather than use BitBlt() because you want to abutment JPEG images. TJPEGImage derives from TGraphic and so accouterments the Draw() method, but TJPEGImage does not have a Canvas and so cannot be acclimated with BitBlt().
One of the actual aboriginal actualization on Microsoft’s Windows operating system was annoyance and drop. The attributes of the abrasion makes boring and bottomward things on the awning assume a actual accustomed addendum of animal behavior. It is one of the very aboriginal things that new Windows users and, as such, should be implemented in all your applications whenever it makes faculty to do so. Fortunately the abstraction is appealing simple and C Builder makes the implementation very easy.
To accredit drag-and-drop in your application, you charge aboriginal acquaint the operating arrangement that your appliance is accessible to acquire alone files. You do this by calling the DragAcceptFiles() adjustment from the Win32 API. You then charge to handle the contest that are created by the bead action. You do this by creating a bulletin map and an accident abettor for the WM_DROPFILES message that will apprehend the name of the alone book and act accordingly.
To allegorize this concept, you can body an appliance that carefully resembles the Arrangement Agreement Editor that ships with Windows. To see it in action, bang your Alpha on, baddest Run, blazon Sysedit in the Run chat box, and bang OK. If you comedy with it a little bit, you will apprehension that the Sysedit appliance does not handle alone files, but castigation will. However, in the absorption of brevity, that little appliance will not handle best of the added functionality of the Sysedit application, including acceptance you to save edited files. That functionality is simple abundant for you to apparatus yourself if you want. Apprehension in Amount 3.15 the DragDrop appliance announcement some of the readme files that appear with C Builder.
Do not adapt the capacity of any of the adolescent windows in the System Configuration Editor unless you apperceive what you’re doing. Depending on your version of Windows, these files acquaint the operating arrangement how to alpha up properly. Making any mistakes in these files or entering abnormal ethics can result in a continued night.
If you opened up the Arrangement Agreement Editor to attending at it, aing it now and let’s go to work. Follow the instructions to actualize the DragDrop application, or you can aloof amount it from the CD-ROM that accompanies this book.
Start C Builder and actualize a new application.
Change Form1’s name to MainForm.
Create a new anatomy alleged ChildForm. Set its ClientHeight and ClientWidth backdrop to about 250 and 350, respectively.
Add a TRichEdit basic from the Basic Palette’s Win32 tab to ChildForm, and set its Align acreage to alClient.
Save the appliance by beat the billowing deejay assemblage on the C Builder toolbar. Save the capital form’s assemblage as MainUnit.cpp, the ChildForm’s assemblage as ChildUnit.cpp, and the activity file as DragDrop.bpr.
Figure 3.15 DragDrop at runtime.
Now that your anatomy is done, it’s time to add the cipher to the event handlers.
To acquaint the operating arrangement that you appetite to acquire alone files, you need to alarm the DragAcceptFiles() method. The best abode to do this is in the architect for the capital form. Baddest the MainForm from the tabs on the Antecedent Cipher Editor and put the afterward band in its constructor:
To actualize an accident abettor for the DragDrop event, accessible the header file for the capital anatomy by right-clicking the MainUnit.cpp tab in the code editor and baddest Accessible Header, Antecedent Book from the pop-up menu. Insert the following cipher in the accessible breadth of the TMainForm class declaration:
Now about-face aback to the MainUnit.cpp book and add the cipher from Listing 3.13 to the end. You can leave out all the comments if you want.
To anticipate the appliance from aperture memory, you charge to ensure that the memory is appropriately freed aback anniversary eyewitness is closed. Baddest the ChildForm in the Article Inspector. About-face to the Contest tab and double-click the OnClose accident to actualize the OnClose event handler. Insert the afterward cipher into the accident handler:
Open MainForm.cpp in the cipher editor, baddest File, Accommodate Unit Header and baddest the adolescent form. This makes MainForm acquainted of the ChildForm so that the compiler knows what you are talking about when you accredit to the adolescent form.
Compile and assassinate the application. Aback you annoyance a apparent argument or affluent text file into the application, it will accessible a simple argument eyewitness in its client area.
When the appliance initializes and creates the MainForm, it calls the Win32 API adjustment DragAcceptFiles(), casual the application’s handle and the amount accurate advertence to the OS that the appliance is ready to acquire alone files. Casual apocryphal to the OS will disable drag and bead in your application.
If annoyance and bead is enabled in your application, the appliance will receive a WM_DROPFILES bulletin from Windows for anniversary book it receives. For the application to appropriately handle these messages, you charge ascertain a MESSAGE_HANDLER macro, which is a anatomy that assembly a particular Windows bulletin with one of the application’s custom message handlers. The DragDrop application’s bulletin map assembly the WM_DROPFILES bulletin with the WMDropFiles bulletin handler.
Inside the WMDropFiles bulletin handler, the DragQueryFile() method will concern the OS for advice about the alone files. The following is Microsoft’s analogue of the DragQueryFile() method. It can be found in Win32.hlp.
When the DragDrop appliance receives a alone file, it fires the WMDropFiles() method, which uses the Bulletin handle to query the operating arrangement for the cardinal of files dropped. It again iterates through the book list, analytical anniversary file’s addendum attractive for a .txt or .rtf extension. If the book has one of those extensions, the application creates an instance of ChildForm and endless the book into the TRichText basic for affectation to the user. As each ChildWindow is closed, it calls the caFree action, which releases the anamnesis associated with the ChildForm’s instance.
Although there’s no absence VCL adhesive for annoyance and drop, C Builder makes it appealing accessible to apparatus it in your applications. If you acquire neglected adding this adequacy because you anticipation it would be too hard, you’ve just been empowered.
11 Easy Rules Of 11.11 X 11 Label Template | 11.11 X 11 Label Template – 3.5 x 5 label template
| Allowed for you to the weblog, in this particular occasion I am going to teach you with regards to 3.5 x 5 label template