Behandeln WM_CHAR, WM_KEYDOWN auch das drücken der Enter Taste?
-
Was ne blöde Idee von mir, benutze WM_KEYDOWN.
Lese selbst:
PSDK schrieb:
The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. WM_CHAR contains the character code of the key that was pressed.
WM_CHAR
chCharCode = (TCHAR) wParam; // character code
lKeyData = lParam; // key dataParameters
chCharCode
Value of wParam. Specifies the character code of the key.
lKeyData
Value of lParam. Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table:
Value Description
0-15 Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user holding down the key.
16-23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM).
24 Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
25-28 Reserved; do not use.
29 Specifies the context code. The value is 1 if the ALT key is held down while the key is pressed; otherwise, the value is 0.
30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up.
31 Specifies the transition state. The value is 1 if the key is being released, or it is 0 if the key is being pressed.Return Values
An application should return zero if it processes this message.
Remarks
Because there is not necessarily a one-to-one correspondence between keys pressed and character messages generated, the information in the high-order word of the lKeyData parameter is generally not useful to applications. The information in the high-order word applies only to the most recent WM_KEYDOWN message that precedes the posting of the WM_CHAR message.
For enhanced 101- and 102-key keyboards, extended 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 divide (/) and ENTER keys in the numeric keypad. Some other keyboards may support the extended-key bit in the lKeyData parameter.
-
Hast du dir den Link angesehen?
-
WM_KEYDOWN und WM_CHAR funktionieren nicht und ich bin ziemlich sicher das das was mit dem IsDialogMessage für Tabstops zu tun hat.
@link was soll man sich da groß ansehen, du hast doch meinen Code gesehen oder? ich sehe zu dem auf www.winapi.net kaum einen unterschied (codemäßig).
Ich habe jetzt mal if(!IsDialogMessage) weggelassen und es funzt, das Problem ist wie kriege ich das hin das Tabstops und das Subclassing funktionieren
-
Srry link habe deinen link zu spät gesehen, mit dem Code funktioniert es zwar auch mit IsDialogMessage allerdings geht jetzt Tabstop net mehr

-
oh das stimmt. dann muss man den code in WM_GETDLGCODE ein bisschen verfeinern.

-
ähm link ich halte die deutsche übersetzung nicht wirklich für gelungen ... ich verstehe nämlich so gut wie gar nichts ... kannst du mir mal in richtigem Deutsch sagen was ich jetzt noch ändern muss?
-
ne, da geb ich dir doch lieber den link zum englischen text.
-
also ich verstehe das immer noch nicht richtig. Ich bräuchte jetzt wirklich mal ein Beispiel wie ich das genau machen soll. Ich wann muss ich was/wo/wieoft zurückgeben?

-
Peek at the lParam. If it is a press of the Return key, then return DLGC_WANTMESSAGE so the message will not be handled by the dialog manager.
-
Ich glaube ihr solltet meine Funktion einfach anpassen, denn ich verstehe immer noch nicht was ihr genau von mir wollt:
LRESULT CALLBACK WndEditProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_GETDLGCODE: return DLGC_WANTALLKEYS; case WM_KEYDOWN: if(wParam == VK_RETURN) { SendMessage((HWND) GetWindowLong(hwnd, GWL_HWNDPARENT), WM_COMMAND, MAKEWPARAM(BU_WEITER, 0),0); return DLGC_WANTALLKEYS; } //Kein break !!! default: return CallWindowProc((WNDPROC)oldeditproc, hwnd, message, wParam, lParam);; }
-
nice try
-
Sag mal ist BU_WEITER ein Button? Dann mach es doch wie "button" es vorgeschlagen hat.
-
was ist mit dem style ES_WANTRETURN ???
ES_WANTRETURN Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiple-line edit control in a dialog box. Without this style, pressing the ENTER key has the same effect as pressing the dialog box’s default pushbutton. This style has no effect on a single-line edit control.
-
This style has no effect on a single-line edit control
-
case ( WM_CHAR ): switch ( wParam ) { case ( '\r' ): // SendMessage ( ...... ); return ( 0 ) } break;
-
????
-
@!!!! hier gehts doch um
Behandeln WM_CHAR, WM_KEYDOWN auch das drücken der Enter Taste?
(oderrhabichschonzuvielbierimkopp
)na so gehts halt !
-
So (ähnlich) gehts nur wenn man nicht IsDialogMessage benutzt.
-
Also nochmal für alle zum mitschreiben, das Codeschnipsel das ich zuletzt gepostet habe funktioniert auch mit IsDialogMessage(). Allerdings funktioniert dann der Tabstop nicht mehr um zwischen den Feldern zu wechseln.
-
Jo, du hast ja auch die WM_GETDLGCODE Behandlung drin. Da darfst du eben nur DLGC_WANTMESSAGE zurückgeben wenn die Enter-Taste gedrückt wurde. Wenns nicht Enter war, rufst du mit CallWindowProc die original Edit-Proc auf.