окно созданное на API(только форма без всего) исходник(2,56Кб), .exe(9,4Кб)
Создайте текстовый файл, скопируйте в него этот текст и измените название на "APIForm.dpr"(проект делфи), потом откройте через Delphi и откомпилируйте, .exe весит 15Kб !

program APIForm;
uses
  Windows, Messages;
const
  TITLE = 'Cамый простой пример API формы без всего';
var
  h_Wnd  : HWND;
function WndProc(hWnd: HWND; Msg: UINT;  wParam: WPARAM;  lParam: 
LPARAM): LRESULT; stdcall;
begin
  case (Msg) of
    WM_CREATE:
      begin { а здесь могло бы быть то что выполняется при старте проги }
      end;
    WM_CLOSE:
      begin
        PostQuitMessage(0);
        Result := 0
      end;
    else
      Result := DefWindowProc(hWnd, Msg, wParam, lParam);
  end;
end;

function APIFormC(Width, Height : Integer ) : Boolean; var wndClass : TWndClass; { Window class } dwStyle , { Window styles } dwExStyle : DWORD; { Extended window styles } h_Instance : HINST; { Current instance } begin h_Instance := GetModuleHandle(nil); { Grab An Instance For Our Window } with wndClass do { Set up the window class } begin style := CS_HREDRAW or { Redraws entire window if length changes } CS_VREDRAW or { Redraws entire window if height changes } CS_OWNDC; { Unique device context for the window } lpfnWndProc := @WndProc; { Set the window procedure to our func WndProc } hInstance := h_Instance; hCursor := LoadCursor(0, IDC_ARROW); hbrBackground := COLOR_WINDOW; { стандартный цвет окна(можно так 445566 (RGB), или просто clred (красный) ) } lpszClassName := 'APIForm'; end; RegisterClass(wndClass); dwStyle := WS_OVERLAPPEDWINDOW; { форма с кнопками вверху } dwExStyle := WS_EX_APPWINDOW; { форма со значком приложения в углу } h_Wnd := CreateWindowEx(dwExStyle, { Extended window styles }
'APIForm', { Class name } TITLE, { Window title (caption) } dwStyle, { Window styles } 0, 0, { позиция окна(левый верхний угол) } Width, Height, { Размеры Width и Heught соответственно } 0, { No parent window } 0, { No menu } h_Instance, { Instance } nil); { Pass nothing to WM_CREATE } if h_Wnd = 0 then begin MessageBox(0, 'Не могу создать окно!', 'Ошибка', MB_OK or MB_ICONERROR); Result := False; Exit; end; ShowWindow(h_Wnd, SW_SHOW); SetForegroundWindow(h_Wnd); SetFocus(h_Wnd); Result := True; end;

function WinMain(hInstance : HINST; hPrevInstance : HINST; lpCmdLine : PChar; nCmdShow : Integer) : Integer; stdcall; var msg : TMsg; finished : Boolean; begin Finished := False; APIFormC( 400, 200 ); { ширина и высота }

while not finished do begin if (PeekMessage(msg, 0, 0, 0, PM_REMOVE)) then { Check if there is a message for this window } begin if (msg.message = WM_QUIT) then { If WM_QUIT message received then we are done } finished := True else begin { Else translate and dispatch the message to this window } TranslateMessage(msg); DispatchMessage(msg); end; end; end; Result := msg.wParam; end;

begin WinMain( hInstance, hPrevInst, CmdLine, CmdShow ); end.