Eingabefeld mit Button verknüpfen
-
Huhu,
Kann mir jemand sagen, wie ich ein Eingabefeld mit einem Button verknüpfe, dass heißt ich möchte, dass wenn der Text im Eingabefeld eingegeben wurde mit der Enter Taste dann der dazugehörige Button ausgelöst wird.
Eingabe: Fritz --> Enter drücken -> Button wird ausgelöst
-
CWnd::OnKeyDown
afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );Parameters
nChar
Specifies the virtual-key code of the given key.
nRepCnt
Repeat count (the number of times the keystroke is repeated as a result of the user holding down the key).
nFlags
Specifies the scan code, key-transition code, previous key state, and context code, as shown in the following list:
Value Description
0–7 Scan code (OEM-dependent value).
8 Extended key, such as a function key or a key on the numeric keypad (1 if it is an extended key).
9–10 Not used.
11–12 Used internally by Windows.
13 Context code (1 if the ALT key is held down while the key is pressed; otherwise 0).
14 Previous key state (1 if the key is down before the call, 0 if the key is up).
15 Transition state (1 if the key is being released, 0 if the key is being pressed).For a WM_KEYDOWN message, the key-transition bit (bit 15) is 0 and the context-code bit (bit 13) is 0.
Remarks
The framework calls this member function when a nonsystem key is pressed. A nonsystem key is a keyboard key that is pressed when the ALT key is not pressed or a keyboard key that is pressed when CWnd has the input focus.
Because of auto-repeat, more than one OnKeyDown call may occur before an OnKeyUp member function call is made. The bit that indicates the previous key state can be used to determine whether the OnKeyDown call is the first down transition or a repeated down transition.
For IBM Enhanced 101- and 102-key keyboards, enhanced keys are the right ALT and the right CTRL keys on the main section of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and arrow keys in the clusters to the left of the numeric keypad; and the slash (/) and ENTER keys in the numeric keypad. Some other keyboards may support the extended-key bit in nFlags.
Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.
Kannst du damit was anfangen?
EDIT:
Für Zitate, vor allem, wenn sie lange Zeilen haben, bitte nicht den Code-Tag verwenden.[ Dieser Beitrag wurde am 12.10.2002 um 10:19 Uhr von dEUs editiert. ]
-
Hört sich gut an, aber ich will ja nicht immer wenn ich die Enter Taste auslöse die gleiche Funktion aufrufen
Ich möchte in ein bestimmtes Eingabefeld meinen Text eingeben und dann die Taste Enter drücken, damit dann gleich die Funktion aufgerufen wird, ohne, dass ich erst zur Maus greifen muss und auf "Senden" (z.B.) klicken muss
-
So, der Button brauch die ID
IDOK
Und in OnOK vom Dialog musst du dann den Code einfügen.
-
Ist es vom User zu viel verlangt auf den Button zu klicken?
Bei einer Mehrzeiligen Editbox hättest du dann nämlich ein Problem...Devil