Home > Net >  Program to form text box automatically add, I could not find a text box displays
Program to form text box automatically add, I could not find a text box displays

Time:09-26

Form design with adding RTB1 text boxes, procedure calls, some can call again, don't know what's the matter with the

CodePudding user response:

You can call behind the code is copied to the front, there to see if an error?

CodePudding user response:

reference 1/f, lover and response:
you put behind can invoke the code is copied to the front, there to see if an error?

CodePudding user response:

On the other Class, the original control in the form of a Class to instantiate.

CodePudding user response:

Loved the
reference 5 floor response:
on the other Class, the original control in the form of a Class to instantiate,

Use new? Will not generate another text box

CodePudding user response:

Is your RTB1 dynamically generated?
Where is the statement?

CodePudding user response:

references on 7th floor is wrath of god reply:
your RTB1 is dynamically generated?
Where is the statement?

The generated RTB1 is the original form

CodePudding user response:

Do a text box form, name is RTB1, but not in the call, not sure what is the reason,


The namespace keyrecord
{
Public partial class WDF1: Form
{
Public WDF1 ()
{
InitializeComponent ();
KeyRecord kr=new KeyRecord ();
Kr. Start ();
}

Public void Form1_Load (object sender, EventArgs e) {}

Public class KeyRecord
{
Public List _Record=new List (a);

Private const int WM_KEYDOWN=0 x100;
Private const int WM_KEYUP=0 x101;
Private const int WM_SYSKEYDOWN=0 x104;
Private const int WM_SYSKEYUP=0 x105;
The public event KeyEventHandler OnKeyDownEvent;
The public event KeyEventHandler OnKeyUpEvent;
The public event KeyPressEventHandler OnKeyPressEvent;
Static int hKeyboardHook=0;
Public const int WH_KEYBOARD_LL=13;
HookProc KeyboardHookProcedure;
[StructLayout (LayoutKind. Sequential)]
Public class KeyboardHookStruct
{
Public int vkCode;
Public int scanCode.
Public int flags;
Public int time;
Public int dwExtraInfo;
}
[DllImport (" user32. DLL, "CharSet=CharSet. Auto, CallingConvention=CallingConvention. StdCall)]
Public static extern int SetWindowsHookEx (int idHook, HookProc LPFN, IntPtr hInstance, int threadId);
[DllImport (" user32. DLL, "CharSet=CharSet. Auto, CallingConvention=CallingConvention. StdCall)]
Public static extern bool UnhookWindowsHookEx (int idHook);
[DllImport (" user32. DLL, "CharSet=CharSet. Auto, CallingConvention=CallingConvention. StdCall)]
Public static extern int CallNextHookEx (int idHook, int nCode, Int32 wParam, IntPtr lParam);
[DllImport (" user32 ")]
Public static extern int GetKeyboardState (byte [] pbKeyState);
Public delegate int HookProc (int nCode, Int32 wParam, IntPtr lParam);
Public KeyRecord ()
{
Enclosing OnKeyPressEvent +=new KeyPressEventHandler (KeyBordHook_OnKeyPressEvent);
Start ().
}
Public void the Start ()
{
If (hKeyboardHook==0)
{
KeyboardHookProcedure=new HookProc (KeyboardHookProc);
The Module m=Assembly GetExecutingAssembly (.) GetModules () [0];
IntPtr itp=Marshal. GetHINSTANCE (m);
HKeyboardHook=SetWindowsHookEx (WH_KEYBOARD_LL KeyboardHookProcedure, itp, 0).
If (hKeyboardHook==0) Stop ();
}
}
Public void the Stop ()
{
Bool retKeyboard=true;
If (hKeyboardHook!=0)
{
RetKeyboard=UnhookWindowsHookEx (hKeyboardHook);
HKeyboardHook=0;
}
}
Private int KeyboardHookProc (int nCode, Int32 wParam, IntPtr lParam)
{
If ((nCode & gt;=0) & amp; & (OnKeyDownEvent!=null | | OnKeyUpEvent!=null | | OnKeyPressEvent!=null))
{
KeyboardHookStruct MyKeyboardHookStruct=(KeyboardHookStruct) Marshal. PtrToStructure (lParam, typeof (KeyboardHookStruct));
If (OnKeyPressEvent!=null & amp; & (wParam==WM_KEYDOWN | | wParam==WM_SYSKEYDOWN))
{
RTB1. AppendText (" KeyCode: "+ MyKeyboardHookStruct. VkCode +" | Time: "+ DateTime. Now +" \ r ");
}
}
Return CallNextHookEx (hKeyboardHook, nCode wParam, lParam);
}
Private void KeyBordHook_OnKeyPressEvent (object sender, KeyPressEventArgs e) {}
}

}

}

CodePudding user response:

try to run, 9/f, reference response:
namespace keyrecord
{

}


,,,,,,, you are in a new class of course can't quote to RTB1!
If you must pass RTB1 past,
You can use the constructor,

Public class KeyRecord
{
Public TextBox RTB1 {get; The set; };
Public KeyRecord (TextBox RTB1)
{
Enclosing RTB1=RTB1;
}
}

CodePudding user response:

11 references are nu month god reply:
Quote: try to run, 9/f, reference response:

The namespace keyrecord
{

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related