Ctrl+Z

  • Thread starter Thread starter genc ymeri
  • Start date Start date
G

genc ymeri

Hi,
I'm doing a C# app which embbeds an ActiveX. If I press Ctrl+Z the ActiveX
performs an "Undo". How can I send the "Ctrl+Z" keypress into the system
through C# code for instance from a menu ????

Thank You in advance.
 
genc ymeri said:
Hi,
I'm doing a C# app which embbeds an ActiveX. If I press Ctrl+Z the ActiveX
performs an "Undo". How can I send the "Ctrl+Z" keypress into the system
through C# code for instance from a menu ????

Thank You in advance.

Use the SendMessage API function:

http://www.mentalis.org/apilist/SendMessage.shtml

You can send windows messages directly to the activex control through the
Control.Handle property:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal
lParam As Integer) As Integer
Private Const WM_UNDO = &H304

then in your code:

SendMessage(myActiveXControl.Handle, WM_UNDO, 0, 0)

Erik
 
I translated your tip in C# as below but it doesn't work. Am I missing
something ????


[DllImport("user32")]
public static extern int SendMessage(
IntPtr hWnd,
uint Msg,
IntPtr wParam,
IntPtr lParam
);

private const int WM_UNDO = 0x304;


private void menuIt_Undo_Click(object sender, System.EventArgs e)
{
SendMessage (this.axVSDrawing.Handle,WM_UNDO,IntPtr.Zero ,
IntPtr.Zero );
}
 
Back
Top