home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
PMMSG10.ZIP
/
PMMESSAG.C
next >
Wrap
Text File
|
1991-02-12
|
3KB
|
114 lines
/* ----------------------------------------------------------------------
PMMESSAGE.C -- This will display a message box with the info passed
---------------------------------------------------------------------- */
#define INCL_WIN
#define INCL_DOSERRORS
#define INCL_SHLERRORS
#define INCL_DOSMISC
#define _MT
#include <os2.h>
#include <malloc.h>
#include <process.h>
#include <string.h>
#include <stdlib.h>
#include "pmmessag.h"
/* Global variables */
HAB hab; /* Handle to an anchor block */
/**
*** ═════════════════════════════════════════════════════════════════════════
**/
int main(int argc, char *argv[])
{
HMQ hmq; /* Handle to a message queue */
QMSG qmsg; /* A queued message */
CHAR szText[SZS_TEXT]; /* Message text */
/* Check for a filename from the command line */
hab = WinInitialize(0);
hmq = WinCreateMsgQueue(hab,0);
WinRegisterClass(hab, CLIENTCLASS, MessageWndProc, 0L, 0);
if (ParseCommandLine(argc, argv, szText) != NO_ERROR)
return 0;
/* Create a window so we can pop the message box */
WinCreateWindow(HWND_DESKTOP, /* Parent */
CLIENTCLASS, /* Registered Class */
NULL, /* Window text */
0L, /* Styles */
0, 0, /* Position */
0, 0, /* Sizes */
HWND_DESKTOP, /* Owner */
HWND_BOTTOM, /* Put it on bottom */
IDW_MAIN, /* Control ID */
szText, /* Class specific */
NULL); /* Presentation Parm */
while(WinGetMsg(hab, &qmsg, NULL, 0, 0))
WinDispatchMsg(hab,&qmsg);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return 0;
} /* Main */
/**
*** ═════════════════════════════════════════════════════════════════════════
*** Primary dialog procedure
*** ═════════════════════════════════════════════════════════════════════════
**/
MRESULT EXPENTRY MessageWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
PSZ pszText; /* Pointer to the text */
switch(msg)
{
case WM_CREATE:
pszText = PVOIDFROMMP(mp1);
/* If alarms are turned on in the control panel, beep the bell */
if (WinQuerySysValue(HWND_DESKTOP, SV_ALARM))
WinAlarm(HWND_DESKTOP,WA_NOTE);
WinMessageBox(HWND_DESKTOP, hwnd,
pszText,
"Message:",
0, MB_OK | MB_INFORMATION);
WinPostMsg(hwnd, WM_CLOSE, NULL, NULL);
return 0;
} /* WM_msg switch */
return WinDefWindowProc(hwnd, msg, mp1, mp2);
} /* MessageWndProc */
/**
*** ══════════════════════════════════════════════════════════════════════════
*** Message queue routines
*** ══════════════════════════════════════════════════════════════════════════
**/
USHORT ParseCommandLine(int argc, char *argv[], PSZ pszText)
{
USHORT i; /* Loop index */
_fstrcpy(pszText, "");
for (i = 1; i < argc; i++)
{
_fstrcat(pszText, argv[i]);
_fstrcat(pszText, " ");
}
return NO_ERROR;
} /* ParseCommandLine */