diff --git a/lcl/interfaces/win32/win32wsbuttons.pp b/lcl/interfaces/win32/win32wsbuttons.pp index e418c59fe8..569bef345c 100644 --- a/lcl/interfaces/win32/win32wsbuttons.pp +++ b/lcl/interfaces/win32/win32wsbuttons.pp @@ -60,6 +60,7 @@ type class procedure SetLayout(const ABitBtn: TCustomBitBtn; const AValue: TButtonLayout); override; class procedure SetMargin(const ABitBtn: TCustomBitBtn; const AValue: Integer); override; class procedure SetSpacing(const ABitBtn: TCustomBitBtn; const AValue: Integer); override; + class procedure SetText(const AWinControl: TWinControl; const AText: string); override; end; { TWin32WSSpeedButton } @@ -407,6 +408,10 @@ begin DrawBitBtnImage(ABitBtn, PChar(ABitBtn.Caption)); end; +procedure TWin32WSBitBtn.SetText(const AWinControl: TWinControl; const AText: string); +begin + DrawBitBtnImage(TCustomBitBtn(AWinControl), PChar(AText)); +end; initialization diff --git a/lcl/interfaces/win32/win32wscontrols.pp b/lcl/interfaces/win32/win32wscontrols.pp index e51a56723c..757faf3281 100644 --- a/lcl/interfaces/win32/win32wscontrols.pp +++ b/lcl/interfaces/win32/win32wscontrols.pp @@ -308,72 +308,10 @@ end; procedure TWin32WSWinControl.SetText(const AWinControl: TWinControl; const AText: string); Var Handle: HWnd; -{ TCI: TC_ITEM; } - TempText: string; -Const - TermChar: PChar = #0#0; Begin Handle := AWinControl.Handle; - Assert(Handle<>0,'Trace:WARNING: [TWin32WidgetSet.SetLabel] --> Got NULL handle'); - Assert(False, 'Trace:Setting the label in TWin32WidgetSet.SetLabel'); - - Case AWinControl.FCompStyle Of - csBitBtn: - DrawBitBtnImage(TCustomBitBtn(AWinControl), PChar(AText)); - - -{ TODO: CHECK !! Code was never reached in SetLabel ? } -{ - csFileDialog, csOpenFileDialog, csSaveFileDialog, csSelectDirectoryDialog, - csColorDialog, csFontDialog: - Begin - Assert(False, Format('Trace:TWin32WidgetSet.SetLabel - Got %S', [CS_To_String(AWinControl.FCompStyle)])); - Assert(False, 'Trace:TWin32WidgetSet.SetLabel - I''m not sure if this''ll work'); - Assert(False, Format('Trace:Is Sender a TCommonDialog - %S', [BOOL_RESULT[AWinControl Is TCommonDialog]])); - If AWinControl Is TCommonDialog Then - TCommonDialog(AWinControl).Title := AText - Else - AWinControl.Caption := AText; - Assert(False, Format('Trace:TWin32WidgetSet.SetLabel - Leaving %S', [CS_To_String(AWinControl.FCompStyle)])); - End; -} - - csComboBox: - Begin - Assert(False, Format('Trace:TWin32WidgetSet.SetLabel - Got %S', [CS_To_String(AWinControl.FCompStyle)])); - Assert(False, Format('Trace:TWin32WidgetSet.SetLabel - label --> %S', [AText])); - if TCustomComboBox(AWinControl).Style = csDropDownList then - Windows.SendMessage(Handle, CB_SELECTSTRING, -1, LPARAM(PChar(AText))) - else - Windows.SendMessage(Handle, WM_SETTEXT, 0, LPARAM(PChar(AText))); - End; - csMemo: - Begin - SendMessage(Handle, WM_SETTEXT, 0, LPARAM(PChar(AText))); - End; - { - csNotebook: - Begin - Assert(False, 'Trace: TWin32WidgetSet.SetLabel - Got csNotebook'); - with TLMNotebookEvent(Data^) do - if Parent=Sender then - begin - TCI.mask := TCIF_TEXT; - Assert(False, Format('Trace:TWin32WidgetSet.SetLabel - label --> %S', [Str])); - TCI.pszText := PChar(Str); - Windows.SendMessage(TCustomNotebook(Sender).Handle, TCM_SETITEM, Page, LPARAM(@TCI)); - end - End; - } - csToolButton: - Begin - TempText := AText + TermChar; - SendMessage(AWinControl.Parent.Handle, TB_ADDSTRING, 0, LPARAM(PChar(TempText))); - End; - Else - Windows.SetWindowText(Handle, PChar(AText)); - End; - Assert(False, Format('Trace:[TWin32WidgetSet.SetLabel] %S --> END', [AWinControl.ClassName])); + Assert(Handle<>0,'Trace:WARNING: [TWin32WSWinControl.SetText] --> Got NULL handle'); + Windows.SetWindowText(Handle, PChar(AText)); End; procedure TWin32WSWinControl.ConstraintsChange(const AWinControl: TWinControl); diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index 9a4d56a89f..ebde66e28c 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -90,6 +90,7 @@ type class procedure SetItemIndex(const ACustomComboBox: TCustomComboBox; NewIndex: integer); override; class procedure SetMaxLength(const ACustomComboBox: TCustomComboBox; NewLength: integer); override; class procedure SetStyle(const ACustomComboBox: TCustomComboBox; NewStyle: TComboBoxStyle); override; + class procedure SetText(const AWinControl: TWinControl; const AText: string); override; class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; override; class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); override; @@ -166,6 +167,7 @@ type const AParams: TCreateParams): HWND; override; class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override; class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); override; + class procedure SetText(const AWinControl: TWinControl; const AText: string); override; class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override; end; @@ -685,6 +687,18 @@ begin GetWindowInfo(winhandle)^.MaxLength := NewLength; end; +procedure TWin32WSCustomComboBox.SetText(const AWinControl: TWinControl; const AText: string); +var + Handle: HWND; +begin + Assert(False, Format('Trace:TWin32WSCustomComboBox.SetText --> %S', [AText])); + Handle := AWinControl.Handle; + if TCustomComboBox(AWinControl).Style = csDropDownList then + Windows.SendMessage(Handle, CB_SELECTSTRING, -1, LPARAM(PChar(AText))) + else + Windows.SendMessage(Handle, WM_SETTEXT, 0, LPARAM(PChar(AText))); +end; + function TWin32WSCustomComboBox.GetItems(const ACustomComboBox: TCustomComboBox): TStrings; var winhandle: HWND; @@ -877,6 +891,11 @@ begin TWin32WidgetSet(InterfaceObject).RecreateWnd(ACustomMemo); end; +procedure TWin32WSCustomMemo.SetText(const AWinControl: TWinControl; const AText: string); +begin + SendMessage(AWinControl.Handle, WM_SETTEXT, 0, LPARAM(PChar(AText))); +end; + procedure TWin32WSCustomMemo.SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); begin // TODO: check if can be done without recreation