ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Get ToolbarButton directly from ButtonString?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

984 Posts

Posted - Mar 27 2021 :  18:55:27  Show Profile  Reply
Is it possible to get a ToolbarButton DIRECTLY from a ButtonString (e.g ivbImageSave) without having to iterate with:

function GetButtonFromButtonStr(const AButtonStr: string): TImageEnViewButton;
var
  bt: TImageEnViewButton;
begin
  for bt := Low(TImageEnViewButton) to High(TImageEnViewButton) do
  begin
    if SameText(AButtonStr, ButtonToStr(bt)) then
    begin
      Result := bt;
      BREAK;
    end;
  end;
end;


So I could add a Button to the Toolbar with simply:

ImageEnViewToolbar1.Buttons := ImageEnViewToolbar1.Buttons + [ButtonFromButtonString(ivbImageSave)];

PeterPanino

984 Posts

Posted - Mar 28 2021 :  05:35:42  Show Profile  Reply
I wrote this unit:

attach/PeterPanino/202132853214_UToolbarButtonStrings.zip
1010 Bytes

Then I use this function:

function TformMain.GetButtonFromButtonStr(const AButtonStr: string): TImageEnViewButton;
var
  //bt: TImageEnViewButton;
  idx: Integer;
begin
  idx := UToolbarButtonStrings.SLToolbarButtonStrings.IndexOf(AButtonStr);
  Result := TImageEnViewButton(idx);

  (*for bt := Low(TImageEnViewButton) to High(TImageEnViewButton) do
  begin
    if SameText(AButtonStr, ButtonToStr(bt)) then
    begin
      Result := bt;
      BREAK;
    end;
  end;*)
end;


Is this correct? Or is there a better BUILT-IN function for this?
Go to Top of Page

xequte

39053 Posts

Posted - Mar 28 2021 :  18:51:20  Show Profile  Reply
Sorry, I'm not really following what you are trying to do here, but the other method is to reference the ID's (tags of each button):

https://www.imageen.com/help/ImageEn_Toolbar_Button_IDs.html

That way you don't have to worry about the text changing due to localization.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: