[futurebasic] Re: [FB] Application Menu-Quit [FB4-Carbon-OSX 10.4.3]

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

From: Brian Stevens <brilor@...>
Date: Tue, 8 Nov 2005 18:06:02 -0700
Seems the program structure needs a lot of work. There are several un- 
dimensioned and re-dimensioned variables and the structure might trip  
you up too. Stu's examples are worth studying for any programmer and  
especially a new programmer.

Brian S.


On Nov 8, 2005, at 5:12 PM, Brian Heibert wrote:

> I changed my code a little bit but I am still having trouble with  
> Application-Quit
> RESOURCES "HBasic.res", "APPLHBas"
> OUTPUT FILE "HBasic"
> KILL RESOURCES "WDEF",8,"CDEF",8,"MDEF",8
> KILL RESOURCES "actb",30333,"DLGX",30333,"ictb",30333
> KILL RESOURCES "PICT",30333,"ALRT",30333,"DITL",30333
> KILL RESOURCES "DLGX",5, "DLGX",151
> KILL RESOURCES "FB3!", 0
> KILL RESOURCES "ICN#", 130
> KILL RESOURCES "icl4", 130
> KILL RESOURCES "icl8", 130
> KILL RESOURCES "ics#", 130
> KILL RESOURCES "ics4", 128, "ics4", 129, "ics4", 130
> KILL RESOURCES "ics8", 128, "ics8", 129, "ics8", 130
> KILL RESOURCES "FB3a", 0
> KILL RESOURCES "icm#", 128, "icm#", 129
> KILL RESOURCES "icm4", 128, "icm4", 129
> KILL RESOURCES "icm8", 128, "icm8", 129
> KILL RESOURCES "icns", 128
>
>
> dim controlnum%
> begin enum 1
> _Window1Wnd
> end enum
>
> begin enum 1
> _cXeditT
> end enum
> Apple menu "About HBasic..."
> dim as Str255              s
> dim as ControlFontStyleRec tfs
> dim as WindowAttributes    wa
> dim as Rect                r
> '~'<
> wa = _kWindowCloseBoxAttribute¬
>      _kWindowCollapseBoxAttribute
> dim deffont$,defsize%,defstyle%,defcolor
> deffont$ = "Helvetica"
> defsize% = 11
> defstyle% = 0
> defcolor = _zBlue
> dim m$
> LOCAL FN main
> m$ = Str#(128,2)
> End FN
> fn main
>
> local fn build
> fn main
> SetRect(r, 0, 0, 640, 480)// Optional FB auto-centre
> //SetRect(r, 0, 44, 640, 524)// w: 640 h: 480
> appearance window -_Window1Wnd,¬
>                   m$, @r,¬
>                   _kDocumentWindowClass, wa
> def SetWindowBackground(_kThemeActiveDialogBackgroundBrush, _zTrue)
> '~'<
> SetRect(r,0,0, 640, 480)
> s = ""
> text deffont$,defsize%,defstyle%
> color defcolor
> edit field _cXeditT, s, @r, _framed_noDrawFocus, _leftJust
>
> SetRect(r, 640,-116, 655, 481)
> //scroll button -_cXeditT,0,0,0,0, @r, _scrollVert
> Scroll Button -1,1,1,1,1,,_scrollVert
>
> dim alxstr$,t$
>
> end fn
>
> fn build
> Local Fn printOneSTR
> t$ =  Str#(128,1)
> End Fn
> dim action$
>
>
>
> local fn DoMenu
> dim as long menuID, itemID
>
> menuID = menu(_menuID)
> itemID = menu(_itemID)
>
> select case( menuID )
> case _applemenu
> select( itemID )
> case 1
> def fn aboutbox
> fn aboutbox
>
> end select
> case 1
> select( itemID )
> case 1
> window close #_Window1Wnd
> delay 300
> SetRect(r, 0, 0, 640, 480)// Optional FB auto-centre
> //SetRect(r, 0, 44, 640, 524)// w: 640 h: 480
> appearance window _Window1Wnd,¬
>                   m$, @r,¬
>                   _kDocumentWindowClass, wa
> def SetWindowBackground(_kThemeActiveDialogBackgroundBrush, _zTrue)
> '~'<
> SetRect(r,0,0, 640, 480)
> s = ""
> text deffont$,defsize%,defstyle%
> color defcolor
> edit field _cXeditT, s, @r, _framed_noDrawFocus, _leftJust
>
> SetRect(r, 640,-116, 655, 481)
> //scroll button -_cXeditT,0,0,0,0, @r, _scrollVert
> Scroll Button -1,1,1,1,1,,_scrollVert
>
> dim alxstr$,t$
>
> end select
> end select
> menu
>
> end fn
>
> LOCAL FN doDialog1
> dim as long evnt, id
>
> evnt = dialog(0)
> id = dialog(evnt)
>
> select case( evnt )
> case _wndClose
> window close #_Window1Wnd
> end select
> end fn
>
> PASCAL FN OnBreakExitProcedure
> fn printOneSTR
> alxstr$ = "Are you sure you want to exit HBasic and the program you  
> are writing?"
> call paramtext (alxstr$,"","","")
> controlNum% = FN STOPALERT(128,0)
> if controlNum% = 2 then end
> if controlNum% = 1 then action$ = "DoNothing"
> end fn = controlNum%
>
> appearance window _Window1Wnd
> ON BREAK FN OnBreakExitProcedure
> ON MENU FN DoMenu
> ON DIALOG FN doDialog1
> do
> handleevents
> until 0
>
> Local Fn printTwoStr
> t1$ =  Str#(128,1)
> t2$ =  Str#(128,5)
> t3$ = Str#(128,3)
> t4$ = Str#(128,4)
> t6$ = Str#(128,6)
> End Fn
> FN printTwoStr
>
> local fn aboutbox
> begin enum 15
> _abbx
> end enum
>
> begin enum 15
> _cStat
> _cPict
> _cStat1
> _OkBtnPush
> end enum
>
> #define FMFontFamily as SInt16
>
> dim as Str255              s
> dim as ControlFontStyleRec tfs
> dim as Rect                r
> dim as Boolean           @ bool
>
>
>
>
> '~'<
> SetRect(r, 0, 0, 360, 181)// Optional FB auto-centre
> //SetRect(r, 292, 148, 652, 329)// w: 360 h: 181
> appearance window -_abbx,¬
>                   "About...", @r,¬
>                   _kMovableAlertWindowClass
> def SetWindowBackground(_kThemeActiveDialogBackgroundBrush, _zTrue)
> '~'<
> SetRect(r, 152, 23, 222, 39)
> appearance button _cStat,¬
>                   _activeBtn,,,,, @r,¬
>                   _kControlStaticTextProc
> tfs.flags =  
> _kControlUseFontMask_kControlUseSizeMask_kControlUseFaceMask_kControlU 
> seJustMask
>
> tfs.size = 13
> tfs.style = 0
> tfs.just = _teJustLeft
> def SetButtonFontStyle(_cStat, tfs)
>
> s = "HBasic 1.0"
> def SetButtonTextString(_cStat, s)
>
> SetRect(r, 26, 23, 76, 73)
> appearance button _cPict,¬
>                   _activeBtn, 1000,,,, @r,¬
>                   _kControlPictureProc
>
> SetRect(r, 102, 57, 327, 73)
> appearance button _cStat1,¬
>                   _activeBtn,,,,, @r,¬
>                   _kControlStaticTextProc
> def SetButtonFontStyle(_cStat1, tfs)
> s = "© Copyright 2005 by Brian Heibert"
> def SetButtonTextString(_cStat1, s)
>
> SetRect(r, 151, 124, 221, 144)
> appearance button _OkBtnPush,¬
>                   _activeBtn,,,,¬
>                   "OK", @r,¬
>                   _kControlPushButtonProc
> bool = _zTrue
> def SetButtonData(_OkBtnPush, _kControlEntireControl,  
> _kControlPushButtonDefaultTag, SizeOf(Boolean), bool)
>
> appearance window _abbx
> def fn dodialogx
> on dialog fn dodialogx
> end fn
>
> local fn dodialogx
> dim as long evnt, id
>
> evnt = dialog(0)
> id = dialog(evnt)
>
> select case( evnt )
> case _btnClick
> select( id )
> case _OkBtnPush
> window close #_abbx
> end select
> end select
>
> end fn
>
>
>
>
>
>
>
> On Nov 8, 2005, at 7:04 PM, Brian Heibert wrote:
>
>
>> This is my menu code:
>> how can I get it so when the application menu is selected in OSX  
>> and quit is selected
>> my application quits?
>>
>> Brian
>>
>> local fn DoMenu
>> dim as long menuID, itemID
>>
>> menuID = menu(_menuID)
>> itemID = menu(_itemID)
>>
>> select case( menuID )
>> case _applemenu
>> select( itemID )
>> case 1
>> def fn aboutbox
>> fn aboutbox
>>
>> end select
>> case 1
>> select( itemID )
>> case 1
>> window close #_Window1Wnd
>> delay 300
>> SetRect(r, 0, 0, 640, 480)// Optional FB auto-centre
>> //SetRect(r, 0, 44, 640, 524)// w: 640 h: 480
>> appearance window _Window1Wnd,¬
>>                   m$, @r,¬
>>                   _kDocumentWindowClass, wa
>> def SetWindowBackground(_kThemeActiveDialogBackgroundBrush, _zTrue)
>> '~'<
>> SetRect(r,0,0, 640, 480)
>> s = ""
>> text deffont$,defsize%,defstyle%
>> color defcolor
>> edit field _cXeditT, s, @r, _framed_noDrawFocus, _leftJust
>>
>> SetRect(r, 640,-116, 655, 481)
>> //scroll button -_cXeditT,0,0,0,0, @r, _scrollVert
>> Scroll Button -1,1,1,1,1,,_scrollVert
>>
>> dim alxstr$,t$
>>
>> end select
>> end select
>> menu
>>
>> end fn
>>
>> --
>>
>>
>
> --
>
>
>