text on tab

text on tab

Postby Eoeo » Tue Aug 14, 2012 7:02 pm

I'd Like insert a text on the left of tabs how I can make to write it on the left
I try as you can see in this picture but the text is wrote near to second tab


Image






I made
the tab
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-80, 12 PIXEL OF oApp():oDlg ;
ITEMS 'Codice','Descrizione'
ACTION ....

activate dialog on init Tab_scritta( oTab,text,nSplit)


...
STATIC FUNCTION Tab_scritta( oTab,text,nSplit)
lOCAL oPSay2
@ 0, 20 SAY oPSay2 PROMPT text OF oApp():oTab COLOR CLR_RED TRANSPARENT

return nil


Any solution ?
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: text on tab

Postby ukoenig » Tue Aug 14, 2012 9:24 pm

Silvio,

To get the left text-startposition,
maybe You can calculate the needed total Tab-width like :

Image

Code: Select all  Expand view  RUN

nSpace := 0
FOR n = 1 to Len( oTabs:aPrompts )
       nSpace := nSpace + GetTextWidth( 0, StrTran( oTabs:aPrompts[ n ], "&", "" ), ;
       oTabs:oBold:hFont ) + ;
       IF( Empty( oTabs:ahBitmaps[ n ] ), 0, 18 ) + 20
NEXT  
   
Msgalert( nSpace )
 


@ 0, nSpace SAY oPSay2 PROMPT text OF oApp():oTab COLOR CLR_RED TRANSPARENT

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: text on tab

Postby Eoeo » Wed Aug 15, 2012 7:40 am

good run ok!!!

but only until two tabs

If I have Many tabs it not run



pls see it


Image
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: text on tab

Postby Eoeo » Wed Aug 15, 2012 7:59 am

I resolve with :

IF Len( oTab:aPrompts ) > 5
numtab:= 3
ELSE
numtab:= Len( oTab:aPrompts )
ENDIF

FOR n = 1 to numtab

NOW run ok with ( until ) 10 Tabs I not Know why ...eh eh eh :)
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: text on tab

Postby ukoenig » Wed Aug 15, 2012 11:32 am

Silvio,

I would adjust the text from Dialog RIGHT-position.
That looks much better and the Position is always the same distance from Right.
But if You like, getting closer to the Tabs, just increase the defined Space from right.
Some calculations needed, using any Font and Text.
Without calculation, it will be very hard, to adjust the Text to the needed Position.

Image

@ 0, any Value SAY oPSay2 PROMPT text OF oApp():oTab COLOR CLR_RED TRANSPARENT

Usage :

Text := "Test String from right"
// any Value of 0, 100. The needed Size 25, 10 will be calculated with the Function.
@ 0, 100 SAY oPSay2 VAR Text SIZE 25,10 OF oApp():oTab CLR_RED PIXEL TRANSPARENT FONT oTxtFont
...
...
// 100 = defined Text-top
// 5 = the wanted Distance between Text-end and Dialog-right

ACTIVATE DIALOG oDlg CENTERED ;
ON INIT TEXT_RIGHT( oPSay2, oTxtFont, 100, oDlg:nRight - 5, cText )

RETURN NIL


Code: Select all  Expand view  RUN

FUNCTION TEXT_RIGHT( oSay, oFont, nTop, nLeft, cText )
LOCAL hDC, nTxtWidth, nTxtHeight

hDC := oSay:GetDC()
nTxtHeight := INT(  Abs( oFont:nHeight ) ) + 10
IF oFont:lItalic = .F. // Italic
    nTxtWidth :=  INT( GettextWidth( hDC, ALLTRIM(cText), oFont:hFont, ) ) + 6
ELSE
    nTxtWidth :=  INT( GettextWidth( hDC, ALLTRIM(cText), oFont:hFont, ) ) + 10
ENDIF
oSay:ReleaseDC()
oSay:nWidth := nTxtWidth
oSay:Move( nTop, nLeft - nTxtWidth, nTxtWidth, nTxtHeight + ( nTxtHeight / 4 ), .T. ) // adjusted Height

RETURN ( NIL )
 


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 46 guests