From 2c5e67e27446634c840ab8c881e0fa19f46c4d93 Mon Sep 17 00:00:00 2001 From: micha Date: Thu, 4 Nov 2004 10:13:54 +0000 Subject: [PATCH] remove usage of fcompstyle by split up of twin32wscustomlistbox.getstrings and twin32wscustomlistbox.getitemindex git-svn-id: trunk@6197 - --- lcl/interfaces/win32/win32wschecklst.pp | 14 ++++++++++-- lcl/interfaces/win32/win32wsclistbox.pp | 10 +++++++++ lcl/interfaces/win32/win32wsstdctrls.pp | 30 +++++-------------------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/lcl/interfaces/win32/win32wschecklst.pp b/lcl/interfaces/win32/win32wschecklst.pp index acae4a8e90..ba9b80b277 100644 --- a/lcl/interfaces/win32/win32wschecklst.pp +++ b/lcl/interfaces/win32/win32wschecklst.pp @@ -33,9 +33,9 @@ uses // To get as little as posible circles, // uncomment only when needed for registration //////////////////////////////////////////////////// - CheckLst, + Classes, CheckLst, StdCtrls, //////////////////////////////////////////////////// - WSCheckLst, WSLCLClasses, Win32Int, Windows; + WSCheckLst, WSLCLClasses, Win32Int, Win32Proc, Windows; type @@ -47,6 +47,7 @@ type public class function GetChecked(const ACheckListBox: TCustomCheckListBox; const AIndex: integer): boolean; override; + class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override; class procedure SetChecked(const ACheckListBox: TCustomCheckListBox; const AIndex: integer; const AChecked: boolean); override; end; @@ -60,6 +61,15 @@ begin Result := TWin32CheckListBoxStrings(ACheckListBox.Items).Checked[AIndex]; end; +function TWin32WSCustomCheckListBox.GetStrings(const ACustomListBox: TCustomListBox): TStrings; +var + Handle: HWND; +begin + Handle := ACustomListBox.Handle; + Result := TWin32CheckListBoxStrings.Create(Handle, ACustomListBox); + GetWindowInfo(Handle)^.List := Result; +end; + procedure TWin32WSCustomCheckListBox.SetChecked(const ACheckListBox: TCustomCheckListBox; const AIndex: integer; const AChecked: boolean); var diff --git a/lcl/interfaces/win32/win32wsclistbox.pp b/lcl/interfaces/win32/win32wsclistbox.pp index f86d9e47ea..dc2a18524f 100644 --- a/lcl/interfaces/win32/win32wsclistbox.pp +++ b/lcl/interfaces/win32/win32wsclistbox.pp @@ -47,6 +47,7 @@ type public class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override; + class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override; end; @@ -85,6 +86,15 @@ begin Result := Params.Window; end; +function TWin32WSCustomCListBox.GetStrings(const ACustomListBox: TCustomListBox): TStrings; +var + Handle: HWND; +begin + Handle := ACustomListBox.Handle; + Result := TWin32CListStringList.Create(Handle, ACustomListBox) + GetWindowInfo(Handle)^.List := Result; +end; + initialization //////////////////////////////////////////////////// diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index 34cabad463..91e659e4ef 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -439,24 +439,12 @@ begin end; function TWin32WSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer; -var - Handle: HWND; begin - Handle := ACustomListBox.Handle; - case ACustomListBox.FCompStyle of - csListBox, csCListBox: - begin - Result := SendMessage(Handle, LB_GETCURSEL, 0, 0); - if Result = LB_ERR then - begin - Assert(False, 'Trace:[TWin32WidgetSet.IntSendMessage3] Could not retrieve item index via LM_GETITEMINDEX; try selecting an item first'); - Result := -1; - end; - end; - csNotebook: - begin - Result := SendMessage(Handle, TCM_GETCURSEL, 0, 0); - end; + Result := SendMessage(ACustomListBox.Handle, LB_GETCURSEL, 0, 0); + if Result = LB_ERR then + begin + Assert(false, 'Trace:[TWin32WSCustomListBox.GetItemIndex] could not retrieve itemindex, try selecting an item first'); + Result := -1; end; end; @@ -483,13 +471,7 @@ var Handle: HWND; begin Handle := ACustomListBox.Handle; - if ACustomListBox.fCompStyle = csCListBox then - Result := TWin32CListStringList.Create(Handle, ACustomListBox) - else - if ACustomListBox.fCompStyle = csCheckListBox then - Result := TWin32CheckListBoxStrings.Create(Handle, ACustomListBox) - else - Result := TWin32ListStringList.Create(Handle, ACustomListBox); + Result := TWin32ListStringList.Create(Handle, ACustomListBox); GetWindowInfo(Handle)^.List := Result; end;