Jump to content
stephanos

Which Objects Allow ActiveControl?

Recommended Posts

Dear All

 

I am being driven mad by the fact that some objects do not do things. I started with buttons and abandoned them as I could not control the colour of the caption. I went onto BitBtn’s only to find that & next to a character in the caption does not display the letter as underlined at run time and sometimes does display the letter as underlined at run time after ALT and the accelerated Char are pressed. I should also say that double &, &&Save, as a caption simply displays as “&Save” with nothing underlined.

     I read around and discovered that labels, and I have many of those on my form, allows the display of the letter as underlined at run time and are even visible at design time. Good old labels. For this to happen I just need to ensure the property “ShowAccelChar” is enabled. I can do that!  So I did an experiment with another label and guess what? Use of ActiveControl to place the focus on a label object does not work.

     Form1.ActiveControl := Label11; // does not work

The error message says: ‘simpleformsunit.pas(181,45) Error: Incompatible type for arg no. 1: Got "TLabel", expected "TwinControl" ’

It did work with BitBtn: Form1.ActiveControl := BitBtn3; // Open File has focus

 

Naturally, I have googled this issue but there is nothing specific about ActiveControl and the label object. As there are many many objects in the IDE I am hoping to draw upon someone’s knowledge to find out if I can do what I want, a via which object.  Perhaps the error message is helpful to someone?  Is there an object that I can use as a button (onclick) that will allow me to:

  1. allow use of ActiveControl
  2. set the tab order
  3. offer a tag for use as an integer variable at run time
  4. allow me to control the colour of the caption and the font size (not at run time)
  5. allow to to position the caption centre vertically and horizontally (not at run time)
  6. enable and un-enable at run time
  7. allow accelerated chars to be visible at run time
  8. have an onclick Event

 

Thanks, wait to hear

 

Windows 10, 64 bit

Free Pascal Lazarus Project, version2.0.6

Share this post


Link to post
41 minutes ago, stephanos said:

I am being driven mad by the fact that some objects do not do things

Welcome to software development.

You may find that things become easier (or even clear) for you if you:

  1. Read the help.
  2. Learn about classes and inheritance. Specifically the VCL class hierarchy is important.
  3. Examine the VCL source code.
  4. See what others do.
  5. See what works and what doesn't and learn from your experience..

Good luck.

  • Like 1

Share this post


Link to post
2 hours ago, Anders Melander said:

You may find that things become easier (or even clear) for you if you

  1. Learn about classes and inheritance. Specifically the VCL class hierarchy is important.
  2. Examine the VCL source code.

Which doesn't help, since he is using Lazarus, not Delphi:

3 hours ago, stephanos said:

Free Pascal Lazarus Project, version2.0.6

On the other hand, the source code for the LCL is also available, but it's much more convoluted than the VCL, because it's supposed to be cross platform.

Edited by dummzeuch

Share this post


Link to post
5 hours ago, stephanos said:

Use of ActiveControl to place the focus on a label object does not work.

     Form1.ActiveControl := Label11; // does not work

The error message says: ‘simpleformsunit.pas(181,45) Error: Incompatible type for arg no. 1: Got "TLabel", expected "TwinControl" ’

Only windowed controls (TWinControl descendants) can receive input focus, and thus be assigned as an ActiveControl.  TLabel is a graphical control (TGraphicControl descendant), not a windowed control.  If you need a windowed text label, use TStaticText instead of TLabel.

5 hours ago, stephanos said:

It did work with BitBtn: Form1.ActiveControl := BitBtn3; // Open File has focus

TBitBtn is a windowed control.

5 hours ago, stephanos said:

Is there an object that I can use as a button (onclick) that will allow me to:

  1. allow use of ActiveControl
  2. set the tab order

All windowed controls support that.

5 hours ago, stephanos said:
  1. offer a tag for use as an integer variable at run time

All components, visual and non-visual, support that.

5 hours ago, stephanos said:
  1. allow me to control the colour of the caption and the font size (not at run time)

The reason that doesn't work for you is most likely due to OS theming.  So turn off theming on the button.  Or, use a 3rd party button that allowed custom coloring.  Or, just owner-draw the button yourself manually.

5 hours ago, stephanos said:
  1. allow to to position the caption centre vertically and horizontally (not at run time)

I don't think any standard controls support vertical alignment, only custom-drawn controls can do that.

5 hours ago, stephanos said:
  1. enable and un-enable at run time

All controls support that.

5 hours ago, stephanos said:
  1. allow accelerated chars to be visible at run time

For controls that are just wrappers for standard OS controls (like TButton), that behavior is controlled by the user's system settings, not by the framework.

5 hours ago, stephanos said:
  1. have an onclick Event

Most controls support that.  Even if the event is not exposes, it still exists in all controls.

5 hours ago, stephanos said:

Free Pascal Lazarus Project, version2.0.6

Why are you posting this in a Delphi forum and not in the Lazarus forums? https://forum.lazarus.freepascal.org

Share this post


Link to post

Thanks to all

 

I will register with Lazarus

 

Meanwhile, much information to absorb, and  I will try to do so.  I now have a way forward with TStaticText.

 

There are many books to choose from as well.  Does anyone have a recommendation for an Object newbie.  Not new to command line.  Have coded in C and Pascal, JavaScript

 

Thanks again

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×