PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Thomas Bock on January 09, 2019, 10:17:38 AM

Title: draw button as empty rectangle
Post by: Thomas Bock on January 09, 2019, 10:17:38 AM
I want to create a button with my own program logic (not nomads). What is necessary to make it look like an empty rectangle?

btnCcl= 10501
button btnCcl, @(10, 10, 10, 1.5)="&Cancel",opt="F"
btnCcl'borderColor$ = "DARK GRAY"
btnCcl'hoverTextColor$ = "WHITE"
btnCcl'hoverBackColor$ = "DARK GRAY"

I'm missing the border.
Title: Re: draw button as empty rectangle
Post by: Jane Raymond on January 09, 2019, 11:20:43 AM
I expect you're looking for the 'border$ property:
https://manual.pvxplus.com/page/properties/border_.htm (https://manual.pvxplus.com/page/properties/border_.htm)
Title: Re: draw button as empty rectangle
Post by: Thomas Bock on January 10, 2019, 01:43:19 AM
Thank you. That's it.

btnCcl= 10501
button btnCcl, @(10, 10, 10, 1.5)="&Cancel"
btnCcl'border$ = "Solid"
btnCcl'borderColor$ = "DARK GRAY"
btnCcl'hoverTextColor$ = "WHITE"
btnCcl'hoverBackColor$ = "DARK GRAY"

I wonder, if there is a way to apply the current theme/VC to such a self drawn control.
Title: Re: draw button as empty rectangle
Post by: Jane Raymond on January 10, 2019, 11:37:22 AM
The application of theme/visual class attributes to controls is rather entrenched in the Nomads logic. You would have to set up a number of variables (as if you had read a record from the screen library file), and then perform the *winproc.dfs program to get the new settings, then you would have to apply all the settings. I expect it would just be easier to use controls on a Nomads panel.
Title: Re: draw button as empty rectangle
Post by: Mike King on January 10, 2019, 11:56:21 AM
If what you are looking for is to dynamically control the presence of the control, just put the button in your Nomads panel but make it hidden. When you need it simply make it visible. 

If you need to dynamically control its location, change its size/position prior making it visible since Nomads generally doesn't care about button positions.

Another option would be to again create a hidden button whose characteristics are based on a theme.  When you want to create your dynamic button simply copy the border and color properties from the hidden button to the button you are creating.  Something like:

ThemeSettings$=hidden_btn.ctl'border.borderColor.hoverTextColor.hoverBackColor.$
...
btnCd'border.borderColor.hoverTextColor.hoverBackColor.$-ThemeSettings$


This will just copy the attributes from the hidden button to the dynamic button.