home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
WLADD.ZIP
/
WLADD.C
next >
Wrap
Text File
|
1990-07-31
|
3KB
|
118 lines
#define INCL_WIN
#include <os2.h>
#include <string.h>
#include "os2supt.h"
#include "wladd.h"
/* Global variables */
HAB hab; /* Handle to an anchor block */
/**
*** ═════════════════════════════════════════════════════════════════════════
**/
int main(int argc, char *argv[])
{
static ULONG flFrameFlags = FCF_SHELLPOSITION |
FCF_TASKLIST ;
HMQ hmq; /* Handle to a message queue */
HWND hwndFrame; /* Handle to the frame window */
QMSG qmsg; /* A queued message */
/* Check for a filename from the command line */
hab = WinInitialize(0); /* Initialize the window routines */
hmq = WinCreateMsgQueue(hab,0); /* Create the PM message queue */
WinRegisterClass(hab, CLIENTCLASS, ClientWindowProc, 0L, 0);
hwndFrame = WinCreateWindow(HWND_DESKTOP, CLIENTCLASS, NULL, 0L,
0, 0, 0, 0, HWND_DESKTOP, HWND_BOTTOM,
0, NULL, 0);
while(WinGetMsg(hab, &qmsg, NULL, 0, 0))
WinDispatchMsg(hab,&qmsg);
WinDestroyWindow(hwndFrame);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return 0;
} /* Main */
/**
*** ═════════════════════════════════════════════════════════════════════════
*** Primary dialog procedure
*** ═════════════════════════════════════════════════════════════════════════
**/
MRESULT EXPENTRY ClientWindowProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
static HWND hwndWL; /* Handle to the W L program */
static USHORT usTimerCount = 0; /* Number of timer pops */
switch(msg)
{
case WM_CREATE:
WinAlarm(HWND_DESKTOP,WA_NOTE);
if (!WinStartTimer(hab, hwnd, TIMER, 3000))
{
ErrorHandler(hwnd, CLIENTCLASS, NULL, 0, UERROR_NO_TIMERS, ERRTYPE_USER, 0);
WinPostMsg(hwnd,WM_CLOSE,NULL,NULL);
}
break;
case WM_TIMER:
WinAlarm(HWND_DESKTOP,WA_NOTE);
usTimerCount++;
if (usTimerCount > 5)
{
WinStopTimer(hab, hwnd, TIMER);
ErrorHandler(hwnd, CLIENTCLASS, NULL, 0, UERROR_NO_WINDOW_HANDLE, ERRTYPE_USER, 0);
WinPostMsg(hwnd,WM_CLOSE,NULL,NULL);
}
if ((hwndWL = FindWL(HWND_DESKTOP)) != NULL)
{
WinStopTimer(hab, hwnd, TIMER);
AddToTaskList(hwndWL, CLIENTCLASS);
WinPostMsg(hwnd,WM_CLOSE,NULL,NULL);
}
break;
} /* WM_msg switch */
return WinDefWindowProc(hwnd, msg, mp1, mp2);
} /* ClientWindowProc */
HWND FindWL(HWND hwnd)
{
HWND hwndNext; /* Handle to a window frame */
CHAR szTemp[8]; /* Title of the window frame */
HENUM hEnum; /* Handle to an enumeration list */
/* Enumerate the Windows on the desktop */
hEnum = WinBeginEnumWindows(hwnd);
while ((hwndNext = WinGetNextWindow(hEnum)) != NULL)
{
/* Unlock the Window */
WinLockWindow(hwndNext,FALSE);
/* Get the name of the window */
WinQueryWindowText(hwndNext,8,szTemp);
if (!strcmp(szTemp,"W L"))
return hwndNext;
} /* end While */
WinEndEnumWindows(hEnum);
return NULL;
}