Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Fill the screen with your form Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
08-Jan-03
Category
VCL-Forms
Language
Delphi 2.x
Views
76
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Lou Adler

I'd like to resize a form and have it fill up the screen. But I don't want it to 
display over the Win95/WinNT taskbar. Is there a way to do this?

Answer:

I put the code in a component wrapper so all you have to do is drop the component 
onto any form, call the component's execute procedure in FormCreate, and voila! an 
instantly sized form that fits nicely within your screen, above the Taskbar.

For Non-Windows 95 users, your form will be sized to maximized, but will be still 
be FormStyle := wsNormal. Select the text below, put it in a file, save the file as 
SizeTask.pas, add into your component library, drop it into a form, and watch it go!

1   unit Sizetask;
2   
3   interface
4   
5   uses
6     SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
7     Forms, Dialogs;
8   
9   type
10    TSizer = class(TComponent)
11    private
12      { Private declarations }
13    protected
14      { Protected declarations }
15      procedure SetSize(MyForm: TForm);
16    public
17      { Public declarations }
18      procedure Execute;
19    end;
20  
21  procedure register;
22  
23  implementation
24  
25  procedure TSizer.Execute;
26  begin
27    SetSize(TForm(Owner));
28  end;
29  
30  procedure TSizer.SetSize(MyForm: TForm);
31  var
32    TaskBarHandle: HWnd; { Handle to the Win95 Taskbar }
33    TaskBarCoord: TRect; { Coordinates of the Win95 Taskbar }
34    CxScreen, { Width of screen in pixels }
35    CyScreen, { Height of screen in pixels }
36    CxFullScreen, { Width of client area in pixels }
37    CyFullScreen, { Height of client area in pixels }
38    CyCaption: Integer; { Height of a window's title bar in pixels }
39  begin
40    TaskBarHandle := FindWindow('Shell_TrayWnd', nil); { Get Win95 Taskbar handle }
41    if TaskBarHandle = 0 then { We're running Win 3.x or WinNT w/o Win95
42      shell, so just maximize }
43      MyForm.WindowState := wsMaximized
44    else { We're running Win95 or WinNT w/Win95 shell }
45    begin
46      MyForm.WindowState := wsNormal;
47      GetWindowRect(TaskBarHandle, TaskBarCoord); { Get coordinates of Win95 Taskbar }
48      CxScreen := GetSystemMetrics(SM_CXSCREEN);
49        { Get various screen dimensions and set form's width/height }
50      CyScreen := GetSystemMetrics(SM_CYSCREEN);
51      CxFullScreen := GetSystemMetrics(SM_CXFULLSCREEN);
52      CyFullScreen := GetSystemMetrics(SM_CYFULLSCREEN);
53      CyCaption := GetSystemMetrics(SM_CYCAPTION);
54      MyForm.Width := CxScreen - (CxScreen - CxFullScreen) + 1;
55      MyForm.Height := CyScreen - (CyScreen - CyFullScreen) + CyCaption + 1;
56      MyForm.Top := 0;
57      MyForm.Left := 0;
58      if (TaskBarCoord.Top = -2) and (TaskBarCoord.Left = -2) then
59        {Taskbar on either top or left }
60        if TaskBarCoord.Right > TaskBarCoord.Bottom then { Taskbar on top }
61          MyForm.Top := TaskBarCoord.Bottom
62        else { Taskbar on left }
63          MyForm.Left := TaskBarCoord.Right;
64    end;
65  end;
66  
67  procedure register;
68  begin
69    RegisterComponents('Samples', [TSizer]);
70  end;
71  
72  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC