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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:08:40+00:00 2026-05-22T12:08:40+00:00

I have read and read, trying to find how to put text on a

  • 0

I have read and read, trying to find how to put text on a custom control. I have found stuff, but none of it has been clean and simple.

So how do I draw text on a custom control? here is code…

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK CustProc(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam) ;
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
wchar_t * windowname = L"window Class";
wchar_t * cust = L"custctrl";

WNDCLASS wc = {0};
wc.lpszClassName = windowname;
wc.lpfnWndProc = WindowProc;
RegisterClass(&wc);

    HWND hwnd = CreateWindowEx(
    0,
    windowname,
    L"app",
     WS_VISIBLE | WS_THICKFRAME| WS_OVERLAPPEDWINDOW  ,
    50, 50,
    500, 500,
    NULL, 
    NULL,
    hInstance,
    NULL
    );



    WNDCLASS button = {0};
button.lpfnWndProc = CustProc;
button.lpszClassName = cust;
button.hInstance = hInstance;
button.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
button.hCursor = LoadCursor(NULL, IDC_HAND);
RegisterClass(&button);



     HWND click =   CreateWindowEx(
    WS_EX_CLIENTEDGE,
    cust,
    L"Custom Control", //doesnt show up on the window, not to my suprise
    WS_VISIBLE | WS_CHILD ,
    0, 0,
    500, 500,
    hwnd,
    NULL,
    hInstance,
    NULL
    );
  //all the rest...
}

LRESULT CALLBACK CustProc(HWND hwnd, UINT uMsg, WPARAM wparam, LPARAM lparam) {
switch(uMsg) {
    case WM_CREATE:
    SetWindowText(hwnd, L"button"); //also doesn't work, also not to my suprise
case WM_LBUTTONDOWN: {
MessageBox(hwnd, L"you clicked the custom button", L"cool", 0); // works fine
break;
                         }
return  0;
}
    return  DefWindowProc(hwnd, uMsg, wparam, lparam);
    }
  • 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-05-22T12:08:40+00:00Added an answer on May 22, 2026 at 12:08 pm

    You can catch the WM_PAINT message in your CustProc function and draw the text yourself.

    You can get a drawing context by calling BeginPaint, draw the text and close the drawing context by calling EndPaint. You can draw text with the TextOut function. Here is an example from MSDN:

    LRESULT APIENTRY WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
    { 
        PAINTSTRUCT ps; 
        HDC hdc; 
    
        switch (message) 
        { 
            case WM_PAINT: 
                hdc = BeginPaint(hwnd, &ps); 
                TextOut(hdc, 0, 0, "Hello, Windows!", 15); 
                EndPaint(hwnd, &ps); 
                return 0L; 
    
            // Process other messages.   
        } 
    } 
    

    Full example here.

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

Sidebar

Related Questions

I have been trying to read a picture saved in Access DB as a
I'm trying to have my application read through a text file and look for
I have a really simple XML file that I'm trying to read, but I
I am trying to read a text file in eclipse, I have run configurations
I am trying to present a modal view controller. I have read the documentation,
I am trying to read data from an RS-232 port. Does anyone have an
I'm trying to read a file from a local filesystem. I do not have
I am trying to read a global symbol from another package. I have the
I have an xml file(from federal government's data.gov) which I'm trying to read with
I have an XML file as follows, and I'm trying to read the content

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.