Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7818451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:34:40+00:00 2026-06-02T06:34:40+00:00

I need to create a form (using CreateWindow functions) without any help from the

  • 0

I need to create a form (using CreateWindow functions) without any help from the VCL (or any visual control) only using the Windows API.

This form will have an InputBox, a Button and a BitMap (like TImage does).

I was not able to find any sample on internet. Does anyone know a good place where I can download a sample besides MSDN?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:34:41+00:00Added an answer on June 2, 2026 at 6:34 am

    This is a sample App which uses only the WinApi to create Windows with an static, edit and button, I let you the display of the BitMap display as exercise for you.

    uses
      Windows,
      Messages,
      SysUtils;
    
    var
      Msg        : TMSG;
      LWndClass  : TWndClass;
      hMainHandle: HWND;
      hButton    : HWND;
      hStatic    : HWND;
      hEdit      : HWND;
      hFontText  : HWND;
      hFontButton: HWND;
    
    procedure ReleaseResources;
    begin
      DestroyWindow(hButton);
      DestroyWindow(hStatic);
      DestroyWindow(hEdit);
      DeleteObject(hFontText);
      DeleteObject(hFontButton);
      PostQuitMessage(0);
    end;
    
    function WindowProc(hWnd,Msg:Longint; wParam : WPARAM; lParam: LPARAM):Longint; stdcall;
    begin
      case Msg of
          WM_COMMAND: if lParam = hButton then
                        MessageBox(hMainHandle,'You pressed the button Hello', 'Hello',MB_OK or MB_ICONINFORMATION);
          WM_DESTROY: ReleaseResources;
      end;
      Result:=DefWindowProc(hWnd,Msg,wParam,lParam);
    end;
    
    begin
      //create the window
      LWndClass.hInstance := hInstance;
      with LWndClass do
        begin
          lpszClassName := 'MyWinApiWnd';
          Style         := CS_PARENTDC or CS_BYTEALIGNCLIENT;
          hIcon         := LoadIcon(hInstance,'MAINICON');
          lpfnWndProc   := @WindowProc;
          hbrBackground := COLOR_BTNFACE+1;
          hCursor       := LoadCursor(0,IDC_ARROW);
        end;
    
      RegisterClass(LWndClass);
      hMainHandle := CreateWindow(LWndClass.lpszClassName,'Window Title', WS_CAPTION or WS_MINIMIZEBOX or WS_SYSMENU or WS_VISIBLE, (GetSystemMetrics(SM_CXSCREEN) div 2)-190,
          (GetSystemMetrics(SM_CYSCREEN) div 2)-170, 386,200,0,0,hInstance,nil);
    
      //Create the fonts to use
      hFontText := CreateFont(-14,0,0,0,0,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH or FF_SWISS,'Tahoma');
      hFontButton := CreateFont(-14,0,0,0,0,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH or FF_SWISS,'Tahoma');
    
      //create the static
      hStatic:=CreateWindow('Static','This is static text, like a TLabel',WS_VISIBLE or WS_CHILD or SS_LEFT, 10,10,360,44,hMainHandle,0,hInstance,nil);
      SendMessage(hStatic,WM_SETFONT,hFontText,0);
    
      //create the edit
      hEdit:=CreateWindowEx(WS_EX_CLIENTEDGE,'Edit','This a Edit like and TEdit', WS_VISIBLE or WS_CHILD or ES_LEFT or ES_AUTOHSCROLL,10,35,360,23,hMainHandle,0,hInstance,nil);
      SendMessage(hEdit,WM_SETFONT,hFontText,0);
    
      //create the button
      hButton:=CreateWindow('Button','Hello', WS_VISIBLE or WS_CHILD or BS_PUSHBUTTON or BS_TEXT, 10,130,100,28,hMainHandle,0,hInstance,nil);
      SendMessage(hButton,WM_SETFONT,hFontButton,0);
    
      //message loop
      while GetMessage(Msg,0,0,0) do
      begin
        TranslateMessage(Msg);
        DispatchMessage(Msg);
      end;
    
    end.
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help I am trying to create a PHP form using sqlite3
I need some help I am trying to create a PHP form using sqlite3
I need to create a Gold bar for my windows form similar to what
I'm using z3c.form to create a form in Plone 4.1.4. I need a boolean
I need to create a custom jquery form validation using Jquery Validation Plugin where
Is it possible to create a form on Windows using Ruby? I have a
I need to create a form that has many of the same fields, that
I'm new to Sencha Touch, and I need to create a form where you
I need to create a full-text search form for a database of emails /
I need to create a PHP order form with 150 lines, each line has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.