[futurebasic] Weird Problem

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2004 : Group Archive : Group : All Groups

From: Stu Cram <stu.cram@...>
Date: Tue, 26 Oct 2004 02:01:07 -0600
Brian - I tried your routine. It created a _dialogPlain window which 
has just a simple outline with a hint of a shadow on right and bottom 
edges - no title bar and no scroll bars. Sounds like that's what you 
saw but mistook it for being stuff inside the previously made editor 
window.

Now that the Prefs window has been made, another routine (part of FN 
doDialog) has to process what happens in that window. FN doDialog has 
to check which window and which buttons or edit fields are being used 
and eventually save the preferences in a disk file somehow. Have you 
planned that yet?

You do not need to call FN doDialog right after making this window. 
Your HandleEvents loop should call it when you click on a button or 
type in the edit fields and process each event as needed.

The code you posted looks like it was made by Staz's Program 
Generator. Do you understand how it works and how to refer to the 
items in the window?  Thefollowing 3 lines can be removed.

Here's your function, slightly revised, along with extra code to test 
it out separately from your main program. It's always good to test 
new routines by themselves first. And, like Brian Stevens said, it 
always better to study & understand other people's code well before 
using them in your projects.
AND DON'T FORGET TO READ THE MANUALS CAREFULLY.

'.---->>   Demo preferences window for Brian H.   (Oct 26, '04)
'
'  Displays and closes a preferences window.
'  Does not save any data in a file nor get any data.
'
RESOURCES "TBASIC.rsrc"
'--------------------
LOCAL FN prefs
'---------------------------------------------------------------
:'CONSTANTS
'---------------------------------------------------------------
_tPrefs           = 779'Preferences window
_picFld1class4    = 1
_btn2WClass4      = 2
_btn2WClass5      = 3
_btn2WClass6      = 4
_btn2WClass7      = 5
_btn2WClass8      = 6
_btn2WClass9      = 7
_picFld9class4    = 9
_picFld8class4    = 8
_nameofcompiledapp= 10
_btn11WClass4     = 11
_picFld12class4   = 12
_SNO              = 13
WINDOW _tPrefs,"Preferences",( 100, 100)-( 450, 500), _dialogPlain
PICTURE FIELD _picFld1class4,%128,( 12,   4)-( 330,  32), 7,_cropPict
BUTTON _btn2WClass4,_enable,"Times New Roman",(  33,  96)-( 192, 112), 3
BUTTON _btn2WClass5,_enable,"Times",(  33, 112)-( 192, 128), 3
BUTTON _btn2WClass6,_enable,"New York",(  33, 128)-( 192, 144), 3
BUTTON _btn2WClass7,_enable,"Geneva",(  33, 144)-( 176, 160), 3
BUTTON _btn2WClass8,_enable,"Arial",(  33, 160)-( 192, 176), 3
BUTTON _btn2WClass9,_enable,"Helvetica",(  33, 176)-( 176, 192), 3
PICTURE FIELD _picFld9class4,%4004,(  36,  68)-( 217,  80), 7,_cropPict
PICTURE FIELD _picFld8class4,%4003,(  36, 212)-( 210, 224), 7,_cropPict
EDIT FIELD _nameofcompiledapp,%4002,(  32, 224)-( 208, 240), 1,_leftJust
BUTTON _btn11WClass4,_enable,"Save",( 144, 320)-( 224, 340), 4
PICTURE FIELD _picFld12class4,%4005,(  36, 260)-(  74, 272), 7,_cropPict
EDIT FIELD _SNO,%4003,(  96, 256)-( 288, 272), 1,_leftJust
END FN
'--------------------
Local fn setRestButton( btnNum )
btnStatus = button( btnNum )
Select btnStatus
Case _markedBtn : Button btnNum, _activeBtn
Case _activeBtn : Button btnNum, _markedBtn
END select
END FN
'--------------------
LOCAL FN doDialog
dType = DIALOG(0)
dCode = DIALOG(dType)
SELECT dType

CASE _wndClose
     IF window(_activeWnd) = 1 THEN END

CASE _btnClick
   LONG IF  WINDOW(_activeWnd) = _tPrefs
     SELECT dCode
     CASE _btn2WClass4  : fn setRestButton( _btn2WClass4 )
     CASE _btn2WClass5  : fn setRestButton( _btn2WClass5 )
     CASE _btn2WClass6  : fn setRestButton( _btn2WClass6 )
     CASE _btn2WClass7  : fn setRestButton( _btn2WClass7 )
     CASE _btn2WClass8  : fn setRestButton( _btn2WClass8 )
     CASE _btn2WClass9  : fn setRestButton( _btn2WClass9 )
     CASE _btn11WClass4 :
       ' should save the data first:  FN SavePrefs
       WINDOW CLOSE _tPrefs
     END SELECT
   END IF

END SELECT
END FN
'--------------------
LOCAL FN doMenu
menuID = MENU(0)
itemID = MENU(1)
IF menuID = 1 AND itemID = 1 THEN FN prefs
IF menuID = 1 AND itemID = 2 THEN END
MENU
END FN
'--------------------
'
' MAIN PROGRAM of demo...
WINDOW 1, "BH-Test", (0,0)-(700,500), 5
TEXT _Geneva, 12,1
rtnChar$ = CHR$(13)
msg$ = "HELLO Brian - This is a test." + rtnChar$
msg$ = msg$ + "Choose 'PREFERENCES' from the FILE menu."
EDIT FIELD 1, msg$, (10, 10)-(350,50), _statFramed, _leftJust

MENU 1,0,1,"File"
MENU 1,1,1,"Preferences"
MENU 1,2,1,"Quit/Q"
EDITMENU 2

ON DIALOG  FN  doDialog
ON MENU  FN  doMenu

DO
   HandleEvents
UNTIL 0









-- 
- Stu Cram, aka  'The Old Guy' at OGSS
    http://Gym-Score-Depot.ca
--
To unsubscribe, send ANY message to: futurebasic-unsubscribe@...