Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 08-14-2015, 10:30 PM
Badger Badger is offline
Member
 
Join Date: Aug 2013
Location: Sheffield, Tasmania (Aust)
Posts: 76
Default Filling a StaticListAction at run time

I'm using an ActionManager to populate an ActionToolbar. I have used it to put a StaticListAction on the toolbar to allow the user to select from the screen fonts. I can't find a way to load the fonts into the list at run time. I've tried ....assign(screen.fonts) but just get an incompatibility error.

Can anybody help?

Badger
Reply With Quote
  #2  
Old 08-17-2015, 03:19 AM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 198
Default

I think what you are looking for can be found here.

delphi(dot)about(dot)com/od/vclusing/a/drawincombobox.htm

sorry for mangling the URL, but I don't seem to have high enough privileges to post a link as yet
Reply With Quote
  #3  
Old 08-17-2015, 08:10 AM
Badger Badger is offline
Member
 
Join Date: Aug 2013
Location: Sheffield, Tasmania (Aust)
Posts: 76
Default

Nice try but when you put that code in the program it comes up with a too many actual parameters error. The TStaticListAction does not behave like a normal combobox. Hence the refusal to compile an assign method. I'll just have to keep looking!!! Thanks for trying.

Badger
Reply With Quote
  #4  
Old 08-17-2015, 10:33 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,333
Default

I would say this looks promissing:
http://www.delphisources.ru/pages/fa...t/LiB0061.html
Reply With Quote
  #5  
Old 08-17-2015, 07:58 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 198
Default

Never having worked with TStaticActionList, I can't tell you if this is the correct way to work with this type of control, but here's what I got working so far.

in your FormCreate add the following code to add the Screen fonts to the drop down
Code:
var
   cnt: Integer;
begin
   for cnt := 0 to Screen.Fonts.Count - 1 do
      With MyStaticListAction.Items.Add do
         Caption := Screen.Fonts.Strings[cnt];
   ...
end;
You may need to filter out some of the fonts as I get some fonts that don't appear in MS Word's list of fonts (not sure how they distinguish??)

Then add the method for OnItemSelected
Code:
procedure TForm1.MyStaticListActionItemSelected(Sender: TCustomListAction; Control: TControl);
var
   SelectedFont: String;
begin
   SelectedFont := (Control as TCustomActionCombo).SelText;
   ShowMessage(SelectedFont);
end;
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 12:02 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.