Board index » delphi » loading and drawing a bitmap witout a form

loading and drawing a bitmap witout a form

hi
is possible draw a bitmap (an then erase it) using win api, without
creating any form?

i want to load a splashscreen (bitmap) before the creation of all my forms,
adding code to the progect source, and then remove it when the main form is
active.

TIA.

GG

 

Re:loading and drawing a bitmap witout a form


GG <ban...@usa.net> skrev i artiklen
<01be00fd$74de3c80$b3e67...@giacomo.etere.com>...

Quote
> hi
> is possible draw a bitmap (an then erase it) using win api, without
> creating any form?
> i want to load a splashscreen (bitmap) before the creation of all my
forms,
> adding code to the progect source, and then remove it when the main form
is
> active.

There is no need to use win api to do this.
Inprise and many other places on the internet has examples how to show a
splashscreen using a normal form.

Re:loading and drawing a bitmap witout a form


You *can* do it this way by creating a bitmap, setting its size, and then
drawing on the bitmaps canvas. Then just copy the bitmap to the screen.
However, I think you really should use a borderless form for your splash
screen.
For one thing, the splash image will refresh if it gets obscured,
which the first method will not do.
Quote
GG wrote in message <01be00fd$74de3c80$b3e67...@giacomo.etere.com>...
>hi
>is possible draw a bitmap (an then erase it) using win api, without
>creating any form?

>i want to load a splashscreen (bitmap) before the creation of all my forms,
>adding code to the progect source, and then remove it when the main form is
>active.

>TIA.

>GG

Re:loading and drawing a bitmap witout a form


Quote
GG wrote:
> is possible draw a bitmap (an then erase it) using win api, without creating
> any form?

> i want to load a splashscreen (bitmap) before the creation of all my forms,
> adding code to the progect source, and then remove it when the main form is
> active.

The simplest window program requires that you create a window into which you
can write text or graphics.  If you use straight API calls, and are not doing
something like writing to the desk top, your splash screen will require that
you create a window, register it, assign whatever resources you need, then draw
a bitmap.

While I'm sure that the inclusion of a form will make the program slightly
bigger overall, it is an irrelevant number, especially when one considers the
amoutn of code one saves.
--
Wayne Herbert
Manager, Computer Products
Key Maps, Inc.
1411 West Alabama
Houston, TX  77006

Vox:  713.522.7949
Fax:  713.521.3202
Email:  wherb...@keymaps.com

"Everywhere I go, I'm asked if I think universities stifle writers. My opinion
is that they don't stifle enough of them."

Flannery O'Connor (1925-1964)

Re:loading and drawing a bitmap witout a form


Yes you can do it.  What you need to do bitblt the bitmap to the screen by
using a window handle of 0.  

Of course like others have said.  You don't gain a whole heck of a lot by
doing this.

Jeff

Re:loading and drawing a bitmap witout a form


Yeah - what they said.

Actually this is really easy to do.
Like the others suggested, add a simple form to your project.
Drop a TImage component on the form and load your image into it.
Change the form to a dialog type or whatever border style you like -
(I prefer to not show the standard title bar and system buttons).
Save the Form/Unit.
Now - bring up the Project Manager/Options dialog and move your
splashscreen form/unit from the auto-create list to the available
forms list.
Then view the project source (the .dpr file - find it in the Project
menu).
This is where you create and destroy your splash screen at program
startup.

Assume we have an app named "MyProgram" which has a main form and 2
other forms.  I named the splash screen form "frmSplash".

Here is the project source:
--------------------------
program MyProgram;

uses
  Forms,
  MyProgU in 'MyProgU.pas' {frmMain},
  Form2U in 'Form2U.pas' {frmSecond},
  Form3U in 'Form3U.pas' {frmThird},
  SplashU in 'Splashu.pas' {frmSplash};

{$R *.RES}

begin
  Application.Initialize;

// Create and display the form here...
  frmSplash := TfrmSplash.Create(Application);
  frmSplash.Show;
  frmSplash.Update;

// The auto-create forms...
  Application.CreateForm(TfrmMain, frmMain);
  frmSplash.Update; // optional
  Application.CreateForm(TfrmSecond, frmSecond);
  frmSplash.Update;  // optional
  Application.CreateForm(TfrmThird, frmThird);

// Now get rid of the splash screen
  frmSplash.Hide;
  frmSplash.Free;

// Let the app run
  Application.Run;
end.

If the splash screen gets messed up due to a lengthy load process or
whatever, you
can insert calls to the update method of the form between the
Application.CreateForm
statements to force it to repaint.

Luck,
DL

Other Threads