Path: utzoo!utgpu!watmath!att!dptg!rutgers!tut.cis.ohio-state.edu!purdue!bu-cs!dartvax!eleazar.dartmouth.edu!isle
From: isle@eleazar.dartmouth.edu (Ken Hancock)
Newsgroups: comp.sys.mac.programmer
Subject: Menubar updating
Message-ID: <15029@dartvax.Dartmouth.EDU>
Date: 15 Aug 89 13:09:32 GMT
Sender: news@dartvax.Dartmouth.EDU
Reply-To: isle@eleazar.dartmouth.edu (Ken Hancock)
Organization: Computer Resource Center, Dartmouth College
Lines: 52


I'm writing a DA, and like all good little DA's, it will
remove it's menu from the MenuBar when not frontmost.
The only probelm is, that no matter what code I use,
I sometimes get a Disposed menu in the menubar
(clicking on it will of course crash the system...)

The code I'm using is included below:


void UpdateMBar(dce)
DCtlPtr	dce;
{
register WindowPeek wptr = (WindowPeek) FrontWindow();

	/*	If our window isn't the frontmost, hide the
	 *	menu to avoid menubar clutter.	*/

	if (wptr)
		{	 
		if (wptr->windowKind == dce->dCtlRefNum)
			{
			if (!GetMHandle(dce->dCtlMenu))
				{
				InsertMenu(myMenuHandle,0);
				DrawMenuBar();
				}
			}
		else if (GetMHandle(dce->dCtlMenu))
			{
			DeleteMenu(dce->dCtlMenu);
			DrawMenuBar();
			}
		}
}

Now the only time that the menu is actually Disposed of is after
I receive an accClose and have closed the driver.  Does anyone know
what I'm doing wrong?

Thanks in advance --

Ken





Ken Hancock  '90                    | E-mail: (BITNET/UUCP/INTERNET)
Computer Resource Center Consultant |   isle@eleazar.dartmouth.edu
------------------------------------+---------------------------------------
DISCLAIMER?  I don't get paid enough to worry about disclaimers.