[futurebasic] Re: [FB] printing static text in an appearance button

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2005 : Group Archive : Group : All Groups

From: Stu Cram <stu@...>
Date: Thu, 8 Sep 2005 13:20:32 -0600
Hello Keiji

I've included a demo program below that may to do what you are asking. 
It has a function that will get the text from an appearance 
button/control and print it on the printer in the same position as as 
the control item was. I chose this approach so one could call the 
function several times to print many such items, but not necessarily
every button on the screen.

The demo makes two buttons in a sample window and right away, sends 
their contents to the printer. Normally that would be done of course in 
response to PRINT being select from the File menu or some other 
interactive method. It also draws a grey grid with lines 20pts apart to 
help check that the data is being printed in the proper position for 
each button. Normally the grid would not be there.

Hope this helps.
-Stu

On Sep 8, 2005, at 1:39 AM, kappalab wrote:
> Hi,   I am trying to print a static text in an apperance button such 
> as,
>
>    appearance button 10,_activeBtn,,,,"", @r,_kControlStaticTextProc
>    def SetButtonTextString( 10, "This is Appearance Button Static 
> Text" )
>
> with "route _toPrinter". However, this seems not working for me.
> Does anyone know how to print a static text like this?
>
> Thank you very much in advance.
> -keiji-
======================================================================

'
'  Demo program - Sept. 8, 2005   for FutureBasic Digest
'    re question:   How can I print text from a static text appearance 
button?
'
'~'1
LOCAL MODE
   dim as OSStatus  ignore
   DIM AS STR255    theBtnText
   DIM AS RECT      theBtnRect

LOCAL FN PrintAppearanceButton( theBtnNumber )
'  Gets text from an appearance button and sends it to the print
'     using same font and position
'  Note:  Must do DEF LPRINT before calling this and Close LPRINT 
afterward.
'           Several buttons can all be printed on same page by calling 
this function for each button.

ignore = fn UseThemeFont( _kThemeSystemFont, _smSystemScript )  ' 
Switch to system's font for buttons
theBtnText = FN ButtonTextString$( theBtnNumber )'  Get text from the 
button
DEF BtnRect( theBtnRect, theBtnNumber )'  Get rect surrounding button

ROUTE _toPrinter
PRINT %( theBtnRect.left, theBtnRect.bottom ) theBtnText;'  And now 
print it
ROUTE _toScreen

END FN
'~'1

LOCAL FN PrintSomeButtons
DEF LPRINT  ' Show st'd Print dialog
LONG IF ( prCancel == 0 )
ROUTE _toPrinter
' this draws a grey grid for reference - just for test purposes
LONG COLOR 56000,56000,56000
DIM x
FOR x = 0 TO 600 STEP 20
   PLOT x,0 TO x,600
   PLOT 0,x TO 600,x
NEXT x
COLOR _zBlack
ROUTE _toScreen
' call the function once for each static text button desired
FN PrintAppearanceButton( 10 )
FN PrintAppearanceButton( 13 )
CLOSE LPRINT
END IF
END FN
'~'1

'  Demo for printing text from static appearance buttons

WINDOW 1, "Button Print Demo", (0,0)-(600,480), 5
DIM AS RECT r1, r2

SetRect (r1, 60,50,300,70)
APPEARANCE BUTTON 10, _activeBtn,,,, "", @r1, _kControlStaticTextProc
DEF SetButtonTextString( 10, "Hello Mary-Lou" )

SetRect (r2, 100,90,400,110)
APPEARANCE BUTTON 13, _activeBtn,,,, "",  @r2, _kControlStaticTextProc
DEF SetButtonTextString( 13, "Good-bye Heart" )

FN PrintSomeButtons

DO
   HandleEvents
UNTIL 0

'===================================================================