![]() |
nonVCL (Edit Control) ESC-Notification an Parent
Dies sind meine ersten Gehversuche in nonVCL-GUI.
Ich habe folgendes Formular:
Delphi-Quellcode:
In der WndProc wird in der WM_Create-Message u.a. folgendes Edit control erstellt:
inst:=getmodulehandle(nil);
wndclass.style:=0; wndclass.lpfnWndProc:=@wndproc; wndclass.cbClsExtra:=0; wndclass.cbWndExtra:=0; wndclass.hInstance:=0; wndclass.hIcon:=0; wndclass.hCursor:=0; wndclass.hbrBackground:=COLOR_BACKGROUND; wndclass.lpszMenuName:=nil; wndclass.lpszClassName:='Fenster1'; registerclass(wndclass); createwindowEx(WS_EX_TOPMOST, 'Fenster1','Test', WS_CAPTION or WS_visible, 50,50,320,200,0,0,inst,nil);
Delphi-Quellcode:
Jetzt bekomme ich bei der Eingabe eines Zeichens in das Edit Control eine EN_Change Notification in meiner WndProc vom Formular (weil sich der Inhalt geändert hat). Ich hätte aber ganz gern jeden Tastendruck mitbekommen (auch wenn sich nicht der Inhalt ändert; im besonderen [ESC]). Derzeit bekomme ich bei [ESC], wenn der Fokus beim Edit control liegt absolut keine Message an die Parent WndProc (also mein Formular).
edit:=createwindowex(WS_EX_CLIENTEDGE,
'Edit','', ws_child or ws_visible or ws_border or ws_clipchildren, 20,50,280,20,wnd,0,inst,nil); //wnd:hwnd aus den Übergabeparametern Kann ich dafür irgendetwas einstellen, oder muss ich mir die Wndproc vom Edit Control holen und subclassen? Edit (Fast vergessen): Natürlich bedanke ich mich für jeden Hinweis :-D |
Re: nonVCL (Edit Control) ESC-Notification an Parent
Da hilft nur Subclassen und auf WM_KEYDOWN usw. zu reagieren. Ich habe mal ein Edit gesubclassed (wattn deutsch :wall: ), damit man dort nur Ziffern eingeben konnte:
WndProc des Edits:
Delphi-Quellcode:
WndProc für das Edit umbiegen:
function EditWndProc(hEdit, uMsg, wParam, lParam: DWORD): DWORD; stdcall;
begin Result := 0; case uMsg of WM_CHAR: case Byte(wParam) of Byte('0')..Byte('9'), Byte(','), VK_DELETE, VK_BACK: CallWindowProc(OldWndProc, hEdit, uMsg, wParam, lParam); end; else Result := CallWindowProc(OldWndProc, hEdit, uMsg, wParam, lParam); end; end;
Delphi-Quellcode:
OldWndProc := Pointer(SetWindowLong(GetDlgItem(hWnd, 103), GWL_WNDPROC, Integer(@EditWndProc)));
|
Re: nonVCL (Edit Control) ESC-Notification an Parent
Na, ok. Habs mir fast gedacht. Danke dir.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:20 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz