home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
vidbtn.zip
/
TOOLBAR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-10
|
28KB
|
636 lines
/*______________________________________________________________________
| ToolBar 05-14-93 (Revised 5-13-1994) Copyright Greg Ratajik |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| This program shows how to use the VidButtn DLL calls to use |
| animated pushbuttons. This version is for SVGS mode. |
| See VidButtn.DOC for more information. This is the 32 bit OS/2 2.1 |
| Version |
| |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Version Release Date Change |
| ------- ------- ---------- ---------------------------------------- |
| .50 1 11-02-1992 Original AniButtn in ChatterBox |
| .75 3-23-1993 Moved from ChatterBox to stand-alone code |
| 1.00 2 (GA) 5-14-1993 Released as program utility AniButtn.dll |
| 1.50 7-29-1993 Enhanced to VidButtn. |
| 1.75 3 5-21-1994 Added to Easyplay V2.12 |
| 2.00 4 (GA) 5-13-1994 Releases as program utility VidButtn.dll |
|_____________________________________________________________________*/
#define INCL_PM
#define INCL_WINSWITCHLIST
/*______________________________________________________________________
| |
| System Includes |
|_____________________________________________________________________*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <os2.h>
/*______________________________________________________________________
| |
| Application Specific Includes & Defines |
|_____________________________________________________________________*/
#include "toolbar.rch"
#include "VidButtn.h"
/*______________________________________________________________________
| |
| Gobal Local Variables |
|_____________________________________________________________________*/
HSWITCH hSwitch; /* Task switch */
SWCNTRL Swctl; /* Task switch */
CHAR szAppName[20]; /* Window creation */
HAB hAB; /* Handle to anchor block */
HMQ hMQ; /* Handle to message Queue */
HWND hWndFrame; /* Handle to main shell's frame */
HWND hWndClient; /* Handle to main shell's client area */
/*____________________________________________________________________
| |
| Function Prototypes. |
|____________________________________________________________________*/
MRESULT EXPENTRY WndProc ( HWND, ULONG, MPARAM, MPARAM );
MRESULT EXPENTRY ToolBar ( HWND, ULONG, MPARAM, MPARAM );
MRESULT EXPENTRY SENDChatter ( HWND, ULONG, MPARAM, MPARAM );
HWND CreateWindow(HWND,ULONG,PCH,PCH,USHORT,INT,INT,INT,INT,PHWND,ULONG,USHORT );
/*___________________________________________________________________________
| |
| Function: Main |
| |
| Return: SHORT |
| |
| -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
| C H A N G E L O G |
| -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
| |
| INT. DATE DESCRIPTION |
| ---- ---------- --------------------------------------------------- |
| GWR 05-15-1993 Initial Developement |
|___________________________________________________________________________*/
main(int argc, char *argv[])
{
static CHAR szTitle[13];
ULONG flCreate = FCF_TITLEBAR | FCF_SYSMENU;
QMSG qmsg;
SEL sel;
TID tid;
argc = argc;
argv = argv;
if((hAB = WinInitialize(0)) == 0)
return(FALSE);
if((hMQ = WinCreateMsgQueue(hAB, 0)) == 0)
return(FALSE);
if(!RegisterClass())
return(FALSE);
WinLoadString(hAB, 0, IDS_TITLE, 13, szTitle);
hWndFrame = WinCreateStdWindow(HWND_DESKTOP,
WS_VISIBLE | WS_MAXIMIZED,
&flCreate,
"ToolBar",
"ToolBar",
WS_MAXIMIZED,
(HMODULE)NULL,
ID_CHATTER,
&hWndClient);
/*___________________________________
| |
| Provide switch info so |
| ChangeTaskList will work |
|___________________________________*/
{
SWCNTRL swctlSwitchList[10];
CHAR szSwitchTitle [50];
HSWITCH hswSwitch;
PHSWITCH phsw;
PSWCNTRL psw;
PID pid;
psw = &swctlSwitchList[0];
phsw = &hswSwitch;
WinQueryWindowProcess(hWndFrame, &pid, NULL);
strcpy(szSwitchTitle, "ToolBar2");
strcpy(swctlSwitchList[0].szSwtitle, szSwitchTitle);
WinQueryWindowProcess(hWndFrame, &pid, &tid);
Swctl.hwnd = hWndFrame; /* Frame window handle */
Swctl.idProcess = pid; /* Process identifier */
Swctl.uchVisibility = SWL_VISIBLE; /* visibility */
Swctl.fbJump = SWL_JUMPABLE; /* Jump indicator */
strcpy(Swctl.szSwtitle, szTitle); /* Frame window title */
hSwitch = WinAddSwitchEntry(&Swctl);
hswSwitch = WinAddSwitchEntry(&swctlSwitchList[0]);
}
/* The following is the message loop for the application. */
while(WinGetMsg(hAB, (PQMSG)&qmsg, 0, 0, 0))
WinDispatchMsg(hAB,(PQMSG)&qmsg);
WinDestroyWindow(hWndFrame); /* Destroy the frame window */
WinDestroyMsgQueue(hMQ); /* Destroy this application's message queue */
WinTerminate(hAB); /* Terminate this application's use of the */
/* Presentation Manager resources */
} /* end of main */
/*___________________________________________________________________________
| |
| Function: WndProc |
| |
| Description: Main window proc for Toolbar Example |
| |
| Return: MRESULT |
| |
| -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
| C H A N G E L O G |
| -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
| |
| INT. DATE DESCRIPTION |
| ---- ---------- --------------------------------------------------- |
| GWR 05-15-1993 Initial Developement |
|___________________________________________________________________________*/
MRESULT EXPENTRY WndProc(HWND hWnd, ULONG message, MPARAM mp1, MPARAM mp2)
{
HPS hPS; /* Handle for the Presentation Space */
RECTL rClient; /* Handle to rectangle formed by client area */
USHORT rc;
switch(message)
{
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
}
break; /* End of WM_COMMAND */
case WM_CREATE:
/*_____________________________________
| |
| Start the toolbar off. In a normal |
| app, you'd have more than this for |
| the main window. |
|_____________________________________*/
rc = (USHORT) WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, (PFNWP)ToolBar,
0, DLG_TOOLBAR, NULL);
WinPostMsg(hWndClient, WM_QUIT,0L,0L);
return(0);
break; /* End of WM_CREATE */
case WM_MOUSEMOVE:
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break;
case WM_PAINT: /* code for the window's client area */
hPS = WinBeginPaint(hWnd, 0, 0);
WinQueryWindowRect(hWnd, &rClient);
WinFillRect(hPS, &rClient, CLR_BACKGROUND);
WinEndPaint(hPS);
break; /* End of WM_PAINT */
case WM_CLOSE: /* close the window */
WinPostMsg(hWndClient, WM_QUIT,0L,0L);
if(hWnd != hWndClient)
break;
return(WinDefWindowProc(hWnd, message, mp1, mp2));
}
return(0L);
} /* End of WndProc */
/*___________________________________________________________________________
| |
| Function: ToolBar |
| |
| Description: Toolbar DLG Message proc. |
| |
| Return: MRESULT |
| |
| -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
| C H A N G E L O G |
| -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
| |
| INT. DATE DESCRIPTION |
| ---- ---------- --------------------------------------------------- |
| GWR 11-02-1993 Initial Developement |
| GWR 05-14-1994 VidButtn Mods |
|___________________________________________________________________________*/
MRESULT EXPENTRY ToolBar(HWND hWndDlg,
ULONG message,
MPARAM mp1,
MPARAM mp2)
{
static USHORT usUpBits [50];
static USHORT usDownBits[50];
static HWND hWndParent;
USHORT grX;
USHORT grY;
switch(message)
{
case WM_INITDLG:
hWndParent = (HWND)mp2;
/*___________________________________
| |
| Create the Video-pushbuttons. |
| The usUpBits array contains |
| a list of BMP id's, which will be |
| played 0-X when the button is |
| pressed. |
| |
| The usDownBits array contain a list|
| of BMP id's, which will be played |
| 0-X when the button is pressed. |
| |
| Each list MUST contain a NULL at |
| the end. |
| |
| The set-up for this can be stream- |
| lined, but for this example, its |
| done in the simplest, most explicit|
| way. |
| |
|___________________________________*/
usUpBits[0] = ID_EYE1;
usUpBits[1] = ID_EYE2;
usUpBits[2] = ID_EYE3;
usUpBits[3] = ID_EYE4;
usUpBits[4] = ID_EYE5;
usUpBits[5] = 0;
usDownBits[5] = 0;
usDownBits[4] = ID_EYE1;
usDownBits[3] = ID_EYE2;
usDownBits[2] = ID_EYE3;
usDownBits[1] = ID_EYE4;
usDownBits[0] = ID_EYE5;
VidCreateButton(hWndDlg, /* Handle of Dialog */
PB_SCAN_DRIVE, /* ID of control */
&usUpBits[0], /* ID of UP bitmap */
&usDownBits[0], /* ID of DOWN bitmap */
68, /* X Size of bitmaps */
31, /* Y Size of bitmaps */
"Press this VidButton to scan the current drive for the selected file type.", /* Status bar text */
TX_HELP); /* ID of status bar */
usUpBits[0] = ID_REDEYE1;
usUpBits[1] = ID_REDEYE2;
usUpBits[2] = ID_REDEYE3;
usUpBits[3] = ID_REDEYE4;
usUpBits[4] = ID_REDEYE5;
usUpBits[5] = 0; // The last element MUST be a NULL
usDownBits[5] = 0; // The last element MUST be a NULL
usDownBits[4] = ID_REDEYE1;
usDownBits[3] = ID_REDEYE2;
usDownBits[2] = ID_REDEYE3;
usDownBits[1] = ID_REDEYE4;
usDownBits[0] = ID_REDEYE5;
VidCreateButton(hWndDlg, /* Handle of Dialog */
PB_RESCAN, /* ID of control */
&usUpBits[0], /* ID of UP bitmap */
&usDownBits[0], /* ID of DOWN bitmap */
68, /* X Size of bitmaps */
31, /* Y Size of bitmaps */
"Press this VidButton to re-scan the current directory.",/* Status bar text */
TX_HELP); /* ID of status bar */
usUpBits[0] = ID_PLAY1;
usUpBits[1] = ID_PLAY2;
usUpBits[2] = ID_PLAY3;
usUpBits[3] = ID_PLAY4;
usUpBits[4] = ID_PLAY5;
usUpBits[5] = ID_PLAY6;
usUpBits[6] = ID_PLAY7;
usUpBits[7] = ID_PLAY8;
usUpBits[8] = ID_PLAY9;
usUpBits[9] = 0;
usDownBits[9] = 0;
usDownBits[8] = ID_PLAY1;
usDownBits[7] = ID_PLAY2;
usDownBits[6] = ID_PLAY3;
usDownBits[5] = ID_PLAY4;
usDownBits[4] = ID_PLAY5;
usDownBits[3] = ID_PLAY6;
usDownBits[2] = ID_PLAY7;
usDownBits[1] = ID_PLAY8;
usDownBits[0] = ID_PLAY9;
VidCreateButton(hWndDlg, /* Handle of Dialog */
PB_PLAY, /* ID of control */
&usUpBits[0], /* ID of UP bitmap */
&usDownBits[0], /* ID of DOWN bitmap */
68, /* X Size of bitmaps */
31, /* Y Size of bitmaps */
"Press this VidButton to play the selected file.",/* Status bar text */
TX_HELP); /* ID of status bar */
usUpBits[0] = ID_PLAY9;
usUpBits[1] = ID_PLAY8;
usUpBits[2] = ID_PLAY7;
usUpBits[3] = ID_PLAY6;
usUpBits[4] = ID_PLAY5;
usUpBits[5] = ID_PLAY4;
usUpBits[6] = ID_PLAY3;
usUpBits[7] = ID_PLAY2;
usUpBits[8] = ID_PLAY1;
usUpBits[9] = 0;
usDownBits[9] = 0;
usDownBits[8] = ID_PLAY9;
usDownBits[7] = ID_PLAY8;
usDownBits[6] = ID_PLAY7;
usDownBits[5] = ID_PLAY6;
usDownBits[4] = ID_PLAY5;
usDownBits[3] = ID_PLAY4;
usDownBits[2] = ID_PLAY3;
usDownBits[1] = ID_PLAY2;
usDownBits[0] = ID_PLAY1;
VidCreateButton(hWndDlg, /* Handle of Dialog */
PB_ALL, /* ID of control */
&usUpBits[0], /* ID of UP bitmap */
&usDownBits[0], /* ID of DOWN bitmap */
68, /* X Size of bitmaps */
31, /* Y Size of bitmaps */
"Press this VidButton to play all files displayed.",/* Status bar text */
TX_HELP); /* ID of status bar */
usUpBits[0] = ID_ABOUT1;
usUpBits[1] = ID_ABOUT2;
usUpBits[2] = ID_ABOUT3;
usUpBits[3] = ID_ABOUT4;
usUpBits[4] = ID_ABOUT5;
usUpBits[5] = ID_ABOUT6;
usUpBits[6] = ID_ABOUT7;
usUpBits[7] = ID_ABOUT8;
usUpBits[8] = ID_ABOUT9;
usUpBits[9] = ID_ABOUT10;
usUpBits[10] = 0;
usDownBits[10] = 0;
usDownBits[9] = ID_ABOUT1;
usDownBits[8] = ID_ABOUT2;
usDownBits[7] = ID_ABOUT3;
usDownBits[6] = ID_ABOUT4;
usDownBits[5] = ID_ABOUT5;
usDownBits[4] = ID_ABOUT6;
usDownBits[3] = ID_ABOUT7;
usDownBits[2] = ID_ABOUT8;
usDownBits[1] = ID_ABOUT9;
usDownBits[0] = ID_ABOUT10;
VidCreateButton(hWndDlg, /* Handle of Dialog */
PB_ABOUT, /* ID of control */
&usUpBits[0], /* ID of UP bitmap */
&usDownBits[0], /* ID of DOWN bitmap */
68, /* X Size of bitmaps */
31, /* Y Size of bitmaps */
"Press this VidButton Find out how to register this really great program!",/* Status bar text */
TX_HELP); /* ID of status bar */
VidCreateButton(hWndDlg, /* Handle of Dialog */
TBB_NA6, /* ID of control */
&usUpBits[0], /* ID of UP bitmap */
&usDownBits[0], /* ID of DOWN bitmap */
68, /* X Size of bitmaps */
31, /* Y Size of bitmaps */
"Press this VidButton Find out how to register this really great program!",/* Status bar text */
TX_HELP); /* ID of status bar */
usUpBits[0] = ID_EXIT1;
usUpBits[1] = ID_EXIT2;
usUpBits[2] = ID_EXIT3;
usUpBits[3] = ID_EXIT4;
usUpBits[4] = ID_EXIT5;
usUpBits[5] = ID_EXIT6;
usUpBits[6] = ID_EXIT7;
usUpBits[7] = ID_EXIT8;
usUpBits[8] = ID_EXIT9;
usUpBits[9] = ID_EXIT10;
usUpBits[10] = ID_EXIT11;
usUpBits[17] = 0;
usDownBits[14] = 0;
usDownBits[13] = ID_EXIT17;
usDownBits[12] = ID_EXIT17;
usDownBits[11] = ID_EXIT16;
usDownBits[10] = ID_EXIT16;
usDownBits[9] = ID_EXIT15;
usDownBits[8] = ID_EXIT15;
usDownBits[7] = ID_EXIT14;
usDownBits[6] = ID_EXIT14;
usDownBits[5] = ID_EXIT13;
usDownBits[4] = ID_EXIT13;
usDownBits[3] = ID_EXIT12;
usDownBits[2] = ID_EXIT12;
usDownBits[1] = ID_EXIT11;
usDownBits[0] = ID_EXIT11;
VidCreateButton(hWndDlg, /* Handle of Dialog */
PB_EXIT, /* ID of control */
&usUpBits[0], /* ID of UP bitmap */
&usDownBits[0], /* ID of DOWN bitmap */
68, /* X Size of bitmaps */
31, /* Y Size of bitmaps */
"Press this VidButton to Exit EasyPlay.",/* Status bar text */
TX_HELP); /* ID of status bar */
/*___________________________________
| |
| Example of converting a AniButtn |
| to a VidButtn (very simple!) |
|___________________________________*/
// *** Original AniButtn Call ***
// AniCreateButton(hWndDlg,
// TBB_NEXT,
// ID_NEXT1,
// ID_NEXT2,
// 68,
// 31,
// "This is the NEXT Button.",
// TX_TBB_HELP);
//
// *** Converted to a VidButtn ***
usUpBits[0] = ID_NA1;
usUpBits[1] = ID_NA2;
usUpBits[2] = 0;
usDownBits[2] = 0;
usDownBits[1] = ID_NA1;
usDownBits[0] = ID_NA2;
VidCreateButton(hWndDlg, /* Handle of Dialog */
TBB_NA3, /* ID of control */
&usUpBits[0], /* ID of UP bitmap */
&usDownBits[0], /* ID of DOWN bitmap */
68, /* X Size of bitmaps */
31, /* Y Size of bitmaps */
"This is a example of a AniButtn converted to a VidButtn.",/* Status bar text */
TX_HELP); /* ID of status bar */
VidCreateButton(hWndDlg, /* Handle of Dialog */
TBB_NA4, /* ID of control */
&usUpBits[0], /* ID of UP bitmap */
&usDownBits[0], /* ID of DOWN bitmap */
68, /* X Size of bitmaps */
31, /* Y Size of bitmaps */
"This is a example of a AniButtn converted to a VidButtn.",/* Status bar text */
TX_HELP); /* ID of status bar */
VidCreateButton(hWndDlg, /* Handle of Dialog */
TBB_NA5, /* ID of control */
&usUpBits[0], /* ID of UP bitmap */
&usDownBits[0], /* ID of DOWN bitmap */
68, /* X Size of bitmaps */
31, /* Y Size of bitmaps */
"This is a example of a AniButtn converted to a VidButtn.",/* Status bar text */
TX_HELP); /* ID of status bar */
break; /* End of WM_INITDLG */
case WM_CONTROL:
switch(SHORT1FROMMP(mp1))
{
}
break; /* End of WM_CONTROL */
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case PB_ABOUT:
WinMessageBox(HWND_DESKTOP,
hWndDlg,
"This is an example of how to use Greg Ratajik's neat Video-Pushbuttons. \
For more information, send questions to 74555,542 (CompuServe), or 74555.542@compuserve.com (Internet),",
"You Have pressed the ABOUT VidButton",
0, MB_NOICON | MB_OK );
break;
case PB_EXIT:
WinDismissDlg(hWndDlg, FALSE);
break;
}
break; /* End of WM_COMMAND */
case WM_CLOSE:
/*___________________________________
| |
| VidButtn uses a linked list to keep|
| track of everything. This API will|
| delete the node for each button. |
|___________________________________*/
VidDeleteButton(hWndDlg, PB_PLAY );
VidDeleteButton(hWndDlg, PB_ALL );
VidDeleteButton(hWndDlg, PB_EXIT );
VidDeleteButton(hWndDlg, PB_RESCAN );
VidDeleteButton(hWndDlg, PB_SCAN_DRIVE);
VidDeleteButton(hWndDlg, TBB_NA2 );
VidDeleteButton(hWndDlg, TBB_NA3 );
VidDeleteButton(hWndDlg, TBB_NA4 );
VidDeleteButton(hWndDlg, TBB_NA5 );
VidDeleteButton(hWndDlg, TBB_NA7 );
VidDeleteButton(hWndDlg, PB_ABOUT );
WinDismissDlg(hWndDlg, FALSE);
break; /* End of WM_CLOSE */
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
} /* End of CHATTERBox */
/*___________________________________________________________________________
| |
| Function: CreateWindow |
|___________________________________________________________________________*/
HWND CreateWindow(HWND hWndParent,
ULONG ctldata,
PCH appname,
PCH title,
USHORT ResID,
INT x,
INT y,
INT cx,
INT cy,
PHWND hWndClient,
ULONG lfStyle,
USHORT uSizeStyle)
{
HWND hWndFrame;
hWndFrame = WinCreateStdWindow(hWndParent,
lfStyle,
&ctldata,
appname,
title,
WS_MAXIMIZED,
0,
ResID,
(HWND FAR *)hWndClient);
if(hWndFrame == 0)
{
WinMessageBox(HWND_DESKTOP, hWndParent, "Error Creating Window!",
0, 0, MB_OK|MB_ICONEXCLAMATION);
return((HWND)0);
}
return(hWndFrame);
} /* End of CreateWindow */
/*___________________________________________________________________________
| |
| Function: RegisterClass |
|___________________________________________________________________________*/
INT RegisterClass(VOID)
{
INT rc;
WinLoadString(hAB, 0, IDS_APP_NAME, 80, szAppName);
rc = WinRegisterClass(hAB,
(PCH)"ToolBar",
(PFNWP)WndProc,
CS_SIZEREDRAW ,
0);
if (rc == FALSE)
return(FALSE);
return(TRUE);
} /* End of RegisterClass */