哪位高手有:用API实现的窗体并加上一些简单的功能,不用DELPHI的VCL的程序源代码,我的EMAIL:[email protected]

解决方案 »

  1.   

    program Project1;{$APPTYPE CONSOLE}uses
      windows,
      messages;// 回调函数
    function AppWindowProc(
        hWnd:HWND; uMsg:UINT;
        wParam:WPARAM; lParam:LPARAM):LRESULT; stdcall;
    begin
      Result := 0;
      case uMsg of
        WM_DESTROY:begin
          PostQuitMessage(0);
          Exit;
        end;
      end;
      Result :=
        DefWindowProc(hWnd, uMsg, wParam, lParam);
    end;
    var
      wc: TWndClass;
      hWnd: Integer;
      MSG: TMsg;begin
      { TODO -oUser -cConsole Main : Insert code here }
      // 程序从这里开始执行
      wc.style := CS_VREDRAW or CS_HREDRAW;
      wc.lpfnWndProc := @AppWindowProc;
      wc.cbClsExtra := 0;
      wc.cbWndExtra := 0;
      wc.hInstance := HInstance;
      wc.hIcon := LoadIcon(0, IDI_APPLICATION);
      wc.hCursor := LoadCursor(0, IDC_ARROW);
      wc.hbrBackground := (COLOR_BTNFACE+1);
      wc.lpszMenuName := nil;
      wc.lpszClassName := 'My App';
      if RegisterClass(wc)=0 then Exit;          //注册窗口
      hWnd := CreateWindow(                      //建立窗口
        wc.lpszClassName, 'TEST',
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT,
        CW_USEDEFAULT, CW_USEDEFAULT,
        0, 0, HInstance, nil);
      if hWnd=0 then Exit;
      ShowWindow(hWnd, SW_SHOWNORMAL);
      while GetMessage(MSG, 0, 0, 0) do begin   //开始消息循环
        TranslateMessage(MSG);
        DispatchMessage(MSG);
      end;
      Halt(MSG.wParam);
    end.