mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-17 22:50:52 +01:00
- win32 and gtk2 working - wince - only setting state. drawing of state is not implemented as before - gtk - only setting state, drawing of grayed state to be implemented - carbon - mapped to UnChecked, Checked (grayed is also treated as checked) git-svn-id: trunk@13356 -
103 lines
3.8 KiB
ObjectPascal
103 lines
3.8 KiB
ObjectPascal
{ $Id$}
|
|
{
|
|
*****************************************************************************
|
|
* Win32WSCheckLst.pp *
|
|
* ------------------ *
|
|
* *
|
|
* *
|
|
*****************************************************************************
|
|
|
|
*****************************************************************************
|
|
* *
|
|
* This file is part of the Lazarus Component Library (LCL) *
|
|
* *
|
|
* See the file COPYING.modifiedLGPL, included in this distribution, *
|
|
* for details about the copyright. *
|
|
* *
|
|
* This program is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
* *
|
|
*****************************************************************************
|
|
}
|
|
unit Win32WSCheckLst;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
////////////////////////////////////////////////////
|
|
// I M P O R T A N T
|
|
////////////////////////////////////////////////////
|
|
// To get as little as posible circles,
|
|
// uncomment only when needed for registration
|
|
////////////////////////////////////////////////////
|
|
Classes, CheckLst, StdCtrls,
|
|
////////////////////////////////////////////////////
|
|
WSCheckLst, WSLCLClasses, Win32Int, Win32Proc, Windows;
|
|
|
|
type
|
|
|
|
{ TWin32WSCheckListBox }
|
|
|
|
{ TWin32WSCustomCheckListBox }
|
|
|
|
TWin32WSCustomCheckListBox = class(TWSCustomCheckListBox)
|
|
private
|
|
protected
|
|
public
|
|
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
|
|
|
|
class function GetState(const ACheckListBox: TCustomCheckListBox;
|
|
const AIndex: integer): TCheckBoxState; override;
|
|
class procedure SetState(const ACheckListBox: TCustomCheckListBox;
|
|
const AIndex: integer; const AState: TCheckBoxState); override;
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
class function TWin32WSCustomCheckListBox.GetStrings(const ACustomListBox: TCustomListBox): TStrings;
|
|
var
|
|
Handle: HWND;
|
|
begin
|
|
Handle := ACustomListBox.Handle;
|
|
Result := TWin32CheckListBoxStrings.Create(Handle, ACustomListBox);
|
|
GetWindowInfo(Handle)^.List := Result;
|
|
end;
|
|
|
|
class function TWin32WSCustomCheckListBox.GetState(
|
|
const ACheckListBox: TCustomCheckListBox; const AIndex: integer
|
|
): TCheckBoxState;
|
|
begin
|
|
Result := TWin32CheckListBoxStrings(ACheckListBox.Items).State[AIndex];
|
|
end;
|
|
|
|
class procedure TWin32WSCustomCheckListBox.SetState(
|
|
const ACheckListBox: TCustomCheckListBox; const AIndex: integer;
|
|
const AState: TCheckBoxState);
|
|
var
|
|
SizeRect: Windows.RECT;
|
|
Handle: HWND;
|
|
begin
|
|
TWin32CheckListBoxStrings(ACheckListBox.Items).State[AIndex] := AState;
|
|
|
|
// redraw control
|
|
Handle := ACheckListBox.Handle;
|
|
Windows.SendMessage(Handle, LB_GETITEMRECT, AIndex, LPARAM(@SizeRect));
|
|
Windows.InvalidateRect(Handle, @SizeRect, False);
|
|
end;
|
|
|
|
initialization
|
|
|
|
////////////////////////////////////////////////////
|
|
// I M P O R T A N T
|
|
////////////////////////////////////////////////////
|
|
// To improve speed, register only classes
|
|
// which actually implement something
|
|
////////////////////////////////////////////////////
|
|
RegisterWSComponent(TCustomCheckListBox, TWin32WSCustomCheckListBox);
|
|
////////////////////////////////////////////////////
|
|
end.
|