[futurebasic] Re: [FB] Operation of the about window

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2006 : Group Archive : Group : All Groups

From: "Y.Hasegawa" <hase44@...>
Date: Wed, 01 Feb 2006 23:44:05 +0900
> Yoshiyuki wrote:
> 
>> How is the about window prevented from going behind the main window?
>> In the sample code below.
> 
Bernie wrote:
> 
> Stuffing the about window into a window group seems to work. However,
> I'm not sure if it's a good idea to create a new group every time the
> about window is built. I wonder if a better way would be to build the
> about window invisibly at app startup and show/hide as required?
> 

I added the improvement to the code a little.
If the gray is displayed to the Main Window, it is better.

Yoshiyuki

'----------
#define WindowGroupAttributes as UInt32
#define WindowGroupRef as pointer // to OpaqueWindowGroupRef
toolbox fn CreateWindowGroup(WindowGroupAttributes inAttributes, ¬
                              WindowGroupRef outGroup) = OSStatus
toolbox fn SetWindowGroup(WindowRef inWindow, ¬
                           WindowGroupRef inNewGroup) = OSStatus

local fn BuildMenus
menu 127, 1, _enable, "About..."
menu
end fn

local fn MainWnd
dim as Rect  r

def NewWindowPositionMethod(_kWindowCenterOnMainScreen)
SetRect(r, 0, 0, 400, 400)
appearance window 1, "Main Window", @r, _kDocumentWindowClass
def NewWindowPositionMethod(0)
def SetWindowBackground(_kThemeActiveDialogBackgroundBrush, _zTrue)

appearance window 1
end fn

local fn AboutWnd
dim as Rect              r
dim as WindowGroupRef  @ groupRef
dim as OSStatus          ignore

def NewWindowPositionMethod(_kWindowCenterOnMainScreen)
SetRect(r, 0, 0, 300, 300)
appearance window 10,"About",@r,_kDocumentWindowClass,¬
                                 _kWindowCloseBoxAttribute
def NewWindowPositionMethod(0)
def SetWindowBackground(_kThemeActiveDialogBackgroundBrush, _zTrue)

text _geneva, 20, 0, _srcOr
print %(50,130) "This is About Window"

ignore = fn CreateWindowGroup( 0, @groupRef )
ignore = fn SetWindowGroup( window( _wndRef ), groupRef )
end fn

local fn DoMenu
select menu(_menuID)
case 254
select menu(_itemID)
case 1
fn AboutWnd
end select
end select
menu
end fn

local fn DoDialog
dim as WindowRef @ AboutWndRef
dim as long evnt, id
evnt = dialog(0)
id   = dialog(evnt)
select window(_outputWnd)
case 1
select evnt
case _preview
select id
case 9
get window 10, AboutWndRef
HiliteWindow( AboutWndRef,_true )
end select
end select
case 10
select evnt
case _wndClose
window close 10
end select
end select
end fn

fn BuildMenus
fn MainWnd

on menu fn DoMenu
on dialog fn DoDialog

do
HandleEvents
until gFBQuit
'----------