⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 window_unit.pas

📁 进程完整路径
💻 PAS
字号:
unit Window_Unit;

interface

  //----建立主窗体------
procedure Create_Window;


implementation

uses
  Windows, public_Unit;

const
  WM_DESTROY = $0002;    // 窗体注销消息
  WM_PAINT   = $000F;    // 窗体刷新消息

var
  WindowIconH: LongWord; //本窗体图标句柄

  //----主窗体消息处理过程-----
function WindowProc(WinHanlde, MessageID, WParam, LParam : Longword):Longint; stdcall;
begin
        //---默认处理过程---
  Result := DefWindowProc(WinHanlde, MessageID, WParam, LParam);
          //--刷新--               //--绘制图标--
  if (MessageID = WM_PAINT) then DrawIconToForm
              //--取图标--
  else if (MessageID = WM_GETICON) then Result:=WindowIconH
                   //--关闭--
       else if (MessageID = WM_DESTROY) then PostQuitMessage(0);

end;

  //----注册窗体类----
function RegWindowClass: Boolean;
var
  WindowClass: TWndClass;
begin
  WindowIconH := LoadIcon(hInstance,'ICON32');
 {--填充结构体--}
  WindowClass.Style := CS_HREDRAW or CS_VREDRAW;     // 窗体类风格
  WindowClass.lpfnWndProc := @WindowProc;            // 指定窗体过程
  WindowClass.cbClsExtra := 0;                       // 无额外类信息
  WindowClass.cbWndExtra := 0;                       // 无额外窗体信息
  WindowClass.hInstance := hInstance;                // 实例句柄
  WindowClass.hIcon := WindowIconH;                  // 指定图标
  WindowClass.hCursor := 0;                          // 没有光标
  WindowClass.hbrBackground := COLOR_WINDOW;         // 预定义颜色
  WindowClass.lpszMenuName := nil;                   // 没有菜单
  WindowClass.lpszClassName := 'Liu_MaZi';          // 欲注册的类名
 {--注册窗体类--}
  Result := RegisterClass(WindowClass) <> 0;
end;

  //----建立主窗体------
procedure Create_Window;
begin      
  if (not RegWindowClass) then
  begin
    MessageBox(0, '注册窗体类失败' , nil, 0);
    Halt;
  end;
  WindowHanlde := CreateWindowEx(0,
                                'Liu_MaZi',
                                '----枚举应用Demo----------- By 麻子',
                                WS_OVERLAPPEDWINDOW or WS_VISIBLE,
                                100,
                                100,
                                455,
                                236,
                                0,
                                0,
                                hInstance,
                                nil);
  if (WindowHanlde = 0) then
  begin
    MessageBox(0, '建立主窗体失败', nil, 0);
    Halt;
  end;
 //--创建字体--
  MyFont_Hanlde := CreateFont(12, 6,0,0,FW_EXTRALIGHT,byte(FALSE),
                              byte(FALSE),byte(FALSE),GB2312_CHARSET,
                              OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
                              DEFAULT_QUALITY,DEFAULT_PITCH,'宋体');
 //--设置字体--
  SendMessage(WindowHanlde, WM_SETFONT, MyFont_Hanlde, 0);
 //--设备环境--
  Window_hdc := GetWindowDC(WindowHanlde);
end;  

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -