Home |
Automatic Named Pointers |
Automatic Named PointersSimilar to automatic temporary pointers, Automatic Named pointers are created on the execution stack and only exist during the class constructor. Named pointers are created by typing a name into the "Pointer Name" field in the object properties dialog basic properties page and unchecking the "Member Pointer" box. Note that the name must be a valid C++ variable name or your compiler will flag an error when you compile the generated module (no name checking is done by Window Builder). Automatic Named pointers are very handy to you, the developer, when you want to modify the object created by Window Builder in ways that are not supported by the Window Builder properties pages. An Automatic Named pointer is used only for the object in question, and more importantly is still valid and available to you at the end of the class constructor (i.e. after the "/* WindowBuilder End Construction */" marker). This allows you to further modify an object by calling class member functions via the named pointer prior to returning from the class constructor. Named pointers also help to improve the syntax and eliminate casting when Window Builder must call member functions of a class. For example, if Window Builder must call the "SetFont" function for a PegPrompt, it will cast a temporary automatic pointer as follows: ((PegPrompt *) pChild1)->SetFont(...); If an automatic named pointer is used, it will be a pointer to the desired type and no casting is required: PegPrompt * MyPrompt; MyPrompt = new PegPrompt(...) MyPrompt->SetFont(...); This can greatly improve the appearance and readability of the constructor source code produced by PEG WindowBuilder.
|