Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi nonVCL (Edit Control) ESC-Notification an Parent (https://www.delphipraxis.net/88641-nonvcl-edit-control-esc-notification-parent.html)

sirius 18. Mär 2007 19:28


nonVCL (Edit Control) ESC-Notification an Parent
 
Dies sind meine ersten Gehversuche in nonVCL-GUI.

Ich habe folgendes Formular:
Delphi-Quellcode:
  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);
In der WndProc wird in der WM_Create-Message u.a. folgendes Edit control erstellt:
Delphi-Quellcode:
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
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).
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

Luckie 18. Mär 2007 21:25

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:
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;
WndProc für das Edit umbiegen:
Delphi-Quellcode:
OldWndProc := Pointer(SetWindowLong(GetDlgItem(hWnd, 103), GWL_WNDPROC, Integer(@EditWndProc)));

sirius 24. Mär 2007 09:48

Re: nonVCL (Edit Control) ESC-Notification an Parent
 
Na, ok. Habs mir fast gedacht. Danke dir.


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:48 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz