![]() |
for Ivory Draw 1.0 A simple program that shows an image. |
Introduction
Here is the first Ivory Draw tutorial, which explains how to go to exclusive mode and display a picture on the screen.
Creating the Application Form
First create a new application, then drop down a TIvoryDraw, a TIvorySurface, a TIvoryBitmap, and a TIvoryPalette component on the main form. Next, change the following settings in the Object Inspector:
Form1->Color = clBlack IvoryDraw1->UserBackSurface = IvorySurface1 IvoryDraw1->ExclusiveMode = true IvoryDraw1->Palette = IvoryPalette1 IvorySurface1->BackgroundBitmap = IvoryBitmap1 IvorySurface1->DrawBackground = true IvoryBitmap1->FileName = Ivory.bmp IvoryPalette1->FileName = Ivory.bmpThis requires a little bit of explanation. First of all, you set Color property for the form to clBlack, or whatever you like. When your program starts, it will display the form for a moment in the color you specified in the Color property.
Then you make the surface component the backbuffer surface by assigning it to the UserBackSurface property for IvoryDraw1. It's a good practice to create a new surface and make it the backbuffer surface, because this way you can have full access to the surface properties at design time. If you don't assign a backbuffer surface to UserBackBuffer, then TIvoryDraw creates an own surface automatically, which can only be manipulated at runtime.
Next, you set ExclusiveMode to true, allowing Ivory Draw to use the whole screen exclusively. This means you won't be able to debug your application, but I don't think it's a big problem in such a simple case, right? If you want to debug an Ivory Draw application, you must set ExclusiveMode to false. If you forget about it, you might hang up Windows 95. Windows NT cannot be hung up this way, but it's not a good practice to always shut down your program, or maybe the whole IDE, from the Task Manager.
Then you assign a palette and a background bitmap to the surface, and enable the background bitmap. Finally, you set the background bitmap file name for both the image and the palette components. That's all you need to do to set up a background image on the backbuffer surface.
Writing the code
Now you only need to provide a way to exit the application. The simplest way is to write an OnKeyPress event handler like this:
void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key) { Close(); }Congratulations! You have written your first Ivory Draw application. Now you can compile and run.