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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:26:19+00:00 2026-05-26T14:26:19+00:00

i have a native win32 c++ application which has a checkbox in it. I

  • 0

i have a native win32 c++ application which has a checkbox in it. I want to replace the checkbox and create ON/OFF toggle button with 2 states (just like the checkbox). I’ve added the BS_OWNERDRAW style to the checkbox and drawn it to the window in WM_DRAWITEM. The problem is that when I click on the checkbox I get a WM_COMMAND message (just like without the BS_OWNERDRAW) but the CHECKED state doesn’t change automaticly. Do I have to implement this functionality or am I missing something?

The code that handles clicking on the checkbox:

 case WM_COMMAND:
    wmId    = LOWORD(wParam);
    wmEvent = HIWORD(wParam);

    switch (wmId)
    {
        case IDC_CHECKBOX:
            if(wmEvent == BN_CLICKED)
            {
                dwPos = SendMessage(checkBox, BM_GETCHECK, 0, 0);
                if(dwPos == BST_CHECKED ) 
                {
                   // do some stuff

                } else if(dwPos == BST_UNCHECKED) {
                    // do some stuff
                }
           }

The problem is that every time i click on the checkbox BM_GETCHECK returns BST_UNCHECKED. If i remove the BS_OWNERDRAW it works fine.

Code that creates the button/checkbox:

   checkBox = CreateWindowEx(
        0,
        WC_BUTTON,
        szBuffer,
        WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_OWNERDRAW,
        BUTTON_ON_OFF_X, BUTTON_ON_OFF_Y,
        BUTTON_ON_OFF_WIDTH, BUTTON_ON_OFF_HEIGHT,
        hWnd, 
        (HMENU)IDC_CHECKBOX,
        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-05-26T14:26:20+00:00Added an answer on May 26, 2026 at 2:26 pm

    Yes. You will need to translate from your WM_COMMAND and toggle the internal check state with something like CheckDlgButton.

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

Sidebar

Related Questions

I have native function takes 2 arguments , i want to create managed thread
The setup: I have a unmanaged/native Win32 application that I inject my code into.
I have a .NET application that makes calls to a native Win32 DLL using
I have a native Win32 client application, and a .NET web application. I'd like
Windows resources have a FileVersion and a ProductVersion. In native development environment(eg. Win32 app,
I have a native VC++ project that uses a dll (which is not in
I have a native DLL which outputs via stdout / stderr. I have a
Or do I have to pinvoke native code? I don't want the power status...well
I have a .net application calling to a COM component (C++) which in turn
I have a need to do some drawing using win32/GDI (Native, not .NET), and

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.