type
TRehCheckComboBox =
class(TRehCustomComboBox)
private
FListInstance: Pointer;
FDefListProc: Pointer;
procedure ListWndProc(
var Message: TMessage);
// ...
end;
constructor TRehCheckComboBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FListInstance := MakeObjectInstance(ListWndProc);
end;
destructor TRehCheckComboBox.Destroy;
begin
FreeObjectInstance(FListInstance);
inherited;
end;
procedure TRehCheckComboBox.CreateWnd;
var
cbi: TComboBoxInfo;
pListHandle: ^HWND;
begin
inherited CreateWnd;
FillChar(cbi, SizeOf(cbi), 0);
cbi.cbSize := SizeOf(cbi);
pListHandle := @ListHandle;
if GetComboBoxInfo(
Handle, cbi)
then
begin
pListHandle^ := cbi.hwndList;
FDefListProc := Pointer(GetWindowLong(ListHandle, GWL_WNDPROC));
SetWindowLong(ListHandle, GWL_WNDPROC, Longint(FListInstance));
end
else
begin
//OutputDebugString(PChar(SysErrorMessage(GetLastError)));
pListHandle^ := 0;
end;
end;
procedure TRehCheckComboBox.ListWndProc(
var Message: TMessage);
var
X, Y,
Index: Integer;
begin
case Message.Msg
of
WM_LBUTTONDOWN:
begin
X := TWMMouse(
Message).XPos;
Y := TWMMouse(
Message).YPos;
Index := ItemAtPos(Point(X, Y), True);
if Index <> -1
then
begin
if not UseRightToLeftAlignment
then
begin
if X - ItemRect(
Index).Left < GetCheckWidth
then
begin
ToggleClickCheck(
Index);
Exit;
end;
end
else
begin
Dec(X, ItemRect(
Index).Right - GetCheckWidth);
if (X > 0)
and (X < GetCheckWidth)
then
begin
ToggleClickCheck(
Index);
Exit;
end;
end;
end;
end;
end;
Message.Result := CallWindowProc(FDefListProc, ListHandle,
Message.Msg,
Message.WParam,
Message.LParam);
end;