0

TJvDockVSPopupPanelのタブアイコンを設定後に変更する方法はありますか?

問題は、プログラムを変更した後、タブアイコンを検証画像に変更したいということです...

ImageList1: TImageList;

procedure TValidationWindow.UpdateIcon;
var
    i, topValidationError  : integer;
begin
    topValidationError := 3;

    {
        SECTION
        //Set topValidationError value to the specific error that has occurred
        SECTION END
    }

    // Set the Icon to the specific image.
    ImageList1.GetIcon(topValidationError, Self.Icon);
end;

上記は初めてのみ機能します!何か案は?

編集:

さらに詳しく調べてみると、TJvDockCustomTabControlにFImages:TCustomImageListがあることがわかりましたが、FImagesにアクセスする方法はまだ見つかりません。このリストにアイコンを追加してから、 imageindexを使用したタブアイコン画像。

解決済み:

したがって、最大の問題は画像リストへのアクセスでした。これは、TJVDockTabControlへのアクセスを許可するTJvDockVIDTabPageControlを介して行うことができます。

タブアイコンを変更するコードは...

if (GetAncestors(Self, 3) is TJvDockTabHostForm) then
    if ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl is TJvDockVIDTabPageControl) then
    begin
        if FTabSheetIndex = - 1 then
            FTabSheetIndex := ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl as TJvDockVIDTabPageControl).PageSheets.IndexOf(TJvDockTabSheet(Self.Parent));
        ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl as TJvDockVIDTabPageControl).Pages[FTabSheetIndex].ImageIndex := x// The icon you want to use
        ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl as TJvDockVIDTabPageControl).Panel.Refresh;
    end;

DockHostWindowを変更するとタブが変更される可能性があるため、FTabSheetIndexを含めました。たとえば、変更する前にタブを削除すると、タブインデックスの順序が変更されるため、簡単に-1に設定して再度見つけることができます。

GetAncestors()に関する情報は、ここにあります。TJvDockServerフォームが固定されていないか、固定されているかをどのように判断できますか?

また、TJvDockTabPageControlにアイコンを追加する必要があります。これは、FormShowイベントで行うのが最適です...

if (GetAncestors(Self, 3) is TJvDockTabHostForm) then
    if ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl is TJvDockVIDTabPageControl) then
    begin
        FTabImageListCount := ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl as TJvDockVIDTabPageControl).Images.Count;
        for i := 0 to ImageList1.Count - 1 do
        begin
            ImageList1.GetIcon(i,Icon);
            ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl as TJvDockVIDTabPageControl).Images.AddIcon(icon);
        end;
    end;

ただし、アプリケーションの開始時にフォームが表示されない場合は、タブをクリックして表示するまで、アイコン変更機能が機能しない場合があります。したがって、フォームがTJvDockHostFormに追加されたらすぐにアイコンを追加するのがおそらく最善です...これはまだ調査中ですが、重要な問題は解決されています。

4

1 に答える 1

0

したがって、最大の問題は画像リストへのアクセスでした。これは、TJVDockTabControlへのアクセスを許可するTJvDockVIDTabPageControlを介して行うことができます。

タブアイコンを変更するコードは...

if (GetAncestors(Self, 3) is TJvDockTabHostForm) then
    if ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl is TJvDockVIDTabPageControl) then
    begin
        if FTabSheetIndex = - 1 then
            FTabSheetIndex := ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl as TJvDockVIDTabPageControl).PageSheets.IndexOf(TJvDockTabSheet(Self.Parent));
        ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl as TJvDockVIDTabPageControl).Pages[FTabSheetIndex].ImageIndex := x// The icon you want to use
        ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl as TJvDockVIDTabPageControl).Panel.Refresh;
    end;

DockHostWindowを変更するとタブが変更される可能性があるため、FTabSheetIndexを含めました。たとえば、変更する前にタブを削除すると、タブインデックスの順序が変更されるため、簡単に-1に設定して再度見つけることができます。

GetAncestors()に関する情報は、ここにあります。TJvDockServerフォームが固定されていないか、固定されているかをどのように判断できますか?

また、TJvDockTabPageControlにアイコンを追加する必要があります。これは、FormShowイベントで行うのが最適です...

if (GetAncestors(Self, 3) is TJvDockTabHostForm) then
    if ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl is TJvDockVIDTabPageControl) then
    begin
        FTabImageListCount := ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl as TJvDockVIDTabPageControl).Images.Count;
        for i := 0 to ImageList1.Count - 1 do
        begin
            ImageList1.GetIcon(i,Icon);
            ((GetAncestors(Self, 3) as TjvDockTabHostForm).PageControl as TJvDockVIDTabPageControl).Images.AddIcon(icon);
        end;
    end;

ただし、アプリケーションの開始時にフォームが表示されない場合は、タブをクリックして表示するまで、アイコン変更機能が機能しない場合があります。したがって、フォームがTJvDockHostFormに追加されたらすぐにアイコンを追加するのがおそらく最善です...これはまだ調査中ですが、重要な問題は解決されています。

于 2013-02-13T13:16:48.150 に答える