community.borland.com

Article #15511: Creating an OWL app withoug a border and caption

 Technical Information Database

TI511D.txt   Creating an OWL app withoug a border and caption
Category   :OWL
Platform    :All
Product    :Pascal  All

Description:

Sometimes programmers of OWL applications want to open a
main window that has no border, no caption, and which
fills the entire screen.  The following example shows
how to do this.

To get started, override the Init Constructor.  Then set
the Windows style to WS_VISIBLE and WS_POPUP:

  Attr.Style := ws_Visible or ws_PopUp;

After doing this, the program will appear with no
border and no caption.  However, the window will not
be visible unless you define its size.  To give the
program a shape, assign it a width and height:

  Attr.X := 100;
  Attr.Y := 100;
  Attr.H := 200;
  Attr.W := 200;

Of course, if you want to show the window in a maximized
state, then you can simply send it a WM_SYSCOMMAND message
from the programs SETUPWINDOW procedure:

  procedure TStepWindow.SetUpWindow;
  begin
    inherited SetUpWindow;
    PostMessage(HWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
  end;

To sum up, the shortest way from point A to point B is to
first give the window the WS_POPUP style, and then
maximize it with the WM_SYSCOMMAND message.  If you
want to create a window that is not maximized, then be
sure to set the window's width and height.  The example
below shows a maximized window:


program NoCaption;

uses WinTypes, WinProcs, OWindows, Strings;

type
  PStepWindow = ^TStepWIndow;
  TStepWindow = object(TWindow)
    constructor Init(P: PWindowsObject; AName: PChar);
    procedure SetUpWindow; virtual;
    procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
      virtual;
    procedure WMLButtonDown(var Msg: TMessage);
      virtual wm_First + wm_LButtonDown;
  end;

  TMyApplication = object(TApplication)
    procedure InitMainWindow; virtual;
  end;

constructor TStepWindow.Init(P: PWindowsObject; AName: PChar);
begin
  inherited Init(P, Aname);
  Attr.Style := ws_Visible or WS_PopUp;
{  Attr.H := 200;
  Attr.W := 200; }
end;

procedure TStepWindow.SetUpWindow;
begin
  inherited SetUpWindow;
  PostMessage(HWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
end;

procedure TStepWindow.WMLButtonDown(var Msg: TMessage);
begin
  CloseWindow;
end;

procedure TStepWindow.Paint(PaintDC: HDC;
                     var PaintInfo: TPaintStruct);
var
  S: array[0..100] of Char;
begin
  StrCopy(S, 'Click on Window to close it');
  TextOut(PaintDC, 10, 10, S, StrLen(S));
end;

procedure TMyApplication.InitMainWindow;
begin
  MainWindow := New(PStepWindow, Init(nil, 'Steps'));
end;

var
  MyApp: TMyApplication;

begin
  MyApp.Init('Steps');
  MyApp.Run;
  MyApp.Done;
end.


Reference:


7/16/98 4:33:46 PM
 

Last Modified: 01-SEP-99