getting the properties of a button

General discussion forum about all things Team Developer 6.x
M.Hohnsbein
Germany
Posts: 12
Joined: 20 Mar 2017, 14:34
Location: Karlsruhe - Germany

getting the properties of a button

Post by M.Hohnsbein » 20 Mar 2017, 15:21

Hi there,

i'm quite new to this hole Team Developer/Sql Windows programing so please bear with me if i ask some stupid questions. :D

In TD 6.3 i'm trying to build an If statement based on the "visible" property of a pushbutton.
If the button is not visible then i want to delete the associated keyboard accelerator.
My colleague told me about the cdk and that there are functions in there which will do that.
This would be CDKGetStrProperty and CDKSetStrProperty, but i dont know anything about the parameters i need to use to implement them.

So I would really appreciate it if someone could give me the right informations or hint me to where i can find them. :)

Thanks in advance,

Max Hohnsbein

Charlie
Canada
Posts: 47
Joined: 07 Mar 2017, 18:52
Location: Fredericton, New Brunswick, Canada

Re: getting the properties of a button

Post by Charlie » 20 Mar 2017, 15:43

G'day,

Getting into CDK functions sounds like way too much trouble for what you need.

Look at SalIsWindowVisible() and see if that does the trick for you.
A little trick to help direct folk from old Gupta forum to this one: Link to post

Charlie
Canada
Posts: 47
Joined: 07 Mar 2017, 18:52
Location: Fredericton, New Brunswick, Canada

Re: getting the properties of a button

Post by Charlie » 20 Mar 2017, 15:56

I thought about it a little more ...

If you are going to have the same accelerator for two buttons, I'd suggest creating a third button and put the accelerator there.

The third button's only job is to catch the accelerator and control what happens. I.e. the third button decides which of the first two buttons to "click" by sending SAM_Click to whichever one of those two buttons applies to the situation.

EDIT: make the third button invisible all the time (it does not need to be visible to catch the accelerator key.)
A little trick to help direct folk from old Gupta forum to this one: Link to post

M.Hohnsbein
Germany
Posts: 12
Joined: 20 Mar 2017, 14:34
Location: Karlsruhe - Germany

Re: getting the properties of a button

Post by M.Hohnsbein » 20 Mar 2017, 16:15

Hey,

the SalIsWindowVisible function was the right call.
Thanks for that!

The main problem actually is that the button is invisible in a couple of windows and should just stop reacting to the accelerator key then.

I'm now trying to use the VisWinSetProp function to set the button to not have an accelerator, but i seem not to get the parameters right.

I'm using it like this right now

Call VisWinSetProp(pbOk, 'Keyboard Accelerator', FALSE)

Any advice on that?

Charlie
Canada
Posts: 47
Joined: 07 Mar 2017, 18:52
Location: Fredericton, New Brunswick, Canada

Re: getting the properties of a button

Post by Charlie » 20 Mar 2017, 16:34

Sorry, I don't have any suggestion there.

(If multiple windows have the same button with same accelerator, I'm thinking you might need an MDI window to host all of those other windows, and have the button exist only once on the MDI Window.)

Without knowing anything about your application's purpose and architecture, I can't help much.

Besides, I avoid situations that involve multiple buttons having the same accelerator. That's just way too high risk of wonky happenings for this kid.

Ugh. I've become the old guy who likes his comfortable shoes ...
A little trick to help direct folk from old Gupta forum to this one: Link to post

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 89
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: getting the properties of a button

Post by Jeff Luther » 20 Mar 2017, 19:02

Hi, Max: You wrote that you are trying
to use the VisWinSetProp function to set the button to not have an accelerator, but i seem not to get the parameters right.

I'm using it like this right now

Call VisWinSetProp(pbOk, 'Keyboard Accelerator', FALSE)

Any advice on that?
Since you wrote earlier that you are new to TD (and the Forum) I recommend that for issues like this you write a small test case apt in text format, showing the code you have and let us look at it.

In your case above, you are passing FALSE as the nValue (3rd) parameter. FALSE = 0 (zero) and my guess is that that is not correct. I just loaded in vt.apl, looked at the Constants/System section and found the section for " ***** Virtual keycodes" listed. My guess is that one of the VK_* constants, like VK_Cancel or VK_Clear, is the value to pass as the 3rd param. in the VisWinSetProp() call.

So... write a small test case for us to see, and/or try this yourself. And if you try it yourself and get it to work, reply to this thread with the solution you found.
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 278
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: getting the properties of a button

Post by Dave Rabelink » 20 Mar 2017, 21:18

Difficult to say what a sound implementation could be without knowing the architecture of your screens, as Charlie already indicated.

So, is the visible button on one window and the other invisible one on another?
Or do you need the same accelerator on the same active window, depending on the visibility change the accelerator from one button to the other?

If for instance, the active form should have all the active accelerators, you can detect if a form is activated or deactivated.
When de-activated, remove the accelerator from the button on that form. On activation you set the accelerator.

Or you could detect a button is made invisible and so remove it's accelerator. And for the button being made visible set it.

There are many ways to implement such a feature, but it is really depending on how the application is used and which forms can be open at once and where the buttons are situated.

Indeed, Jeff is right that a simple testcase having the architecture really helps here.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

M.Hohnsbein
Germany
Posts: 12
Joined: 20 Mar 2017, 14:34
Location: Karlsruhe - Germany

Re: getting the properties of a button

Post by M.Hohnsbein » 21 Mar 2017, 07:41

Hello Guys,

thanks for the replies.
I dont have multiple buttons with same accelerator as of yet. I just want to disable the accelerator when the button is not visible.
I'll build a small Testcase for you to try out what i'd like to do and come back to you later today or tomorrow.

M.Hohnsbein
Germany
Posts: 12
Joined: 20 Mar 2017, 14:34
Location: Karlsruhe - Germany

Re: getting the properties of a button

Post by M.Hohnsbein » 21 Mar 2017, 10:17

Ok, I built a small testcase in which you can see what I want to do.

There is a FormWindow which is opened after a buttonclick.
The opened Formwindow has two buttons.
One is visible, the other is not. Both have an accelerator set (Enter & Esc).
Right now both have an If-Statement in the SAM_Create which should disable or at least change the accelerator when the button is invisible.
I looked into the Virtual Keycodes and put VK_0 into one of them to try them out, but this does not seem to work.
You do not have the required permissions to view the files attached to this post.

M.Hohnsbein
Germany
Posts: 12
Joined: 20 Mar 2017, 14:34
Location: Karlsruhe - Germany

Re: getting the properties of a button

Post by M.Hohnsbein » 21 Mar 2017, 10:29

Dave Rabelink wrote:
20 Mar 2017, 21:18
Or you could detect a button is made invisible and so remove it's accelerator.
This is what i want to do. :)
In my case though, the button is invisible from the moment of its creation per setting in the attribute inspector.

I think I found quite an easy workaround.
In the SAM_CreateComplete of the window in which the button is, I disable the hole button via SalDisableWindow and thats it...

If NOT SalIsWindowVisible( pbOk )
Call SalDisableWindow( pbOk )

I still would be interested in how to change the properties using the VisWinSetProp function as there are a couple more buttons which are invisible in some windows.
And I think it would be more reasonable to find a solution for the buttons themself and not to have to put the line you see above for each of the buttons in each of the windows.

Edit(14:00 CET):
Ok, i looked further into the VisWinSetProp, VisWinGetProp, VisWinEnumProps, VisWinLoadAccelerator and VisWinFreeAccelerator functions.
To me it looks like they all refer to a custommade list of properties and not the ones i find in the Attribute Inspector.
I expected the VisWinEnumProps function to just hand me a list of the regular properties but, alas, it is empty as long as i didnt define any properties by myself.

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 89
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: getting the properties of a button

Post by Jeff Luther » 21 Mar 2017, 14:52

Max -- I think what you are really looking for in TD is an advanced set of functionality available to the programmer via an extension to the SAL language. It is part of the TD product and is called the CDK ("Component Developers Kit), a long-time add-on to the product that I think some coders have used over the years.
I don't recall a lot of old Forum (now read-only: https://support.guptatechnologies.com/supportforum/
talk about this and in fact just visited the site, searched for 'cdk' and didn't get a single hit! (I'm very surprised!!)

In any event, let me introduce you to this extension to the TD product. Briefly, the CDK's functionality can be used to examine and change -- at runtime -- attributes and properties of the internal outline of either the application itself that is running, or another outline that can be loaded in from disk.

I'll introduce you to the CDK in a couple of ways:
1) -- I've attached a TDv6.2 version of the CDK.apl book in case you don't have it.

2) open TD Help and search for: cdk (VERY brief overview, so look at the CDK.apl book for more details. Best to see 3) below to see how it operates.)

3) -- Among the TD samples on my web page: http://www.jeffluther.net/TD/#Code_Samples
Look for and d-click on CDK TUTORIAL, a tutorial I wrote long ago that show, by clicking each radio button, how to 'drill down' into the outline during runtime. (You will need to download and unzip the file since it has an ico for the outline that is used as part of the demo.) The form displays 2 multi-line fields:
LEFT shows in pseudo-code what that code does, and the
RIGHT side shows the results of running that radio button's code

TIP: If you want to see the outline's code that runs per radio button click, collapse the outline, click Debug/Fast Animate, and click a button.

4) (A little homework for myself...) Let me see if I can take your original request as you wrote it in your first msg:
If the button is not visible then i want to delete the associated keyboard accelerator.
and write a small test case using the CDK to show how to get the current Keyboard Accelerator value and how to change that at runtime. Not sure I've ever done this though I have used the CDK a lot to code. I will check to see if t he CDK can drill down to the Accelerator level (I think it can) and get/set that button's attribute.

I have it on my to-do list and will report back and attach a test showing how to do this or not.
You do not have the required permissions to view the files attached to this post.
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

M.Hohnsbein
Germany
Posts: 12
Joined: 20 Mar 2017, 14:34
Location: Karlsruhe - Germany

Re: getting the properties of a button

Post by M.Hohnsbein » 21 Mar 2017, 15:21

Hey Jeff,

I think you're right about the cdk. The basic TD functions cant do what I need...

Thanks alot for the .pdf and the hint to your tutorial.
I found your homepage and the tutorial there before, but without the .pdf I didnt thought I could get my head into it, so I didnt try.

I'll give it a try now and'll write here when I get any results or more problems. More likely the problems... ;)

Thanks again. :)

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 89
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: getting the properties of a button

Post by Jeff Luther » 21 Mar 2017, 16:07

I'll give it a try now
OK, but why not wait and I'll see if I can cook something up. Maybe save you a problem or 2, or even a little (as we say in English) 'hair pulling' :)
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 89
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: getting the properties of a button

Post by Jeff Luther » 21 Mar 2017, 17:35

Here you go, Max. Top of outline, saved in v5.2, has some notes on where the code is. Idea is to toggle (set/reset) the top pushbutton (PB) so Esc key does or does not work as an accelerator. Bottom PB toggles that. Turn on animate to see SAM_CreateComplete code in the form's msg. actions and see code in bottom PB.

Simple test case but it shows:
> how to save a CDK class instance for the control/object = top PB
> use that class instance to GetAttribute() and SetAttribute() to change keybd. accelerator's setting.

NOTE: This change is to the test case outline as loaded into and running from memory; it does not change the keybd. accelerator's setting in the outline file on disk. Let me know if you have any questions. This isn't meant to be an online tutorial on the CDK, just enough of a peek into it to answer your issue from your first msg.
You do not have the required permissions to view the files attached to this post.
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

M.Hohnsbein
Germany
Posts: 12
Joined: 20 Mar 2017, 14:34
Location: Karlsruhe - Germany

Re: getting the properties of a button

Post by M.Hohnsbein » 22 Mar 2017, 08:20

Hey Jeff, that is exactly what I was looking for.
I will shamelessly steal and rebuild it for my purposes :D

Thanks again.

Return to “General Discussion”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests