程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi使用三則

Delphi使用三則

編輯: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

 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved