zoukankan      html  css  js  c++  java
  • delphi 通过windows api 创建窗体

    {Register the Window class}
    function RegisterClassMeth: Boolean;
    var
      WindowClass: TWndClass;
    begin
      {setup our new window class}
      WindowClass.style := CS_HREDRAW or CS_VREDRAW; {set the class styles}
      WindowClass.lpfnWndProc := @DefWindowProc;     {point to the default window procedure}
      WindowClass.cbClsExtra := 0;                   {no extra class memory}
      WindowClass.cbWndExtra := 0;                   {no extra window memory}
      WindowClass.hInstance := HInstance;            {the application instance}
      WindowClass.hIcon := 0;                        {no icon specified}
      WindowClass.hCursor := 0;                      {no cursor specified}
      WindowClass.hbrBackground := COLOR_WINDOW;     {use a predefined color}
      WindowClass.lpszMenuName := nil;               {no memu}
      WindowClass.lpszClassName := 'TestClass';      {the registered class name}
    
      {now that we have our class set up,register it with the system}
      Result := Winapi.Windows.RegisterClass(WindowClass) <> 0;
    end;
    
    procedure TForm12.Button3Click(Sender: TObject);
    var
      hWindow: HWND;
    begin
      {Step 1: Register our new window class}
      if not RegisterClassMeth() then
      begin
        ShowMessage('RegisterClass failed!');
        Exit;
      end;
    
      {Step 2: Create a window based on our new class}
      hWindow := CreateWindowEx(0,      {no extend styles}
                                'TestClass',    {the registered class name}
                                'New Window',   {the title bar text}
                                WS_OVERLAPPEDWINDOW, {a normal window style}
                                CW_USEDEFAULT,     {default horizontal position}
                                CW_USEDEFAULT,     {default vertical position}
                                CW_USEDEFAULT,     {default width}
                                CW_USEDEFAULT,     {default height}
                                0,                 {no owner window}
                                0,                 {no menu}
                                hInstance,         {the application instance}
                                nil                {no additional information}
                                );
    
      {Step 3: If our window was created successfully,display it}
      if hWindow <> 0 then
      begin
        ShowWindow(hWindow,SW_SHOWNORMAL);
        UpdateWindow(hWindow);
      end
      else
      begin
        ShowMessage('CreateWindow');
        Exit;
      end;
    
    end;
  • 相关阅读:
    从Swift3的标准库协议看面向协议编程(一)
    iOS多线程到底不安全在哪里?
    typealias和泛型接口
    iOS蓝牙开发CoreBluetooth快速入门
    iOS学习路线图
    iOS开发masonry的一些使用简介
    在Swift项目中使用cocoaPods导入第三方OC库
    微信小程序开发POST请求
    一些NSArray,NSDictionary,NSSet相关的算法知识
    iOS开发中的权限
  • 原文地址:https://www.cnblogs.com/yangxuming/p/9229523.html
Copyright © 2011-2022 走看看