SendMessage in C#

Posted on 2003-03-03
Medium Priority
Last Modified: 2009-12-16
I have a win application that is written by C#.
When run it, first one form with "frmAbout" name appears.
on the this form, there is a "ok" button.
we must click this button until we see another form.
I want when run program without clicking "ok" button, I see second form, I want to do it with retrieving handle of "ok" button and Sending Message to "ok" button.
please help me.
Question by:KawoshSoft
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

Nebulus_ earned 480 total points
ID: 8056309
I'm not sure that you need to send messages to a control from a form (maybe you need a spash screen :) ) but this is, I think, what you ask:

using System.Runtime.InteropServices;


public const uint WM_LBUTTONDOWN = 0x201;
public const uint WM_LBUTTONUP = 0x202;

[DllImport("user32.dll", EntryPoint = "SendMessageA")]
public static extern uint SendMessage(IntPtr hWnd, uint  wMsg, uint wParam, uint lParam);


SendMessage(buttonOK.Handle, WM_LBUTTONDOWN, 0, 0);
SendMessage(buttonOK.Handle, WM_LBUTTONUP, 0, 0);

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question