home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
develo.zip
/
ZIP
/
SAMPLE.C
next >
Wrap
C/C++ Source or Header
|
1993-06-21
|
6KB
|
196 lines
#define MAIN
#define INCL_DOSFILEMGR
#define INCL_PM
#define INCL_WINDIALOGS
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include "sample.h"
#include "wcpic16.h"
#define NULLHANDLE NULL
HAB hAB;
HMQ hMQ;
HWND hwndFrame;
HWND hwndClient;
/********************************************************************\
* Main Entrypoint *
\********************************************************************/
int main(argc, argv)
int argc;
char *argv[];
{
QMSG qmsg; // MSG structure to store your messages
ULONG flStyle;
RECTL rc;
/*****************************************************************\
* The WinInitialize routine initializes the Presentation Manager *
* facilities for use by this application and returns a handle to *
* the anchor block assigned to the application by PM. *
\*****************************************************************/
if((hAB = WinInitialize(0)) == 0)
return(FALSE);
/*****************************************************************\
* The WinCreateMsgQueue call creates a msg queue for this app. *
/*****************************************************************/
if((hMQ = WinCreateMsgQueue(hAB, 0)) == 0)
return(FALSE);
/*█████████████████████████████████████████████████████████████████
█ █
█ This is the only line of code you need to add to your codes. █
█ Just initialize the entryfield picture mask window class. █
█ █
██████████████████████████████████████████████████████████████████*/
fnInitWCPicMsk(hAB);
/*****************************************************************\
* Register the sample window class *
\*****************************************************************/
WinRegisterClass(hAB, // Anchor block handle
(PCH)"SAMPLE", // Name of class to register
(PFNWP)WndProc, // Window procedure for class
CS_SIZEREDRAW ,
0);
flStyle = FCF_TITLEBAR | FCF_SYSMENU |
FCF_MINBUTTON | FCF_MAXBUTTON |
FCF_SIZEBORDER | FCF_TASKLIST |
FCF_MENU;
hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
WS_VISIBLE,
&flStyle,
"SAMPLE",
"Picture Mask Sample Window",
WS_VISIBLE,
NULLHANDLE,
ID_SAMPLE,
&hwndClient);
WinQueryWindowRect(HWND_DESKTOP, &rc);
WinSetWindowPos(hwndFrame,
HWND_TOP,
(SHORT)(rc.xRight / 16L),
(SHORT)(rc.yTop / 6L),
(SHORT)(rc.xRight / 1.14L),
(SHORT)(rc.yTop / 1.5L),
SWP_ACTIVATE | SWP_SHOW | SWP_SIZE | SWP_MOVE
| SWP_ZORDER);
/******************************************************************\
* The following is the message loop for the application. *
\******************************************************************/
while(WinGetMsg(hAB, (PQMSG)&qmsg, 0, 0, 0))
WinDispatchMsg(hAB,(PQMSG)&qmsg);
/*****************************************************************\
* Cleanup and terminate *
\*****************************************************************/
WinDestroyWindow(hwndFrame); // Destroy the frame window
WinDestroyMsgQueue(hMQ); // Destroy application's message queue
WinTerminate(hAB); // Terminate application's use of the
// Presentation Manager resources
DosExit(EXIT_PROCESS, 0);
} /* end of main */
/********************************************************************\
* Main Window Procedure *
\********************************************************************/
MRESULT EXPENTRY WndProc(HWND hwnd, UINT msg, MPARAM mp1, MPARAM mp2)
{
HPS hps;
RECTL rClient;
switch(msg)
{
case WM_CREATE:
WinPostMsg(hwnd, WM_COMMAND, MPFROMSHORT(ID_M_ABOUT), 0L);
break;
case WM_PAINT:
hps = WinBeginPaint(hwnd, NULLHANDLE, &rClient);
WinFillRect(hps, &rClient, SYSCLR_APPWORKSPACE);
WinEndPaint(hps);
break;
case WM_COMMAND:
fnProcessCmd(hwnd, msg, mp1, mp2);
break;
case WM_CLOSE:
WinPostMsg(hwnd, WM_QUIT, 0L, 0L);
break;
default:
return(WinDefWindowProc(hwnd, msg, mp1, mp2));
}
return((MRESULT)0L);
}
VOID fnProcessCmd(HWND hwnd, UINT msg, MPARAM mp1, MPARAM mp2)
{
ERRORID err;
switch (SHORT1FROMMP(mp1))
{
case ID_M_DIALOG:
WinDlgBox(HWND_DESKTOP,
hwnd,
SampleDlgProc,
NULLHANDLE,
(LONG)IDLG_EMPINFO,
NULL);
err = WinGetLastError(hAB);
break;
case ID_M_ABOUT:
WinDlgBox(hwnd,
hwnd,
AboutDlgProc,
NULLHANDLE,
IDLG_ABOUT,
NULL);
break;
case ID_M_EXIT:
WinPostMsg(hwnd, WM_CLOSE, 0L, 0L);
break;
}
return ;
}
MRESULT EXPENTRY SampleDlgProc(HWND hwnd, UINT msg, MPARAM mp1, MPARAM mp2)
{
return (WinDefDlgProc(hwnd, msg, mp1, mp2));
}
MRESULT EXPENTRY AboutDlgProc(HWND hwnd, UINT msg, MPARAM mp1, MPARAM mp2)
{
return (WinDefDlgProc(hwnd, msg, mp1, mp2));
}