home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
PMWALKER.ZIP
/
WALKER.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-08-14
|
3KB
|
114 lines
/* WALKER.C - Sample Animated Icon Program */
/* Copyright (C) Lee S. Fields, 1989 */
#define INCL_WIN
#include <os2.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "walker.h"
/* declare functions to enforce type checking */
MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM);
/* window anchor block handle */
HAB hab;
HMQ hmq; /* message queue handle */
HWND hwndClient, hwndFrame; /* window handles */
QMSG qmsg; /* message queue structure */
/* Common string prefixes */
CHAR szCaption[80] = "Walker";
/* main function setup to accept command line parameters */
void main (void)
{
static CHAR szClientClass[] = "Walker"; /* window class name */
/* start frame with icon, system menu and titlebar */
/* tasklist flag creates problem when selecting from tas */
ULONG flFrameFlags = FCF_ICON | FCF_SYSMENU | FCF_TITLEBAR;
/* start frame style as visible and minimized */
ULONG flFrameStyle = WS_VISIBLE | WS_MINIMIZED;
hab = WinInitialize (0); /* initialize window anchor block
* handle */
hmq = WinCreateMsgQueue (hab, 0); /* create window message queue */
WinRegisterClass (hab, szClientClass, ClientWndProc, 0L, 0); /* register window class */
hwndFrame = WinCreateStdWindow (HWND_DESKTOP, /* parent window handle */
flFrameStyle, /* window frame style */
&flFrameFlags, /* window control flags */
szClientClass, /* window class name */
szCaption, /* title bar text */
0L,/* client window style */
NULL, /* resources in .exe */
IDP_STEP1, /* icon resource id */
&hwndClient); /* pointer to client
* window handler */
/* Process messages, no preprocessing required so just dispatch them */
/* Exit when WM_QUIT message returns FALSE */
while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
WinDispatchMsg (hab, &qmsg);
WinDestroyWindow (hwndFrame); /* destroy the window */
WinDestroyMsgQueue (hmq); /* destroy the message queue */
WinTerminate (hab); /* destroy the anchor block handle */
return 0;
}
MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
static HPOINTER step[IDP_STEP4];
static SHORT counter = IDP_STEP1;
/* process messages */
switch (msg)
{
/* Window is being created */
case WM_CREATE:
for (counter = IDP_STEP1; counter <= IDP_STEP4; counter++)
step[counter] = WinLoadPointer (HWND_DESKTOP, NULL, counter);
if (!WinStartTimer (hab, hwnd, ID_TIMER, 333))
{
WinMessageBox (HWND_DESKTOP, hwnd, "Too many timers",
szCaption, 0, MB_OK | MB_ICONEXCLAMATION);
WinPostMsg (hwnd, WM_QUIT, 0L, 0L); /* send message to exit
* program */
}
return 0;
case WM_TIMER:
if (counter > IDP_STEP4)
counter = IDP_STEP1;
WinSendMsg (hwndFrame, WM_SETICON, step[counter], NULL);
WinInvalidateRect (hwndFrame, NULL, FALSE);
counter++;
return 0;
case WM_DESTROY:
WinStopTimer (hab, hwnd, ID_TIMER);
for (counter = IDP_STEP1; counter <= IDP_STEP4; counter++)
WinDestroyPointer (step[counter]);
return 0;
}
return WinDefWindowProc (hwnd, msg, mp1, mp2);
}