[futurebasic] Overflowing Font Menu problem

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2002 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Sat, 19 Jan 2002 10:07:38 -0500
Using the below code when building my dialog for a text entry window and
popup menus, I get a nice font menu (resource menu, id is _FontPopup)
...the first time.



Problem is that if I close the dialog window , and then open it again, the
font menu is double filled now, with the list appearing twice. If I close
the dialog, then open again, now I have 3 head to tail lists of the fonts
in the same one menu. So if the font list should be 20 items, it is now 60,
3 repeats of the same 20 fonts.

?

What disposing or other handling is called for to make this behave?

Is it getting (re)built on top of itself on subsequent dialog openings?

Robert


'~'2

LOCAL FN ShowFontBox 'show box & selection
DIM temp$
DIM @pictH as handle
DIM theWnd
theWnd = Window(_outputWnd)
Window OutPut _TextEntryWnd
PictH = FN GetPicture(_FontBoxPICT)
DrawPicture(pictH,gFontPopRect)
TEXT 0,12,0,0
Color _zBlack
CALL GETITEM(gFontPopHndl&,gFontPopId%,temp$)'get text of curr item
CALL INSETRECT(gFontPopRect,2,2) 'shrink rect to preserve shadow box
CALL TEXTBOX(VARPTR(temp$)+1,LEN(temp$),gFontPopRect.top%,6)'draw text, 6
is spacer.
CALL INSETRECT(gFontPopRect,-2,-2) 'restore rect
Window OutPut theWnd
END FN
'~'2

LOCAL FN PopFont'this routine pops the menu
DIM  mPt as Point
DIM menuResult as Long
DIM menuID%

mPt.v% = gFontPopRect.top%:mPt.h% = gFontPopRect.left% 'top/left = top/left
of shadow box
CALL LOCALTOGLOBAL(mPt) '    but convert to global coords

menuResult& = FN POPUPMENUSELECT(gFontPopHndl&,mPt.v%,mPt.h%,gFontPopId)

LONG IF menuResult& 'non zero result?
gFontPopId = FN LOWORD(menuResult&)'extract the item number
FN MenuFont (gFontPopId)// RC Addition
menuID = FN HIWORD(menuResult&) 'extract the menu number
FN ShowFontBox 'show the new item in the box
END IF

END FN

'~'2
LOCAL FN BuildFontMenu 'build menu & get handle
MENU _FontPopup, _resMenu, _enable,"FOND"
gFontPopHndl& = FN GETMHANDLE(_FontPopup)
CALL DELETEMENU(_FontPopup) 'delete name from menu bar
CALL INSERTMENU(gFontPopHndl&,-1) 'insert into memory (not into bar)
//CALL DRAWMENUBAR 'fix menu bar(changed by DELMENU)
CALL CALCMENUSIZE(gFontPopHndl&) 'make menu calc its width
gFontPopRect.top%=19:gFontPopRect.left%=60:gFontPopRect.bottom=gFontPopRect.top%
+20'location of our box
gFontPopRect.right% = gFontPopRect.left% +PEEK WORD(PEEK
LONG(gFontPopHndl&)+2)+1'add menu width to calc right side
gFontPopId = 1 'default selection is item 1
END FN
'~'2