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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Get ToolbarButton directly from ButtonString?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Mar 27 2021 : 18:55:27
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)];
2   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Mar 28 2021 : 18:51:20
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
PeterPanino Posted - Mar 28 2021 : 05:35:42
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?