zoukankan      html  css  js  c++  java
  • Object Pascal开发windows原生程序

    program Project1;

    uses
      Windows ,Messages ,SysUtils;
    const
      appname='fancydemo';
      function windowproc(window:HWND ;amessage:UINT ;wparam:WPARAM ;
      lparam:LPARAM ):LRESULT ;stdcall ;export ;
      var
        dc:HDC ;
        ps:TPaintStruct ;
        r:TRect ;

    begin
      windowproc:=0;
      case amessage of
      WM_PAINT :
      begin
        dc:=BeginPaint(window ,ps);
        GetClientRect(window ,r);
        DrawText(dc,'op 语言写的windows程序',-1,r,DT_SINGLELINE or DT_CENTER );
        EndPaint(window ,ps);
        exit;
      end;
      WM_DESTROY :
      begin
        PostQuitMessage(0);
        Exit;
      end;
      end;
      windowproc:=DefWindowProc(window,amessage ,wparam ,lparam );
    end;
         function winregister:Boolean ;
         var
           windowclass:WNDCLASS ;
           begin
             windowclass .style :=CS_HREDRAW or CS_VREDRAW ;
             windowclass .lpfnWndProc :=TFNWndProc(@windowproc);
             windowclass .cbClsExtra :=0;
             windowclass .cbWndExtra :=0;
             windowclass .hInstance :=SYSTEM.MainInstance ;
             windowclass .hIcon :=LoadIcon(0,IDI_APPLICATION );
             windowclass .hCursor :=LoadCursor(0,IDC_ARROW );
             windowclass .hbrBackground :=GetStockObject(WHITE_BRUSH );
             windowclass .lpszMenuName :=nil;
             windowclass .lpszClassName :=appname ;
             result:=RegisterClass(windowclass )<>0;
           end;
           function wincreate:HWND ;
           var
            hwindow:HWND ;
            begin
              hwindow :=CreateWindow(appname ,'hello,fancy',WS_OVERLAPPEDWINDOW ,CW_usedefault,cw_usedefault,cw_usedefault,cw_usedefault,0,0,SYSTEM.MainInstance ,nil );
              if hwindow <> 0 then
                 begin
                   ShowWindow(hwindow ,cmdshow);
                   ShowWindow(hwindow ,SW_SHOW );
                   UpdateWindow(hwindow );
                 end;
                   Result :=hwindow ;
            end;
            var
               amessage:TMsg ;
               hwindow:HWND ;
             begin
               if not winregister then
               begin
                MessageBox(0,'Register failed',nil,MB_OK );
                Exit;
               end;
               hwindow:=wincreate ;
               if LongInt (hwindow)=0 then
               begin
               MessageBox(0,'wincreate failed',nil,MB_OK );
               Exit ;
               end ;
               while GetMessage(amessage ,0,0,0) do
               begin
               TranslateMessage(amessage );
               DispatchMessage(amessage );
               end;
               Halt (amessage .wParam );
             end.


     

  • 相关阅读:
    SpringBoot整合flyway
    JavaFTP递归查询指定目录下的所有目录和文件
    初识网络设备
    Session
    Cookie
    文件下载
    PHP文件上传
    数据库操作函数笔记
    Apache #Tomcat CVE-2020-9484
    红方人员实战手册
  • 原文地址:https://www.cnblogs.com/feng801/p/1277788.html
Copyright © 2011-2022 走看看