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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:43:36+00:00 2026-05-15T13:43:36+00:00

In my C# application I’m trying to use the TDM_CLICK_BUTTON message to click a

  • 0

In my C# application I’m trying to use the TDM_CLICK_BUTTON message to click a button in a TaskDialog. This basically works just fine. What I expect to happen, happens. I even receive the TDN_BUTTON_CLICKED notification.

But the documentation says, that the return value of SendMessage would be nonzero if the call succeeds. But it always returns zero for me.

This is my code:

public void ClickButton( int buttonId ) {
  bool success = UnsafeNativeMethods.SendMessage(
    WindowHandle,
    (uint)UnsafeNativeMethods.TASKDIALOG_MESSAGES.TDM_CLICK_BUTTON,
    (IntPtr)buttonId,
    IntPtr.Zero ) != IntPtr.Zero;
  if( !success ) {
    int lastWin32Error = Marshal.GetLastWin32Error();
    throw new Win32Exception( lastWin32Error, "SendMessage for TDM_CLICK_BUTTON failed." );
  }
}

lastWin32Error is always zero when the exception is thrown. Which would be another indicator that everything is fine.

SendMessage is declared in my code like this:

[DllImport( "user32.dll", SetLastError = true )]
internal static extern IntPtr SendMessage( IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam );

Is the documentation incorrect or am I using the message incorrectly?

  • 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-15T13:43:37+00:00Added an answer on May 15, 2026 at 1:43 pm

    So I took the C++ Windows SDK TaskDialog sample and tried this message out in there as well. The return value of SendMessage remains zero always.

    I noticed that a TDN_BUTTON_CLICKED notification will always be sent (even if the button id does not exist). If the button exists or not has no effect on the SendMessage return value.

    Then I suspected, that the return value for that notification might have an effect, but no matter what I return from the callback (TRUE/FALSE/S_OK/42), my SendMessage return value remains zero.

    So, given that I found no way to make this fail and/or return a nonzero value, I can only assume that the documentation is incorrect.

    edit: I got a reply to my documentation feedback I sent a few days ago. Turns out the documentation is indeed incorrect. The return value is to be ignored.

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

Sidebar

Related Questions

Application is sending email by using MFMailComposeViewController , everything works just fine. However after
Application works fine. I can access everything in debug except for an Array Adapter
Application : HTA (therefore IE) This is an application that uses SendKeys to populate
Application stores configuration data in custom section of configuration file. This information is used
my application use 10 threads that to read a lot of html file.similar the
Application: This is a workshop proposal system for a conference. A user can create
Application.Run(form); Actually I tried to call this from my project. I got this exception.
My application purpose just simply captures a ISBN number then converts ISBN to a
Application.Run(new Main()); This line gives TypeInitializationException was unhandled after I switched from 3.5 to
Application.ScreenUpdating = False If ... something... Then Range(calc02).EntireRow.Hidden = False // this is critical

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.