Delphi使用三则

2016-01-29 14:17 2 1 收藏

Delphi使用三则,Delphi使用三则

【 tulaoshi.com - Delphi 】

 

  隐藏和显示Windows的任务条
  如果隐藏和显示Windows的任务条,仅仅调用以下的函数就可以:
  procedure hideTaskbar; //隐藏
  var
  wndHandle : THandle;
  wndClass : array[0..50] of Char;
  begin
  StrPCopy(@wndClass[0], ′Shell—TrayWnd′);
  wndHandle:=FindWindow(@wndClass[0],nil);
  ShowWindow(wndHandle, SW—HIDE);
  End;
  procedure showTaskbar;
  var
  wndHandle : THandle;
  wndClass : array[0..50] of Char;
  begin
  StrPCopy(@wndClass[0], ′Shell—TrayWnd′);
  wndHandle:=FindWindow(@wndClass[0], nil);
  ShowWindow(wndHandle, SW—RESTORE);
  end;

  控制窗体
  如何在Delphi中把Form控制成不能放大/缩小/移动/关闭的窗体,可进行如下步骤:
  1.把Form的BorderIcons下的几个子属性值全改为False;
  2.修改Form的BorderStyle的值为bsSingle;
  3.为了让窗口不能移动,可以自已拦下WM—NCHITTEST消息,对该消息的处理为:一概回应鼠标点在窗口的Client区域, 相信这个视窗就不会动了。
  下面是一个例子, 请参考:
  unit Unit1;
  interface
  uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls,Forms, Dialogs, StdCtrls;
  type
  TForm1 = class(TForm)
  Button1: TButton;
  procedure Button1Click(Sender: TObject);
  private
  { Private declarations }
  procedure WMNCHitTest(var Msg: TMessage); message WM—NCHITTEST;
  public
  { Public declarations }
  end;
  var Form1: TForm1;
  implementation {$R *.DFM}
  procedure TForm1.Button1Click(Sender: TObject);
  begin
  Close; // 不可少, 因为已经没有其他方法能关闭此捶ň褪恰捌燮毕低?让它认为点中的是窗体的标题行:
  unit Dragmain;
  interface
  uses
   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
   Forms, Dialogs, StdCtrls;
  type
   TForm1 = class(TForm)
  Button1: TButton;
  procedure Button1Click(Sender: TObject);
   private
    procedure WMNCHitTest(var M: TWMNCHitTest); message wm—NCHitTest;
   end;
  var Form1: TForm1;
  implementation {$R *.DFM}
  procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);
  begin
   inherited;    
  { call the inherited message handler }
   if M.Result = htClient then
  { is the click in the client area? }
    M.Result := htCaption;  
   { if so, make Windows think it′s   }
      { on the caption bar.  }
  end;
  procedure TForm1.Button1Click(Sender: TObject);
  begin
   Close;
  end;
  end.
  { 下面是这个窗体的设置}
  object Form1: TForm1
   Left = 203
   Top = 94
   BorderIcons = []
   BorderStyle = bsNone
   ClientHeight = 273
   ClientWidth = 427
   Font.Color = clWindowText
   Font.Height = -13
   Font.Name = ′System′
   Font.Style = []
   PixelsPerInch = 96
   TextHeight = 16
   object Button1: TButton
    Left = 160
    Top = 104
    Width = 89
    Height = 33
    Caption = ′Close′
    TabOrder = 0
    OnClick = Button1Click
   end
  end

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/delphi/) 

来源:https://www.tulaoshi.com/n/20160129/1492941.html

延伸阅读
标签: 办公软件
对于Word中的超链接功能,大家应该并不陌生,笔者在使用Word中的超链接时总结出了一些经验,现在写出来供大家参考。 1.使用“屏幕提示” 我们在浏览网页时,如果把鼠标指针悬停在某个超链接上面,有时就会出现这个超链接的内容介绍。其实这很容易用Word的超链接功能实现。方法如下:在要添加屏幕提示的文字或图片超链接上面点击...
Delphi以其优良的可视化编程,灵活的Windows API接口,丰富的底层操作越来越受到编程爱好者的青睐。 在Delphi中,通过调用Windows API,可以很方便地获取系统信息,这有助于我们编写出更好的Windows应用程序。以下程序在Delphi3.0 For Windows 9x下编译通过。 一、 用GetDriveType函数获取磁盘信息 Lbl_DriveType:Tlabel; ...
标签: Delphi
  1.2.4.3 汉化界面及字体选取          如果您的 Windows95系统中安装了中文系统,对界面做汉化是极其方便的。例如,您可以将 Button1 的 Caption属性改成“ &R 矩形”,同样地可改变其它部件的属性,将窗体做成中文的操作界面。        &nbs...
标签: Web开发
1. CSS字体属性简写规则 一般用CSS设定字体属性是这样做的: font-weight: bold; font-style: italic; font-varient: small-caps; font-size: 1em; line-height: 1.5em; font-family: verdana,sans-serif 但也可以把它们全部写到一行上去: font: bold italic small-caps 1em/1.5em verdana,sans-serif 真不错!只有一点要提醒的:这种简...
标签: 电脑入门
WPS Office 2007 简体中文版,完整的桌面Office功能、易学易用全兼容Office、灵活的企业自动化组件、安全可靠文档应用处理。 WPS技巧一:人民币大写自动转换 对于每天面对大量数据的财务人员来说,把数字格式转换成人民币大写格式可能是他们每天要做的工 作,如果通过函数设置人民币大写格式,复杂程度就不用说了,有的朋友甚至不会使用函数...

经验教程

505

收藏

75
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部