Tuesday, July 12, 2011

Sunday, July 12, 2009

A way to ensure your delphi elements appear just like you want them to

Constrain your form's size and position at runtime automatically

A way to ensure your elements appear just like you want them to! Automatically constrains forms at runtime, at the size used in designtime! You could say this one enables constraints at default, but WITH the ability to change it in designtime any way you like. Normally, setting constraints to any maxwidth etc, will not allow you to change your mind after that, unless you change the maxwidth etc again. This one lets you change it to any size you want in designtime, while keeping the constraints enabled! It is set to Active:= True by default, which, enables the component but can be set to Active:= False which disables it.


Download

How to create a form in a form in delphi

How to create a form in a form?

Three easy examples of how to create a Form in a form, so that the second [and third, fourth etc] is inside the first form. It has an example of a form without a titlebar [bsNone], one with a form that is resizeable and moveable, plus one that is not resizeable and moveable. It also includes a template for a starting point should you wanna create a form-in-a-form.


Borderstyles

Note that borderstyle bsDialog presents you with only a close icon normally but if you use that in the Form-in-a-form, it has no effect in the Not_Moveable_Resizeable version, it will show up but will not be clickable. Same counts for bsResizeable, the icons will show up but will not be clickable You will have to experiment what normal settings do with a form-in-a-form

Moveable and Resizeable Form-in-a-form

While the code in Unit2.pas makes sure you can move and resize the form you should also note that the BorderStyle of the form2 is set to bsSingle. Since setting this to bsSizeable does not result in the form2 being moveable and or resizeable, it only gives you the resize cursor when you hover over each of the 4 sides of the form itself, which serves no purpose to me. Also, the Captionbuttons [border icons] were removed, and the position was set to poDefaultPosOnly, plus the scrollbars were removed, these were the settings that differ from the defaults, change it the way you wish.
Not Moveable and Resizeable Form-in-a-form

While the code in Unit2.pas makes sure you cannot move and resize the form you should also note that the BorderStyle of the form2 is set to bsSingle. Since setting this to bsSizeable does not result in the form2 being moveable and or resizeable, it only gives you the resize cursor when you hover over each of the 4 sides of the form itself, which serves no purpose to me. Also, the Captionbuttons [border icons] were removed, and the position was set to poDefaultPosOnly, plus the scrollbars were removed, these were the settings that differ from the defaults, change it the way you wish.

No Titlebar Form-in-a-form

The borderstyle of Form2 was set to bsNone, and the position was set to poDefaultPosOnly. A bevel was added to the form2 but this was to make it appear and also it looks nice to me.

Template_Mainform

Just a quick and easy starting point should you wanna create a Form-in-a-form


Download

How to create your own delphi splash screen in less than 3 minutes

Build your own splash screen in a few minutes

This is a basic and very short tutorial for creating your own splash screen. The best way to learn Delphi is to have an example, and study the code. Do not rely on 3rd party components when you do not have to! Create your own splash screen in less than 3 minutes. Following this tutorial, you will learn to create a splash screen, that can be disabled by unchecking a checkbox on the mainform, it makes use of an Inifile to store the value and enable and disable the appearance of the Splashscreen. About the included example, to test the splash screen a simple restartbutton was added to it, in order to make that work Shellapi was added to the uses clausule of Form1.

A quick and easy way to spice up your program!

Of course a splash screen that has the default color and is empty, is not really cool so add an image to it, or anything you want to appear there, see the included example for a simple basic idea, but technically speaking you are finished and have just created your own Splash Screen, and you no longer have to rely on 3rd party components! Here is an some example I used:

Naming conventions

Note that variables can be called anything you wish [except for keywords etc], it is good practice to name them to something useful, so the name of it already tells you at least a bit what is it about. Then if you are finished with your project you can always do a search and place to make the variables shorter [saving a bit of space] and making them more difficult to guess, should you wanna'. Also, it is a good thing to name the components, and the forms, and units to something meaningful. The advantage of properly named forms, are so you can tell them apart from the standard forms with names given to them by delphi itself, and they wont be written over accidentally easy, plus it is easier to work with them in a single project that has more forms. However, for ease of use of this tutorial, I used the standard names. Also, for your own sake [readability] it is best to name your forms like something more clear. In this tutorial however, I used the standard names Delphi gives them, to not make it more complex and lengthy. My own splash screen would be named something like: SplashForm, while Form1 would be named: MainForm. Same goes for components, Checkbox1 does not say anything what it is used for or what it is about, I myself would name it something like: chkSplash. Note that variables can be called anything you wish [except for keywords etc], it is good practise to name them to sumthing useful, so the name of it already tells you at least a bit what is it about. Then if you are finished with your project you can always do a search and place to make the variables shorter [saving a bit of space] and making them more difficult to guess, should you wanna'. Also, it is a good thing to name the components, and the forms, and units to something meaningfull. The advantage of properly named forms, are so you can tell them apart from the standard forms with names given to them by delphi itself, and they wont be written over accidentally easy, plus it is easier to work with them in a single project that has more forms. However, for ease of use of this tutorial, I used the standard names.

The position can and maybe should be altered too, but this is purely personal, so I did not discuss that. In the included example, position of Form1 was set to poDesktopCenter, and position of Form2 was set to poMainformCenter, so the splashscreen appears centered in where the Form1 will appear. Also, for your own sake [readability] it is best to name your forms like something more clear. In this tutorial however, I used the standard names Delphi gives them, to not make it more complex and lengthy. My own splashscreen would be named sumthing like: SplashForm, while Form1 would be named: MainForm. Same goes for components, Checkbox1 does not say anything what it is used for or what it is about, I myself would name it sumthing like: chkSplash. Click here for the tutorial to see it online, but that is again the limited version.
Demo Delphi Application included in the download link here.

How to write your own Delphi progress bar in less than a minute

Create your own delphi progress bar

This very short tutorial shows you how to add a progress bar to any web browser programs you make in less than a minute. It is very basic, and kept as short as possible, you can figure out most of the code just by looking at it. Aimed at beginners, this gives you an easy and quick way to have a working progress bar which informs the user of the progress the web browser is making! You can then focus on the other tasks like for instance the graphical representation to make it the way you want it. Included is the completed example. I hope this little bit of conceptual knowledge will help you. Because the Delphi Help Api does not provide these things. I like to hear your opinion, comments, problems you may have while using this helpfile, this goes for all of my published stuff, please email me.



Download
 

html statistics
Cheap Flowers