Page 1 of 1
Window's Title to Center
Posted: Thu Sep 20, 2012 12:56 pm
by Pablo César
How do I make the Window's Title align in “Center” not in “Left”.
How do I change the window's title alignment to center ? Like this:
- a.jpg (13.45 KiB) Viewed 4255 times
I have tried to set Window's font to
Courier New which is monospaced (fixed-width) but for title is not working.
Re: Window's Title to Center
Posted: Thu Sep 20, 2012 1:09 pm
by esgici
Pablo César wrote:How do I make the Window's Title align in “Center” not in “Left”.
How do I change the window's title alignment to center ? Like this:
a.jpg
I have tried to set Window's font to
Courier New which is monospaced (fixed-width) but for title is not working.
IMHO this is another unbreakable Windows rule :
Window title must be left aligned !
Regards
Re: Window's Title to Center
Posted: Thu Sep 20, 2012 2:02 pm
by gfilatov
Pablo César wrote:
How do I change the window's title alignment to center ?
Hello Pablo,
Please be so kind to try the following simple sample:
Code: Select all
/*
* MiniGUI Window Demo
* (c) 2012 Grigory Filatov
*/
#include "hmg.ch"
Procedure Main
SET MULTIPLE OFF
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 ;
HEIGHT 480 ;
TITLE 'Main Window' ;
MAIN ;
ON INIT MoveTitle() ;
ON MAXIMIZE MoveTitle() ;
ON SIZE MoveTitle() ;
BACKCOLOR GRAY
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return
Procedure MoveTitle()
ThisWindow.Title := xPadC( 'Main Window', ThisWindow.Width * 1.2 - 40 )
Return
function xPadC( cText, nPixels, cChar )
local cRet := If( Valtype( cText ) == "C", AllTrim( cText ), "" )
local nLen := Len( cText )
local nPixLen
local nPad
DEFAULT cChar := Chr(32)
nPixLen := GetTextWidth( , cText )
nPad := GetTextWidth( , cChar )
if nPixels > nPixLen
cRet := PadC( cRet, Int( nLen + ( nPixels - nPixLen ) / nPad ), cChar )
endif
return cRet
Hope that helps
Window's Title to Center
Posted: Thu Sep 20, 2012 2:58 pm
by Pablo César
Wow Master ! Thank you for your indications, Mr. Grigory. It is almost quite 100% OK, but in order to avoid "..." as part of title shown, I have make some changings. Probably it is for my Windows is not main Window. Ssorry I have mentioned as main but in real is MODAL and with NOSIZE and NOSYSMENU. So I subtract -70 (wich is not exact value) but it approximally center aligned.
Could you please explain why in you code is subtracted 40 ?
I have adapted my STRU code like this:
Code: Select all
..//..
DEFINE WINDOW MyAlert AT 0, 0 ;
WIDTH 425 HEIGHT 155 ;
TITLE cTitle MODAL ;
ON INIT MoveTitle(cTitle) ;
NOSIZE NOSYSMENU
...//..
Function MoveTitle(cTitle)
ThisWindow.Title := xPadC( cTitle, (ThisWindow.Width - 70) * 1.2 ) // please note here
Return Nil
If I do not change your code
,ThisWindow.Width * 1.2 - 40 ) for
,(ThisWindow.Width - 70) * 1.2 ) then my window is going to show these caracters "
...", please see picture below:
- Screen40.PNG (9.7 KiB) Viewed 4224 times
I feel I am so near to reach a final solution regarding this value subtracted and I wish to avoid these points... so It will be very much appreciated your explanation about this subtracted value and why to multiply with 1.2 ?. Any way thanks again Mr. Grigory !
Re: Window's Title to Center
Posted: Thu Sep 20, 2012 7:48 pm
by esgici
Apparently,
unbreakable is for novices like me; not for gurus
Thanks Grigory
Regards
Re: Window's Title to Center
Posted: Fri Sep 21, 2012 1:30 pm
by srvet_claudio
Hi Pablo.
Test with:
Code: Select all
ON INIT RTrim (MoveTitle(cTitle)) ;
Best regards,
Claudio.
Window's Title to Center
Posted: Fri Sep 21, 2012 5:36 pm
by Pablo César
srvet_claudio wrote:Hi Pablo.
Test with:
Code: Select all
ON INIT RTrim (MoveTitle(cTitle)) ;
Best regards,
Claudio.
GRANDE, amigo ! Buena idea ! Muchas gracias.