1.在CreateWindowEx的dwStyle参数中加上and not CreateWindowEx可去掉标题栏。2.使用Application.Icon.LoadFromFile;

解决方案 »

  1.   

    请 new 一个 Console Application ,然后写入以下程序:program plainAPI;uses
      Windows,
      Messages;{$R *.res}function PlainWinProc (hWnd: THandle; nMsg: UINT;
      wParam, lParam: Cardinal): Cardinal; export; stdcall;
    var
      hdc: THandle;
      ps: TPaintStruct;
    begin
      Result := 0;
      case nMsg of
        wm_lButtonDown:
          MessageBox (hWnd, 'Mouse Clicked',
            'Plain API', MB_OK);
        wm_Paint:
        begin
          hdc := BeginPaint (hWnd, ps);
          Ellipse (hdc, 100, 100, 300, 300);
          EndPaint (hWnd, ps);
        end;
        wm_Destroy:
          PostQuitMessage (0);
        else
          Result := DefWindowProc (hWnd, nMsg, wParam, lParam);
      end;
    end;
    procedure WinMain;
    var
      hWnd: THandle;
      Msg: TMsg;
      WndClassEx: TWndClassEx;
    begin
      // 初始化window class 结构
      WndClassEx.cbSize := sizeOf (TWndClassEx);
      WndClassEx.lpszClassName := 'PlainWindow';
      WndClassEx.style := CS_CLASSDC or CS_PARENTDC;
      WndClassEx.hInstance := HInstance;
      WndClassEx.lpfnWndProc := @PlainWinProc;
      WndClassEx.cbClsExtra := 0;
      WndClassEx.cbWndExtra := 0;
      WndClassEx.hIcon := LoadIcon (hInstance,
        MakeIntResource ('MAINICON'));
      WndClassEx.hIconSm  := LoadIcon (hInstance,
        MakeIntResource ('MAINICON'));
      WndClassEx.hCursor := LoadCursor (0, idc_Arrow);;
      WndClassEx.hbrBackground := GetStockObject (white_Brush);
      WndClassEx.lpszMenuName := nil;
      // 注册 class
      if RegisterClassEx (WndClassEx) = 0 then
        MessageBox (0, 'Invalid class registration',
          'Plain API', MB_OK)
      else
      begin
        hWnd := CreateWindowEx(
          WS_EX_LEFT OR WS_EX_LTRREADING or WS_EX_RIGHTSCROLLBAR or WS_EX_CONTROLPARENT,//扩展风格
          WndClassEx.lpszClassName, // Windows Class名
          '纯API演示', // 标题
          WS_POPUP OR WS_VISIBLE OR WS_CLIPSIBLINGS OR WS_OVERLAPPED , // 一般风格
          10, 10, // 位置
          600, 400, // 大小
          0, // 父窗口句柄
          0, // 菜单句柄
          HInstance, // 实例句柄
          nil); // 初始参数
        if hWnd = 0 then
          MessageBox (0, 'Window not created',
            'Plain API', MB_OK)
        else
        begin
          ShowWindow (hWnd, sw_ShowNormal);
          while GetMessage (Msg, 0, 0, 0) do
          begin
            TranslateMessage (Msg);
            DispatchMessage (Msg);
          end;
        end;
      end;
    end;begin
      WinMain;
    end.
    把工程文件存成plainAPI.dpr文件,就成了。
    这个程序满足了你的:1)纯API编出的窗口。2)没有标题栏。
    3)要改主程序的图标,请修改WndClassEx.hIcon的语句。