stephanos 0 Posted April 6, 2020 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: allow use of ActiveControl set the tab order offer a tag for use as an integer variable at run time allow me to control the colour of the caption and the font size (not at run time) allow to to position the caption centre vertically and horizontally (not at run time) enable and un-enable at run time allow accelerated chars to be visible at run time 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
Anders Melander 1815 Posted April 6, 2020 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: Read the help. Learn about classes and inheritance. Specifically the VCL class hierarchy is important. Examine the VCL source code. See what others do. See what works and what doesn't and learn from your experience.. Good luck. 1 Share this post Link to post
dummzeuch 1517 Posted April 6, 2020 (edited) 2 hours ago, Anders Melander said: You may find that things become easier (or even clear) for you if you Learn about classes and inheritance. Specifically the VCL class hierarchy is important. 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 April 6, 2020 by dummzeuch Share this post Link to post
Remy Lebeau 1436 Posted April 6, 2020 2 hours ago, dummzeuch said: Which doesn't help, since he is using Lazarus, not Delphi Then why is this being posted in a Delphi forum and not in the Lazarus forums? https://forum.lazarus.freepascal.org Share this post Link to post
Remy Lebeau 1436 Posted April 6, 2020 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: allow use of ActiveControl set the tab order All windowed controls support that. 5 hours ago, stephanos said: 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: 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: 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: enable and un-enable at run time All controls support that. 5 hours ago, stephanos said: 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: 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
stephanos 0 Posted April 6, 2020 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