April 25, 2024, 10:21:52 PM

News:

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


Text alignment in a static button control

Started by JoaoAfonso, March 23, 2008, 03:25:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JoaoAfonso

Good evening.

I am asking for help in this forum, but I believe it could be either here, Emergency or Aurora forum, but as this is one of mine CB programs, I decided to put it here. I have in my program some buttons that need to have a standard width, which is often few for all the text I want to put there. What happens by default, though, is text centralized in contol, and I wish to align it to the left, so I can read the start of the phrase I put there. How to do it? I tried this, with no success, and I am unable to find a workable solution:

CONTROL d1,"B,,15+(a*90),184+(b*16),85,15,@CTEDITLEFT,c"

Thank you in advance.
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

LarryMc

Use BS_LEFT
where
CONST BS_LEFT = 0x100

Should work.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

JoaoAfonso

CONTROL d1,"B,,15+(a*90),184+(b*16),85,15,BS_LEFT,c"
still does not work... keeps centralizing the text.
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

LarryMc

March 24, 2008, 07:35:39 AM #3 Last Edit: March 24, 2008, 07:47:49 AM by Larry McCaughn
Sorry about that.
I based  the info on an external "standard" resource editor.

Looking at the source code for EBasic Paul creates a buttons text by his own code.

The EBasic solution would be to create the "button" first as a radiobutton.
Then using the MODIFYSTYLE command to delete 0x309 from the style and add 0x100 to the style.
That results in a button with left aligned text like you want.


Problem is CBasic doesn't have that command.

I couldn't get these to work correctly in CBasic or I would have been able to duplicate the MODIFYSTYLE command.
DECLARE "user32",SetWindowLongA(hwnd:INT, nIndex:INT, value:INT),INT
DECLARE "user32",GetWindowLongA(hwnd:INT, nIndex:INT),INT
DECLARE "user32",GetDlgItem(hwnd:INT,id:INT),INT

but I'm not very familiar with CBasic's syntax; I've never used it.

EDIT:
the only other things I could think of trying would be to:

1) prepend a number of spaces to the front of the text string based upon the length of the string(- a few characters) before sending it to the button.
When the text is centered the beginning of the desired text should show.

2) create a temp variable to hold the left x-number of characters of the string and just send that to the button

* 2nd solution is simpler and doesn't have the possibility of creating a string of over 255 characters like the 1st does.

Larry

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

JoaoAfonso

Second choice was easier to implement, and as that text in buttons is just for give a small information, it fits well my purposes. Thank you for the tips!
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

philippe.tx

hi all, it's been a long time :)

even simpler, use @cteditcenter, @cteditright or @cteditleft  ;)
(rememberings from loooooooong ago)

JoaoAfonso

That was the problem, my friend. In buttons, those flags does not work as I wanted, so figured out the second solution Larry told was the best one, preventing re-writing lines of code.
Thanks anyway
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

philippe.tx

oooops
my mistake, i 've read static control instead of static button control. :-\