home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
372.lha
/
PopUpMenu_3.2
/
Source
/
SendMessage.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-06
|
2KB
|
73 lines
#include "PopUpMenu.h"
/*******************************************************
* SendMessage(ReplyPort) - Send MENUVERIFY message *
* to all windows on screen with MENUVERIFY flag set. *
* Input: *
* ReplyPort - PopUpMenu replyport. *
* Output: *
* return - Messages sent. *
*******************************************************/
SHORT SendMessage(ReplyPort)
struct MsgPort *const ReplyPort;
{
IMPORT struct Window *const ActiveWindow;
struct Window *Window;
WORD NrOfMessages = 0;
Forbid(); /* To be sure that the windowlist doesn't change */
Window = ActiveWindow->WScreen->FirstWindow;
do {
if (Window->IDCMPFlags & MENUVERIFY) {
struct IntuiMessage *const Message =
BuildIntuiMsg(ReplyPort, MENUVERIFY,
(Window == ActiveWindow) ? MENUHOT : MENUWAITING);
if (Message) {
CurrentTime(&Message->Seconds,&Message->Micros);
Message->IDCMPWindow = Window;
PutMsg(Window->UserPort,(struct Message *)Message);
NrOfMessages++;
}
}
}
while (Window = Window->NextWindow);
Permit();
return (NrOfMessages);
}
/***************************************
* BuildIntuiMsg(ReplyMsg,Class,Code) *
* *
* Input: *
* ReplyPort *
* Class *
* Code *
* Output: *
* return - IntuiMessage *
***************************************/
struct IntuiMessage *BuildIntuiMsg(ReplyPort,Class,Code)
struct MsgPort *const ReplyPort;
ULONG Class;
UWORD Code;
{
struct IntuiMessage *const Message =
AllocMem(sizeof(struct IntuiMessage),MEMF_PUBLIC | MEMF_CLEAR);
if (Message) {
Message->ExecMessage.mn_Node.ln_Type = NT_MESSAGE;
Message->ExecMessage.mn_ReplyPort = ReplyPort;
Message->ExecMessage.mn_Length = sizeof(struct IntuiMessage) -
sizeof(struct Message);
Message->Class = Class;
Message->Code = Code;
}
return (Message);
}