April 19, 2024, 01:07:55 AM

News:

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


Offset text position in a static control

Started by Andy, November 07, 2014, 12:18:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Hi,

I have a static control, the text for it is simply a letter for example "A".
The static control size is 100 by 100.
The static has the colour white for the text and blue for the background.
The font size is 60.

Now, if I use
CONTROL w1,@STATIC,"A",10,10,100,100,@CTEDITLEFT, 1 - the text is on the very left hand side.

if I use:
CONTROL w1,@STATIC," A",10,10,100,100,@CTEDITLEFT, 1 - (with a space) - the "A" is too far over to the right.

Is there a way I can create a static control and specify the offset of the letter "A" - moving it to the right to a position that looks good to me, rather than just using @cteditleft/right/centre?

I don't want to draw a rectangle and use the print command.


DEF w1 as WINDOW

int blue   = rgb(0,148,196)
int white  = rgb(255,255,255)


OPENWINDOW w1,0,0,350,350,@MINBOX|@MAXBOX|@SIZE,0,"",&main

CONTROL w1,@STATIC,"A",10,10,100,100,@CTEDITLEFT, 1
SETCONTROLCOLOR w1, 1,white,blue
SETFONT w1,"Arial",60,700,0,1

WAITUNTIL w1 = 0
END


SUB main

    IF @CLASS = @IDCLOSEWINDOW
        CLOSEWINDOW w1

    ENDIF

RETURN
ENDSUB

Thanks,
Andy.




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

LarryMc

you'll have to subclass the control and draw it yourself in response to the
@IDPAINT message
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Let me know if you need me to to write the code for you
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library