• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Delphi中窗体全屏组件

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

由于经常要用到窗体全屏功能 所以把他封装成了一个组件 这是主要代码

 

1 {*******************************************************}
2  { }
3  { TFullScreen }
4 { Ver 0.1.1 }
5 { Copyright(C) 2006-2007 Unruly Wolf Soft }
6 { }
7 {*******************************************************}
8
9 unit FullScreen;
10
11 interface
12
13 uses
14 SysUtils, Classes,Forms,Windows;
15
16 type
17 TFullScreen = class(TComponent)
18 private
19 { Private declarations }
20 FFullScreenMode : Boolean;
21 FForm : TCustomForm;
22 OldState,OldHeight,OldWidth,OldX,OldY:Longint;
23 FOldState:TWindowState;
24 FBeforeFullScreen:TNotifyEvent ;
25 FAfterModeChanged:TNotifyEvent ;
26 FAfterFullScreen:TNotifyEvent ;
27 FExitFullScreen:TNotifyEvent ;
28 Procedure SetFullScreenMode(aVal:Boolean);
29 protected
30 { Protected declarations }
31 public
32 { Public declarations }
33 property FullScreen : Boolean read FFullScreenMode write SetFullScreenMode;
34 property FormMain : TCustomForm read FForm write FForm;
35 procedure SaveOldWinState;
36 published
37 { Published declarations }
38 property BeforeFullScreen : TNotifyEvent read FBeforeFullScreen write FBeforeFullScreen;
39 property AfterModeChanged : TNotifyEvent read FAfterModeChanged write FAfterModeChanged;
40 property AfterFullScreen : TNotifyEvent read FAfterFullScreen write FAfterFullScreen;
41 property ExitFullScreen : TNotifyEvent read FExitFullScreen write FExitFullScreen;
42 end;
43
44 procedure Register;
45
46 implementation
47
48
49 //Save form state
50 procedure TFullScreen.SaveOldWinState ;
51 begin
52 if FForm<>nil then
53 FOldState:=FForm.WindowState ;
54 end;
55
56 procedure TFullScreen.SetFullScreenMode(aVal:Boolean);
57 begin
58 if aVal<>FFullScreenMode then
59 begin
60 FFullScreenMode:=aVal;
61 if FFullScreenMode then
62 //enter fullscreen
63 begin
64 OldState:=GetWindowLong(FForm.Handle, GWL_STYLE);
65 OldHeight:=FForm.Height;
66 OldWidth:=FForm.Width;
67 OldX:=FForm.Left ;
68 OldY:=FForm.Top;
69 SaveOldWinState;
70 if Assigned(FBeforeFullScreen) then FBeforeFullScreen(Self);
71 FForm.Left:=0;
72 FForm.Top:=0;
73 FForm.windowstate:=wsmaximized;
74 SetWindowLong(FForm.Handle, GWL_STYLE,
75 GetWindowLong(FForm.Handle, GWL_STYLE) AND NOT WS_CAPTION);
76 //FForm.windowstate:=wsmaximized;
77 FForm.clientHeight:=screen.Height;
78 FForm.Refresh;
79 if Assigned(FAfterFullScreen) then FAfterFullScreen(Self);
80 end
81 else
82 // Exit full screen
83 begin
84 SetWindowLong(FForm.Handle, GWL_STYLE, OldState);
85 FForm.Height:=OldHeight;
86 FForm.Width:=OldWidth;
87 FForm.Left:=OldX;
88 FForm.Top:=OldY;
89 FForm.Windowstate:=FOldState;
90 FForm.Refresh;
91 if Assigned(FExitFullScreen) then FExitFullScreen(Self);
92 end;
93 end;
94 if Assigned(FAfterModeChanged) then FAfterModeChanged(Self);
95 end;
96
97 procedure Register;
98 begin
99 RegisterComponents('UWS Used', [TFullScreen]);
100 end;
101
102 end.
103

 组件下载:https://files.cnblogs.com/uws2056/FullScreen.rar


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
《zw版·Halcon-delphi系列原创教程》Halcon分类函数002·AI人工智能 ...发布时间:2022-07-18
下一篇:
DELPHITADOQuery和Excel相关发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap