Life
After Delphi

Thinking about making the switch over from Delphi to Power++? Maybe you just want to see what Power++ has to offer you. Or perhaps you have already made the decision to use Power++, but need that last push to get you going (or to get your boss going with you). This is the page for you. This page was not intended to be a tutorial (though it might be all you need if you are already familiar with both Delphi and C++). For more information about learning to develop with Power++, see the last section of this page, Where Do We Go From Here.

First Step - Download the Evaluation

You have to actually experience Power++, before you can evaluate it. Powersoft has made available the Power++ Test Drive. You may download the full version, or versions with samples and/or help and/or Sybase SQL Anywhere removed. The Test Drive is a fully-functional version with no redistribution rights. Link to the following web page, and fill out the form. You will be brought to a page which will let you download the desired version of the Test Drive. If at first the server responds with an error, try again and things should work nicely.

And While You Are Waiting...

Great things come to those who wait. And wait is what you will do while downloading the Power++ Test Drive, unless you have a very fast connection. :) This being the case, you might want to read a review comparing Power++ with other similar development tools. This review, by PC Week, compares the Power++ with Delphi, Visual Basic, and Clarion. Don't forget, that the article was written after the release of Power++ version 1.0, so it doesn't take into account all that has changed in the current release (v1.5), and only handles the Developer version of Power++, rather than the Professional or Enterprise versions which were only made available when version 1.5 was released. Some of the main weaknesses mentioned in the review - lack of advanced optimization options, database driver support, and some others - are obliterated with the release of 1.5.

Start Your Engines!

So, you have downloaded the program and installed it. You are ready to start optimizing. Go for it! If you are familiar with Delphi's interface, you are already familiar with the basics of Power++. The component palette is self explanatory, and contains all the standard controls you might expect. The standard toolbar contains a few useful tools by default, but if you don't like it, you can customize it to include toolbar buttons for any Power++ feature you choose, by choosing Toolbars from the View menu. It is probably best not to change anything before you get familiar with Power++, but it is nice to be able to customize Power++ when you are more comfortable with it.

Inspector Gadget

You may be wondering where the Object Inspector is. Power++ includes one, and those accustomed to Delphi will initially be inclined to use it as the primary method of manipulating an object's properties. People who have used Power++ for a while though, even coming from a Delphi background, will eventually tune in to Power++'s main way of changing properties - you may be uncomfortable with it at first, but it turns out to be a quicker and more intuitive method in the majority of cases.

The command button control can be accessed from the right-most tool button on the standard tab page of the component palette. Click on it once, then click on the form to drop it there. Move it to somewhere around the bottom right corner of the form. Move the mouse around on the form and watch the status bar located on the main Power++ window. Notice that as you move the mouse over the command button, the status bar reflects to show its name, and class - never again will you have to select an object to find out its name while coding. You won't even have to shift the focus away from the code editor if your form is visible; simply move the mouse over the desired object and continue programming with your train of thought still intact.

Now right-click on the command button and choose Properties. In Power++, double-clicking on an object displays its property sheet, as opposed to creating an event handler for that object as in Delphi, so you could have double-clicked on the command button instead. The property sheet method of setting control properties turns out to be quicker than the object inspector for a few reasons. Consider the General tab - the first one which is presented to you. Here, are all of the most commonly used properties, separated from the rest. So, for instance, if you want to set the Text property of the command button (its visual label), you would open up the command button's property sheet, and be confident that the Text property would be one of the first things you see. Try changing the Text property now to something like, 'Click Me', and hitting the 'Apply' button - notice how the command button on the form is updated to reflect the changes.

Along the same lines, what if you wanted to change the dimensions of the object? You would always know that everything you would need would be in the Size tab. One could argue that knowing to look for Width in the object inspector would be just as obvious - which is true - but it often follows that you would then want to change the height of the object, and 'H' is a long way from 'W'... A more logical approach would be to group together all dimension-related controls, and this is exactly what the Size tab is for. But now that you are looking at the Size tab page, what are these Resize Percentages? Therein lies another nice feature of the property sheet. Right-click where it says Left Percentage, and choose 'What's This'. Rather than bothering with the online help, which would be overkill just to find out what a particular property does, the context help in property sheets will be your best friend in Power++. Now that you have read what the Left Percentage property does, set the Left Percentage to a value of '100', and click OK to apply the changes and close the property sheet.

Now run the program by choosing Run from the Run menu, or by clicking the Run toolbar button which depicts a green person running, superimposed over a file. (Note that the first build is always slower than subsequent builds in Power++. Still, don't expect it ever to get quite up to the compiling speed of Delphi - Pascal and C++ are very different languages, and a C++ compiler has much more work to do than a Pascal compiler.) Now that your program is running, try resizing it. Notice how the command button's right side remains glued to its position relative to the right side of the form - and without writing any code! From this, you can imagine how fooling around with the different Resize Percentages properties, and different values for them can create almost any effect you want. Take a deep breath and repeat: "I will never write another resize event handler again."

Events: As Far As The Eye Can See

After closing the running version of your newly designed, world-class button on a form application, bring up the form's property sheet in the same way you brought up the command button's property sheet (double-click on the form). For now, just change the titlebar text of the form to read something like 'Default Title' by editing the Text property of the form on the General tab page, in the same way it was done with the command button. While you are in the form's property sheet, glance through the different tab pages to see some of the properties that can be changed. You will notice that Power++ gives you control over essentially all the properties of a form, many of which you might need to access manually through the Windows API with Delphi, if you desired to use them. Click OK to apply the new title bar text.

Even in the case of events, you usually don't need to touch the Object Inspector (which we still have not looked at, but will shortly). For instance, 99% of the time you wish to write an event handler for a command button, it is one which is associated with the Click event for that button. Let's write a simple Click event handler for our 'Click Me' button that changes the titlebar text of the form, as well the text label for our command button that is to be clicked. Right-click on the command button. The first item in the popup menu is Events which leads to a sub-menu which lists the most common events for that particular control - in the case of a command button, only Click. Ignore the More choice for now, and choose the Click item. Finally we are brought to the code editor of Power++.

Some notes before we go on. You will notice that the event handler created is of the form:
    WBool FunctionName( WObject * source, WEventData * event )
In fact, all event handlers are of this form, where source is a pointer to the object that called the event (all visual objects in Power++ are descendants of WObject), and event is a pointer to a structure which contains information relevant to the event. event is a pointer to an object of type WEventData, or of some type derived from WEventData (for example, in a MouseMove event, the event parameter would be of type WMouseEventData, and would contain such useful information as the position of the mouse when the event was fired). This is important, because it means you can assign any type of event to the same event handler if it suits your needs in your program. You will also notice that the event handler returns a boolean result. Power++ has a powerful feature known as chained event handlers which we will not go into detail about here. But assume that there is a default Click event assigned to your button, even before you assign one yourself - this event takes care of default background nitty gritty click stuff. When you assign your own Click event handler to the button, rather than replacing the existing one, it is chained on top of it and executes before it when the button is clicked. If your Click handler returns FALSE (as it will 90% of the time), the default handler will execute after yours to finish the job. If your even handler returns TRUE (not usually what you want), default (and other) event handlers that yours is chained on top of are ignored, and you are saying, "I have done everything to handle this event, don't do anything else."

Now add two lines of code (in bold below) to the event handler created for you, so that it looks something like this (don't forget that C++ is case-sensitive, so type the lines exactly as they are here):

WBool Form1::cb_1_Click(
    WObject *           source,
    WEventData *        event )
{
    SetText( "New Title!" );        // Set the titlebar text
    cb_1->SetText( "Clicked!" );    // Set the button's text label
    
    return FALSE;
}
Run the program just to see that it does what the comments say it will when you click the button. To put things into perspective, if this were Delphi the lines might have looked something like this:
    Text := "New Title!";
    cb_1.Text := "Clicked!";

As opposed to Delphi's way of accessing properties as sort of variables, Power++ uses Get and Set methods for accessing an object's properties. This was done because C++ lacks an equivalent to Object Pascal's published properties. Getting used to Power++'s way of handling properties, is simply a matter of using it, but aside from this, there are also some interesting advantages to using methods to access properties. Power++ takes advantage of the ability to overload functions in C++. For example, if you have a simple status bar named StatusBar, with only one text area, you could use one form of the Text property's Get and Set methods, as in:

WString oldStatus = StatusBar->GetText(); // Get the old status text and stick
                                          //     it in a string variable 'oldStatus'
StatusBar->SetText( "New Status Text" );  // Set some new status bar text
But imagine that your status bar was divided into 3 parts; in this case you could use another form of the Text property's Get and Set methods, like this:

WString status = StatusBar->GetText( 1 ); // Get the status text from the *second* part
                                          //     of the status bar, and stick it in a
                                          //     string variable 'status'
StatusBar->SetText( 2, "Third Part!" );   // Set the status text of the *third* part of
                                          //     of the status bar

What if you wanted to create an event handler other than Click for the command button? Finally we will need to use the Object Inspector. Right-click on your command button. Notice that Click is checked off in the Events sub-menu indicating that you have associated a handler with that event. All events which you associate with a handler at design time will appear on this list with a check next to them (even ones that aren't here before you associate a handler with them), which gives you a quick way to check if a particular event of an object is being handled, and also gives you a quick way to access that event handler (by clicking on it in this list). Now click on More to bring up the Object Inspector with the full list of possible events for this button. If you are thinking to yourself, "err... this is a big list," I don't blame you. Power++ gives you a lot of power, providing you with direct access to almost any event you could want. Some event which might require using obscure windows messages in Delphi, would probably be directly supported in Power++.

Go down the list until you find the LeftButtonDown event (you can hit the 'L' key twice to get there). Click on it once so that it is selected, and then click on the '...' button to create an event handler for it. Add the following lines of code, in the same way you did for the Click event:

WBool Form1::cb_1_LeftButtonDown(
    WObject *           source,
    WMouseEventData *   event )
{
    SetText( "Down Title!" );    // Set the titlebar text
    cb_1->SetText( "Down!" );    // Set the button's text label
    
    return FALSE;
}
Run the program, click and hold down on the button, and then release the mouse button. What do you think would happen if we changed the last line of our LeftButtonDown event handler to 'return TRUE;' instead of 'return FALSE;'? Try it out and see the expected effect. Note that if you double-click, you will be able to get the Click event to fire on the second click of the double-click. To stop that as well, you would need to return TRUE in a handled LeftButtonDouble event (which you can try if you wish). Now close the code editor and the Object Inspector. What if you made a mistake in the code of your LeftButtonDown event handler? Simply right-click on the Command Button, and find that the desired event is now located, with a check mark beside it, in the Events sub-menu of the button's popup menu. You can click there if you wish to edit it.

Visual Design

The Text Box control is accessible from the fourth tool button on the standard tab page of the component palette. Use it to saggar some Text Boxes around the form: first put one near the bottom of the form, then one near the top, then one in the middle, then one below that, then one above the middle one. Place them so that they are not all aligned horizontally; change some of their sizes as well. Now it is time to set their tab stops, so that they are logically ordered from top to bottom. Don't squirm! :) In fact, you can do it in three mouse clicks. Right-click on the form and choose Edit Tab Stops. In the Tab Editor, you can change the tab order, and specify which controls are included in it, but you almost never need to do this manually. Instead, click the Auto Order button, and presto! Click OK, run the program, and go crazy with the tab key.

There is a situation in which the Object Inspector is easier to use than the property sheet, which is when you want to set a property of multiple objects to the same value - for instance, setting all Text Boxes so that they have the same value for their Left property. But there is a much easier and more visual way to do this. Select all of the text boxes you have placed on the form, and right-click on the one whose current left position looks nice. Form the Align sub-menu, choose the first item and watch the magic. Now right-click on one of the Text Boxes again, and choose the second to last item in the Align sub-menu (you will only be able to see this nice effect if some of the Text Boxes are of different widths). You can align the right side of the Text Boxes by choosing the second item from the Align sub-menu. Now again align the left edges of the Text Boxes. Right-click on the Text Box whose Width property you like. From the Same Size sub-menu, choose the second item. Now wasn't that fun? :)

Advanced Thingies

From the View menu, choose Classes. As you might expect, this brings up the Classes View. On the left pane of the window, all the different classes which you have created and are using in your project are listed. You will notice that your form is listed here - this is because forms you design in Power++, are classes, and the name you assign to a form at design time is its class name, rather than its instance name. Notice the little green running person next to your form's class name - this indicates that this is the Main Class of the program, and an instance of this form is created and displayed when your program runs. If you had created other forms in this project, they would be listed here as well, and you could right-click on the desired one and choose Main Class to make it the Main Class in your program. On the right pane, all the methods of the class selected to the left are listed. You can rename and delete these functions here, or double-click on one to bring up the code editor, with the function code at the cursor (you could also double-click on the class to the left to bring up the class code).

View / Objects shows the hierarchy of objects used in your program. You can also change an object's properties here, delete it, or edit one of its associated events. View / Files lets you inspect the files associated with your project, delete the ones not needed, and add new ones. View / Debug Log allows you to take advantage of Power++'s advanced memory usage checks and Validity Checks. In the debug log window, choose Options from the View menu to set these up. View / Error Log brings up a log of all the errors in your project. Power++ has a great way of displaying coding errors - it actually inserts the error message into the code itself, and erases it when the problem is fixed. Try it yourself - in an event handler, write some nonsense code, and try to run the program. Apart from these in-line error messages, the Error Log keeps a list of all the errors and warnings in a more traditional fashion, and lets you link to their position in the code, by double-clicking on the message. You can get help on the message by right-clicking on it (in either the Error Log, or directly in the editor), and choosing Help.

Choose Resources from the View menu. Here you can add bitmap, cursor, icon, string, and user defined resources, all of which can then be used from within your program. You can also edit the version resource, which is the information about your program that is accessible to users from the Version tab when they right-click on your program's EXE from explorer, and choose Properties. Click on Icons in the left pane. You can add as many icon resources as you wish to your project. Double-click on Form1 to bring up its property sheet. You will notice the Icon property at the bottom of the General tab. If you drop down the associated combo box, you will see the default ICON_1 from the Resource View listed there - choose it and click OK. If you had added other icons to the Icons Resource, they would be listed here as well. You could use the same icon on as many forms as you like without fear of increasing program size, since the only copy of the icon is stored in the resources.

Now choose Targets from the View menu. Here you can specify which target you want to build, by selecting it in the drop-down combo box. A green check mark next to each item indicates that its Build Status is up to date. You can also change all the options for the currently selected target. For example, right-click on the project name (the root item in the treeview), and choose Properties. Here you can change general project properties; for instance, the Executable Size tab page lets you specify weather or not to use the runtime DLL. Close this property sheet, and bring up the property sheet for applic.wcx. You can change to the Optimization tab and take a look at all the optimizations that you have power over.

Where Do We Go From Here?

This page has just glanced over a few of the interesting differences (and some of the similarities) between Power++ and Delphi. Many issues are, however, entirely beyond the scope of this page. For example, some great features of Power++ include the amazing DataWindow, support for Win32 console applications, FDX (Form Data Exchange), the entire component library of Power++, the Power++ Reference Card, and of course the C++ language itself.

If you have a background C programming, the Getting Started section of the Power++ help system may be all you need to learn the essentials of C++ and start programming real applications in Power++. If, however, you have no experience in either C or C++, it is recommended that you read a good book on the topic. A great tutorial available on the web for learning C++ is by Coronado Enterprises. The tutorial assumes you are already familiar with C programming. If you are not, another tutorial is available, from the same source, on C programming, which you can read as a primer to the C++ tutorial. Both of these books are available for reading on-line here:

Even if you are not already familiar with C++, you can still do some real programming in Power++ by taking a look at some of the many example programs that come along with Power++, and getting the jist of things from them. In fact it is recommended that you do this in any case, since learning by example is often the best way to grasp the idea behind something. And, of course, the Power++ Component Library Reference is the ultimate reference to all the properties, methods, and events for the different components in Power++ - press the F1 key while a component is selected to bring up its help topic in the reference. Power++ has a lot to offer the power programmer and database developer. Give it a try, and you might not want to ever leave it.


Remember, this web site is here for you and people like you. So if you have anything that others might find useful, let me know, and I'll post it here. E-mail me, Andre Schild at a.schild(at)aarboard.ch, or fill out the form at the bottom of the main page.
Hope to hear from you soon!


Back to Absolute Power++.