From d4ce99fba2c61b4d2fd1c7163c2a7301335ae57c Mon Sep 17 00:00:00 2001 From: micha Date: Mon, 1 Nov 2004 18:48:43 +0000 Subject: [PATCH] remove usage of FCompStyle in GetText using splitup git-svn-id: trunk@6185 - --- lcl/interfaces/win32/win32wscontrols.pp | 30 +---------------- lcl/interfaces/win32/win32wsstdctrls.pp | 43 ++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/lcl/interfaces/win32/win32wscontrols.pp b/lcl/interfaces/win32/win32wscontrols.pp index 594a10f9e4..3092838978 100644 --- a/lcl/interfaces/win32/win32wscontrols.pp +++ b/lcl/interfaces/win32/win32wscontrols.pp @@ -280,37 +280,9 @@ begin end; function TWin32WSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean; -var - CapLen: Cardinal; - Caption: PChar; - Handle: HWND; begin - Result := AWinControl.HandleAllocated; - if not Result then - exit; AText := ''; - Handle := AWinControl.Handle; - case AWinControl.FCompStyle of - csComboBox: - begin - // + 1 = terminating null character - CapLen := Windows.SendMessage(Handle, WM_GETTEXTLENGTH, 0, 0) + 1; - Caption := StrAlloc(CapLen); - Windows.SendMessage(Handle, WM_GETTEXT, CapLen, LPARAM(Caption)); - AText := StrPas(Caption); - StrDispose(Caption); - end; - csEdit, csMemo: - begin - CapLen := GetWindowTextLength(Handle); - Caption := StrAlloc(CapLen + 1); - GetWindowText(Handle, Caption, CapLen + 1); - AText := StrPas(Caption); - StrDispose(Caption); - end; - else - Result := false; - end; + Result := false; end; procedure TWin32WSWinControl.SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index a909fabbca..9a4d56a89f 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -33,7 +33,7 @@ uses // To get as little as posible circles, // uncomment only when needed for registration //////////////////////////////////////////////////// - Classes, StdCtrls, Controls, Graphics, Forms, + Classes, StdCtrls, Controls, Graphics, Forms, SysUtils, //////////////////////////////////////////////////// WSStdCtrls, WSLCLClasses, Windows, LCLType, Win32Int, Win32Proc, InterfaceBase, Win32WSControls; @@ -81,6 +81,7 @@ type class function GetSelLength(const ACustomComboBox: TCustomComboBox): integer; override; class function GetItemIndex(const ACustomComboBox: TCustomComboBox): integer; override; class function GetMaxLength(const ACustomComboBox: TCustomComboBox): integer; override; + class function GetText(const AWinControl: TWinControl; var AText: string): boolean; override; class procedure SetArrowKeysTraverseList(const ACustomComboBox: TCustomComboBox; NewTraverseList: boolean); override; @@ -144,6 +145,7 @@ type class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override; class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override; class function GetMaxLength(const ACustomEdit: TCustomEdit): integer; {override;} + class function GetText(const AWinControl: TWinControl; var AText: string): boolean; override; class procedure SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); override; class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override; @@ -627,6 +629,26 @@ begin Result := GetWindowInfo(ACustomComboBox.Handle)^.MaxLength; end; +function TWin32WSCustomComboBox.GetText(const AWinControl: TWinControl; var AText: string): boolean; +var + Handle: HWND; + CapLen: dword; + Caption: PChar; +begin + Result := AWinControl.HandleAllocated; + if not Result then + exit; + AText := ''; + Handle := AWinControl.Handle; + // TODO: this can be made shorter probably, using SetLength(AText, ...) + // + 1 = terminating null character + CapLen := Windows.SendMessage(Handle, WM_GETTEXTLENGTH, 0, 0) + 1; + Caption := StrAlloc(CapLen); + Windows.SendMessage(Handle, WM_GETTEXT, CapLen, LPARAM(Caption)); + AText := StrPas(Caption); + StrDispose(Caption); +end; + procedure TWin32WSCustomComboBox.SetArrowKeysTraverseList(const ACustomComboBox: TCustomComboBox; NewTraverseList: boolean); begin @@ -743,6 +765,25 @@ begin Result := GetWindowInfo(ACustomEdit.Handle)^.MaxLength; end; +function TWin32WSCustomEdit.GetText(const AWinControl: TWinControl; var AText: string): boolean; +var + CapLen: dword; + Caption: PChar; + Handle: HWND; +begin + Result := AWinControl.HandleAllocated; + if not Result then + exit; + AText := ''; + Handle := AWinControl.Handle; + // TODO: this can be made shorter probably, using SetLength(AText, ...) + CapLen := GetWindowTextLength(Handle); + Caption := StrAlloc(CapLen + 1); + GetWindowText(Handle, Caption, CapLen + 1); + AText := StrPas(Caption); + StrDispose(Caption); +end; + procedure TWin32WSCustomEdit.SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); const EditStyles: array[TEditCharCase] of integer = (0, ES_UPPERCASE, ES_LOWERCASE);