How do I send a EM_XXXX message to a textbox to get some value such as line index in C#
There is a protected SendMessage call you can use for this purpose, so you have to derive from TextBox. public MyTextBox : TextBox { private const int EM_XXXX = 0x1234; public int LineIndex { get { return base.SendMessage(EM_XXXX, 0, 0); } } } (from [email protected] on microsoft.public.dotnet.framework.windowsforms)
How can I detect if the user clicks into another window from my modal dialog
Use the Form.Deactivate event: this.Deactivate += new EventHandle(OnDeactivate); //… private void OnDeactivate(object s, EventArgs e) { this.Close(); } (from [email protected] on microsoft.public.dotnet.framework.windowsforms)
How do I get an HWND for a form
See the Control.Handle property which returns the HWND. Be careful if you pass this handle to some Win32 API as Windows Forms controls do their own handle management so they may recreate the handle which would leave this HWND dangling. (from [email protected] on microsoft.public.dotnet.framework.windowsforms)
If I have a user control and a designer, how can I debug the designer
You need to use a second instance of VS.NET to debug the one that’s running the code. 1) Put your control on a form in VS.NET 2) Start a 2nd Vs.Net 3) Choose the Debug menu >> Processes … 4) Double click ‘devenv.exe’ and choose ‘Common Language Runtime’ as the types of debugging 5) Open your code file, set your breakpoint, and you’re debugging. (from [email protected] on microsoft.public.dotnet.framework.windowsforms)
How do I convert LParam in a message from IntPtr to the Win32 type
Define the struct you want, for example RECT struct RECT { public int left, top, right, bottom; } Then use the Message.GetLPAram method RECT rc = (RECT)m.GetLParam( typeof(RECT) );