[futurebasic] Re: [FB] Set control alpha?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2013 : Group Archive : Group : All Groups

From: Bernie <fblist.bw@...>
Date: Fri, 28 Jun 2013 08:57:22 +0100
rc wrote:

> 
>> how about dropping it on an overlay window and setting window alpha? Window could be attached to main window with grouping... maybe.
> 
> That could work. Thanks Bernie.
> 

Window groups are funny beasts. Here's a start.

'---------------
include "Tlbx HIView.incl"
include "Tlbx MacApplication.incl"

// MacWindows.h
toolbox SetWindowAlpha( WindowRef inWindow, double inAlpha )

#if ndef _DEFINEDINCARBON
#define WindowGroupAttributes as UInt32
begin enum
_kWindowGroupAttrSelectAsLayer    = (1 << 0)
_kWindowGroupAttrMoveTogether     = (1 << 1)
_kWindowGroupAttrLayerTogether    = (1 << 2)
_kWindowGroupAttrSharedActivation = (1 << 3)
_kWindowGroupAttrHideOnCollapse   = (1 << 4)
_kWindowGroupAttrFixedLevel       = (1 << 5)
end enum

#define WindowGroupRef as ptr // to OpaqueWindowGroupRef

toolbox fn CreateWindowGroup( WindowGroupAttributes inAttributes, WindowGroupRef outGroup ) = OSStatus
toolbox fn SetWindowGroupParent( WindowGroupRef inGroup, WindowGroupRef inNewGroup ) = OSStatus
toolbox fn SetWindowGroup( WindowRef inWindow, WindowGroupRef inNewGroup ) = OSStatus
toolbox fn SendWindowGroupBehind( WindowGroupRef inGroup, WindowGroupRef behindGroup ) = OSStatus

#endif

_mainWnd = 1
_cBtn = 1

_overlayWnd = 2
_cAlphaBtn = 1


local fn BuildWindows
'~'1
dim as WindowRef        mainWnd, overlayWnd
dim as WindowGroupRef   group
dim as Rect             r

// main window
SetRect( r, 118, 103, 598, 463 )
appearance window _mainWnd, "Main Window", @r, _kDocumentWindowClass, _kWindowCompositingAttribute
get window _mainWnd, @mainWnd

SetRect( r, 317, 153, 387, 173 )
appearance button _cBtn,,,,, "Button", @r, _kControlPushButtonProc

// overlay window
SetRect( r, 118, 103, 598, 463 )
appearance window _overlayWnd,, @r, _kOverlayWindowClass, _kWindowCompositingAttribute
get window _overlayWnd, @overlayWnd
SetWindowAlpha( overlayWnd, 0.3 )

SetRect( r, 70, 153, 180, 173 )
appearance button _cBtn,,,,, "Alpha Button", @r, _kControlPushButtonProc

// window group
fn CreateWindowGroup( _kWindowGroupAttrMoveTogether + _kWindowGroupAttrLayerTogether, @group )
fn SetWindowGroup( overlayWnd, group )
fn SetWindowGroup( mainWnd, group )
end fn


fn BuildWindows()

RunApplicationEventLoop()
'---------------