Is there any way to capture what a user enters from keyboard during Getpoint? I see where I can set
prPointOptions.AllowNone = True
and then be able determine if a user hit Enter. I would like to be able to capture any random input.
Is this possible?
Thanks
Chris
Here is an example that illustrates two approaches, the one Jeff mentioned and the message filter. I'm not sure if one is better than the other, you find out.
I'm curious to know what kind of feature you want to implement, usually one will use keywords rather than grabbing raw keyboard inputs ...
const int WM_KEYDOWN = 0x0100; [CommandMethod("AppMsg")] public void AppMsg() { Application.PreTranslateMessage += new PreTranslateMessageEventHandler(Application_PreTranslateMessage); appMsgFilter = new AppMessageFilter(); System.Windows.Forms.Application.AddMessageFilter(appMsgFilter); Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; var pr = doc.Editor.GetPoint("\nGet Point: "); System.Windows.Forms.Application.RemoveMessageFilter(appMsgFilter); Application.PreTranslateMessage -= new PreTranslateMessageEventHandler(Application_PreTranslateMessage); } void Application_PreTranslateMessage(
object sender,
PreTranslateMessageEventArgs e) { System.Windows.Interop.MSG msg = e.Message; if (msg.message == WM_KEYDOWN) { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; doc.Editor.WriteMessage("\nKey: " + msg.wParam); } } static AppMessageFilter appMsgFilter = null; class AppMessageFilter : System.Windows.Forms.IMessageFilter { public bool PreFilterMessage(ref System.Windows.Forms.Message m) { if (m.Msg == WM_KEYDOWN) { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; doc.Editor.WriteMessage("\nKey: " + m.WParam); } return false; } }
Regards,
Philippe.
Thanks. I'll check it out. I am trying combine GetPoint with GetInt or Getstring. When a user is prompted for a point I want to check for three things: 1)valid point, 2) enter or 3) random integer/string input.