chami.com/tips/
Last  Home  Next
 Internet
 Programming
 Windows


Click for details
Keywords
Delphi 2.x
Delphi 3.x
Delphi
Functions
Source Code

Downloads
surprise.pas

Surprise!

    See Also
  How to maximize without maximizing
  Life cycle of a form
  Windows, web pages, multimedia programs, all have backgrounds. How come your Delphi form doesn't?

This hint is a little surprise. So, you'd have to either read the code and understand what it does or try it out!

  1. Create a new application (select "File | New Application" from the main menu)
     
  2. Select the empty form and double click on it's "OnResize" event
     
  3. Change the generated "FormResize()" function to look like the following and run the program.
     

procedure TForm1.FormResize( Sender: TObject );
var
  R    : TRect;
  DC   : HDc;
  Canv : TCanvas;
begin
  R    := Rect( 0, 0, Screen.Width, Screen.Height );
  DC   := GetWindowDC( GetDeskTopWindow );
  Canv := TCanvas.Create;

  Canv.Handle := DC;
  Canvas.CopyRect( R, Canv, R );
  ReleaseDC( GetDeskTopWindow, DC );
end;
Listing #1 : Delphi code. Right click surprise.pas to download.

Doesn't do anything? Try resizing the form by dragging its top left corner while running the program.

 
Related Links Email Print 
Created on 4-Nov-1996. Updated on 14-Jan-1998. Source code colorized using CodeColorizer.
Copyright (C) 1996-99 Chami.com All Rights Reserved. Reproduction in whole or in part
or in any form or medium without express written permission of Chami.com is prohibited.
Information on this page is provided as-is without warranty of any kind. Use at your own risk.
Free Downloads | Products & Services | Privacy Statement | Terms & Conditions | Advertising Info