Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:04 11 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : GUI Caption problem

Author Message
Malibu
Senior Member

Joined: 07/07/2018
Location: Australia
Posts: 260
Posted: 12:58am 14 Jul 2018
Copy link to clipboard 
Print this post

Hi all,

I've got a GUI Caption problem that is baffling me... I got this one when I was trying to do long strings and display it in the Caption box.
Because it annoys me to have horizontal scroll bars in programing, I build the string as needed (as you can see in the code) just to keep it where I want it.

So, my problem is that when I specify the alignment (LM, CB, or whatever) the Vertical align always seems to defaulting to middle...
If I set the coordinates for text display at 10,10 - the long string runs over the top edge of the LCD.

Here's my code (reduced to a bare minimum to find what's going on)

option explicit
dim HelpStr as string
dim Align as string

Align = "LB" '<<----- Change here for new alignment. Options are - L C R + T M B
cls
line 0,mm.vres/2,mm.hres,mm.vres/2,1,RGB(RED) '<<---- Shows where the LCD center is
SetMsg '<<------- Build the message
print len(HelpStr) '<<----- Just check and show the length
text 10,mm.vres/2,"Some Text",Align,2,1,RGB(White),rgb(Black) '<<---- Just to check the Align string
pause 1500
ShowHelp '<<---- Show the GUI CAPTION area with the initial message
pause 1500
ShowMsg '<<---- Show the new message in the GUI CAPTION area
do:loop

'------
sub SetMsg 'Build the string so it doesn't run off the MM Edit screen
HelpStr = "This is a long string to~" '<<---- Comment out some of the following lines to see the effect
HelpStr = HelpStr + "test the possibilities ~"
HelpStr = HelpStr + "of a help screen that ~"
HelpStr = HelpStr + "will flash up after a ~"
HelpStr = HelpStr + "user touches a HELP ~"
HelpStr = HelpStr + "button or to show any ~"
HelpStr = HelpStr + "extra details that may~"
HelpStr = HelpStr + "be needed in a program~"
end sub

'------
sub ShowMsg
ctrlval(#3) = HelpStr$
end sub

'------
sub ShowHelp
Font 2
gui caption #3,"Gui~Caption~for~testing~alignment",10,mm.vres/2,Align,RGB(White),rgb(Black)
end sub


Any ideas what I've done wrong on that one?
It's most noticeable with REALLY long strings...

Thanks, John

John
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1116
Posted: 04:43am 14 Jul 2018
Copy link to clipboard 
Print this post

John,

It appears that CAPTION assumes just a single line of text as Top,Middle or Bottom just positions the text at T,M or B around the y start axis.

You can see this most obviously if you change the background to a grey colour. You will see that the text line with HELP is now sitting above(T), centred(M) or below (B) the red line.

I realise this doesn't fix your problem but at least it is not a programming error of yours, rather a design limitation. Perhaps the manual could indicate that CAPTION is for a single line of text only.

The only way around it may be to have some code to insert the newline tilde either before or after your text to manipulate it into the correct position.

panky


... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
Malibu
Senior Member

Joined: 07/07/2018
Location: Australia
Posts: 260
Posted: 05:48am 14 Jul 2018
Copy link to clipboard 
Print this post

Thanks Panky,
I un-commented 1 line at a time right through to the full string and saw exactly what you described.

As far as my problem goes, it's easy enough to to have a 'fixed' string length of 8 lines long. As long as I know where it will be placed, I can punch in the correct X/Y coordinates to get the right position to allow for the 'up' and 'down' spread (which is what I did...)

All good in the end and thanks

John
John
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025