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.
Use BS_LEFT
where
CONST BS_LEFT = 0x100
Should work.
Larry
CONTROL d1,"B,,15+(a*90),184+(b*16),85,15,BS_LEFT,c"
still does not work... keeps centralizing the text.
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
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!
hi all, it's been a long time :)
even simpler, use @cteditcenter, @cteditright or @cteditleft ;)
(rememberings from loooooooong ago)
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
oooops
my mistake, i 've read static control instead of static button control. :-\