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:
I have tried to set Window's font to Courier New which is monospaced (fixed-width) but for title is not working.
Window's Title to Center
Moderator: Rathinagiri
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Window's Title to Center
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Window's Title to Center
IMHO this is another unbreakable Windows rule : Window title must be left aligned !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: I have tried to set Window's font to Courier New which is monospaced (fixed-width) but for title is not working.
Regards
Viva INTERNATIONAL HMG
Re: Window's Title to Center
Hello Pablo,Pablo César wrote: How do I change the window's title alignment to center ?
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
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Window's Title to Center
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: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:
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 !
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
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Window's Title to Center
Apparently, unbreakable is for novices like me; not for gurus
Thanks Grigory
Regards
Thanks Grigory
Regards
Viva INTERNATIONAL HMG
- srvet_claudio
- Posts: 2193
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Window's Title to Center
GRANDE, amigo ! Buena idea ! Muchas gracias.srvet_claudio wrote:Hi Pablo.
Test with:Code: Select all
ON INIT RTrim (MoveTitle(cTitle)) ;
Best regards,
Claudio.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein