아래 팁 2개에서
TListView의 subitem에
tooltip이 나타나는것 설정 변경과
exstyle에서 checkboxes=true로 할경우 설정에 문제를 기술하였 습니다.
두가지 문제를 한번에 해결하는 TListView를 간단히 만들어 봤습니다.
이전에 김태선님이 소개하신 방식대로
디자인타임에 올려진 Form위에 올려진 TListVeiw를 새로정의한 ListView로 교체되는것입니다.
//C++Builder
class TListView : public Comctrls::TListView
{
private:
bool FSubItemImages;
bool FSubItemTooltip;
void __fastcall ResetExtendStyle()
{
ListView_SetExtendedListViewStyle(Handle,ListView_GetExtendedListViewStyle(Handle));
}
void __fastcall SetSubitemTooltip(bool bTooltip)
{
FSubItemTooltip=bTooltip;
ResetExtendStyle();
}
void __fastcall SetSubitemImages(bool bSubitemImage)
{
FSubItemTooltip=bSubitemImage;
ResetExtendStyle();
}
public:
__fastcall TListView(TComponent* Owner)
: Comctrls::TListView(Owner)
{
FSubItemImages=true;
FSubItemTooltip=true;
}
void __fastcall WndProc(TMessage &Msg)
{
if(Msg.Msg==LVM_SETEXTENDEDLISTVIEWSTYLE)
{
if(FSubItemImages)Msg.LParam=Msg.LParam | LVS_EX_SUBITEMIMAGES ;
else Msg.LParam=Msg.LParam & (~ LVS_EX_SUBITEMIMAGES );
if(FSubItemTooltip)Msg.LParam=Msg.LParam | LVS_EX_INFOTIP ;
else Msg.LParam=Msg.LParam & (~ LVS_EX_INFOTIP );
}
Comctrls::TListView::WndProc(Msg);
}
public:
__property bool ShowSubitemTooltip = {read=FSubItemTooltip,write=SetSubitemTooltip};
__property bool ShowSubitemImages = {read=FSubItemImages,write=SetSubitemImages};
};
#define TListView ::TListView
//Delphi
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls,Commctrl;
type
TListView = class(Comctrls.TListView)
private
FSubItemImages: boolean;
FSubItemTooltip: boolean;
procedure ResetExtendStyle();
procedure SetSubitemTooltip(bTooltip: boolean);
procedure SetSubitemImages(bSubitemImage: boolean );
public
constructor Create(AOwner: TComponent); override;
procedure WndProc(var Msg: TMessage); override;
public
property ShowSubitemTooltip: Boolean read FSubItemTooltip write SetSubitemTooltip default True;
property ShowSubitemImages: Boolean read FSubItemImages write SetSubitemImages default True;
end;
implementation
{$R *.dfm}
procedure TListView.ResetExtendStyle();
begin
ListView_SetExtendedListViewStyle(Handle,ListView_GetExtendedListViewStyle(Handle));
end;
procedure TListView.SetSubitemTooltip(bTooltip: boolean);
begin
FSubItemTooltip:=bTooltip;
ResetExtendStyle();
end;
procedure TListView.SetSubitemImages(bSubitemImage: boolean );
begin
FSubItemTooltip:=bSubitemImage;
ResetExtendStyle();
end;
constructor TListView.Create(AOwner: TComponent);
begin
FSubItemImages:=true;
FSubItemTooltip:=true;
inherited;
end;
procedure TListView.WndProc(var Msg: TMessage);
begin
if(Msg.Msg=LVM_SETEXTENDEDLISTVIEWSTYLE)then
begin
if(FSubItemImages)then Msg.LParam:=Msg.LParam or LVS_EX_SUBITEMIMAGES
else Msg.LParam:=Msg.LParam and (not LVS_EX_SUBITEMIMAGES );
if(FSubItemTooltip)then Msg.LParam:=Msg.LParam or LVS_EX_INFOTIP
else Msg.LParam:=Msg.LParam and (not LVS_EX_INFOTIP );
end;
inherited;
end;
//------------------------------------------
//사용예
procedure TForm1.Button2Click(Sender: TObject);
begin
ListView1.Checkboxes:=not ListView1.Checkboxes;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ListView1.ShowSubitemTooltip:= not ListView1.ShowSubitemTooltip;
end;
end.
그럼...
|