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 8054337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:07:26+00:00 2026-06-05T08:07:26+00:00

this may seem like a trivial question and one that the answer serves no

  • 0

this may seem like a trivial question and one that the answer serves no apparent purpose but I’m asking purely out of the interest of knowledge and curiosity.

I’m writing a Win32 GUI application with no actual purpose other than to expand my programming knowledge with the Win32 API and I am wondering how I would go about creating controls(text fields and buttons in particular) after the program has been launched and WM_CREATE has been called.

I know that using UpdateWindow will send a WM_CREATE message to the window but if i am to understand correctly, this will just update the stuff already written in WM_CREATE within the source?

What I am after is a button which adds another button upon click and a button which adds a text field on click.

And, although not a control, another button that paints text with TextOut() or something on click.

I’ve been scouring google for the last 2 hours looking for this and had no luck, i’ve also viewed UpdateWindow() and RedrawWindow() which have provided no real help.

Im not asking for you guys to write any code for me, although that would be great:P
Just a few pointers in the right direction and a bit of guidance would be wonderful

Thanks in Advance,
Timmy

Also, I’m using C++ with VS10 and no .NET or MFC please, just pure C++ 😀

Edit:

main.cpp, message loop:

case WM_CREATE:
hedit = ctrls->createTextArea(100, 50, 100, 20, ghInstance, hWnd, hEdit1);
hedit2 = ctrls->createBtn(200, 50, 100, 20, ghInstance, hWnd, "button", btn1);
return 0;

ctrls refers to controls class object and createTextArea and createBtn from this class follow:

HWND controls::createTextArea(int x, int y, int width, int height, HINSTANCE hInst, HWND parent, int id)
{
return CreateWindowEx(NULL,
            "Edit",
            "",
            WS_CHILD | WS_VISIBLE | ES_PASSWORD | WS_BORDER,
            x, y,
            width,height,
            parent, (HBRUSH)id,
            hInst,
            NULL);
}



HWND controls::createBtn(int x, int y, int width, int height, HINSTANCE hInst, HWND parent, LPCSTR btnText, int id)
{
    return CreateWindowEx(NULL,
            "Button",
            btnText,
            WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
            x, y,
            width, height,
            parent, (HBRUSH)id,
            hInst,
            NULL);
}

EDIT Two:

WM_COMMAND

    case WM_COMMAND:

        if( LOWORD(wParam) == btn1) // btn1 click
        {
            hBtn = CreateWindowEx(NULL,
                "Button",
                "Button2",
                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                400,50,100,20,
                hWnd, NULL,
                ghInstance,
                NULL);
            ShowWindow(hBtn, SW_SHOW);
            UpdateWindow(hWnd);
        }
            return 0;

the ‘btn1’ in if( LOWORD(wParam) == btn1) refers to the ID of the button im clicking to try and make another which is effectively created by the following code called via function:

CreateWindowEx(NULL,
            "Button",
            btnText,
            WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
            x, y,
            width, height,
            parent, (HMENU)id,
            hInst,
            NULL);
  • 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-05T08:07:27+00:00Added an answer on June 5, 2026 at 8:07 am

    I know that using UpdateWindow will send a WM_CREATE message to the window

    No, CreateWindow/Ex() will send that message. UpdateWindow will only force a WM_PAINT message to be dispatched and processed. If your main window doesn’t become visible then you probably forgot to call ShowWindow().

    Use the default code generated by the Win32 Project template as a guide. Verify it works first, add changes incrementally. Watch out for swallowed SEH exceptions when you write 32-bit code on a 64-bit operating system. Debug + Exceptions, tick the Thrown checkbox for “Win32 Exceptions”.

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

Sidebar

Related Questions

This may seem like a simple question, but I can't find the definite answer:
This may seem like a simple question, but I can't find the answer anywhere
This may seem like a silly question, but do custom fonts that are linked
Ok this may seem like a bit of a noob question but one many
This may seem like a silly question, but it is something that drives me
This may seem like a really daft question, but what is the reason for
This may seem like a simple question but i am getting an error when
This may seem like a stupid question, but what message do i send to
This may seem like a silly question but I can't figure it out. let's
This may seem like a realy basic question but... How do you use double

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.