April 19, 2024, 05:33:34 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Useful tips - part 2

Started by Andy, September 16, 2018, 02:31:54 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

September 16, 2018, 02:31:54 AM Last Edit: September 16, 2018, 03:04:28 AM by Andy
I could have called the useful tips topic - things no one tells you - and here I will show an example.

Let's look at controls.

Controls are buttons, statics, edit boxes etc...

Now each control can be assigned styles, that is, changing it's appearance from it's default appearance to make it look how we want it to look.

Let's take this static control - a control to display text on screen:

CONTROL win,@STATIC,"Key please",20,65,110,25,@SS_RIGHT,STATIC_1


After the four co-ordinates 20,65,110,25 we have @SS_RIGHT.

@SS_RIGHT makes the text justified to the right of the control. In fact, @SS_RIGHT has a value assigned to it, and that value is a hexadecimal - 0X2.

So we could change the above line to this:

CONTROL win,@STATIC,"Key please",20,65,110,25,0X2,STATIC_1


Both do the same thing, but it's easier to understand using words, hence @SS_RIGHT.

And you can combine them, that is have multiple "styles".

CONTROL win,@STATIC,"Key please",20,65,110,25,@SS_RIGHT | 0X200,STATIC_1


The above line justifies the text to the right and makes sure the text is vertically centred in it's rectangle (I will come back to that later).

Now I'm coming to the point on this one.

How on earth did I find 0X200 - well I had to ask the question here, and that begs another question, how did they find out about 0X200?

If you search on Microsoft's developers website MSDN, you can find sections on "control styles".

Here is an example of when I searched for "SS_RIGHT MSDN"
https://msdn.microsoft.com/en-us/library/ms997560.aspx

And you think "that is that - I've got it" - wrong!

It tells you some of the styles (not all), notice there is no mention of vertically centring the static.
And even when it mentions SS_RIGHT - you need to know the hex value e.g. 0X2.

Fortunately we have ways round it.

A great deal of these styles are already built into IWB and are prefixed with the @ symbol.
i.e. SS_RIGHT in IWB is @SS_RIGHT.

But how do you find out other styles in IWB?

To begin with, IWB has a file called "windows.inc" (in your IWBDev \ Includes folder).

In there are many styles with their hex values in there:

CONST SS_RIGHT = 0x2


If you find the style you want in the windows.inc file, you can simply do this (as MS state on their MSDN site, without the @ symbol):

CONTROL win,@STATIC,"Key please",20,65,110,25,SS_RIGHT,STATIC_1


Also, you can have a look at iwbstd.incc (in your IWBDev \ Bin folder), it too has many styles in there.

If the style you want is in iwbstd.incc then you can use the @ symbol - as we did at the very start of this post.

It's simply knowing what style(s) you want, and then searching for it via MSDN, trying the style command, and / or searching for the hex value.

It's always worth searching this site too - there's a good chance some else will have asked the question.

When all else fails - ask!

Andy.
:)





Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

I feel that it would be remiss to not mention that one should look in the User's Guide under the Windows Programming/Controls section and then at the section covering the desired control first for any information about styles. It has has, in most cases, the most commonly used style flags.

NOTE: Some controls are still a WIP.

Also, those who own IWB+ can see all the available style flags when adding a control to a form.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library