[futurebasic] Re: [FB] Changing a window's id value

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

From: Robert Purves <robert.purves@...>
Date: Tue, 23 Sep 2003 21:16:17 +1200
On Tuesday, September 23, 2003, Bernie Wylde wrote:
>
> Now, all I need is an active button that behaves like a gray button 
> (no hilite, no btn event)     ;-)

Let DrawControlInCurrentPort be your friend.


'----------------
'~'A
'                       Runtime : Rntm Appearance.Incl
'                           CPU : Carbon
'~'B

_myAppSignature = _"RDPu"

local mode
local fn DoDialog
'~'1
dim as long          evnt, ref
dim as WindowRef   @ wRef
dim as ControlRef  @ weirdButton
dim as OSStatus      err

evnt = dialog(0) : ref = dialog(evnt)
select evnt
case _btnClick : beep
case _wndRefresh
select ref
case 1
// retrieve the ControlRef weirdButton from the window...
get window ref, wRef
err = fn GetWindowProperty( wRef, _myAppSignature, _"WeRD", ¬
          sizeof( ControlRef ), #_nil, @weirdButton )
// ...and draw it
DrawControlInCurrentPort( weirdButton )
end select
end select
end fn



// Main program
dim as Rect          r
dim as ControlRef  @ weirdButton
dim as OSStatus      err

on dialog fn DoDialog

// make button in invisible window
window -999
SetRect( r, 10, 60, 150, 80 )
weirdButton = fn NewControl( window( _wndRef ), @r, "Unresponsive",¬
      _true, 1, 0, 1, _kControlPushButtonProc, 0 )

// our real window
appearance window 1,,, _kDocumentWindowClass,¬
    _kWindowStandardDocumentAttributes
// store the ControlRef weirdButton away for handy access
err = fn SetWindowProperty( window( _wndRef ), _myAppSignature,¬
          _"WeRD", sizeof( ControlRef ), @weirdButton )

// make an ordinary button for comparison
SetRect( r, 10, 10, 140, 30 )
appearance button 1,,,,, "Ordinary", @r, _kControlPushButtonProc


do
HandleEvents
until 0
'----------------

Robert P.