home *** CD-ROM | disk | FTP | other *** search
File List | 1989-02-10 | 3.1 KB | 144 lines |
-
- _A PRESENTATION MANAGER APPLICATION TEMPLATE_
- by Herbert Schildt
-
- [LISTING ONE]
-
-
- /* A Presentation Manager Application skeleton. */
-
- #define INCL_PM
-
- #include <os2.h>
- #include <stddef.h> /* get definition of NULL */
-
- void far * pascal far window_func(void far *, unsigned short,
- void far *, void far *);
-
- char class[] = "MyClass";
-
- main()
- {
- void far *hand_ab;
- void far *hand_mq;
- void far *hand_frame, far *hand_client;
- QMSG q_mess;
- unsigned flags = FCF_SYSMENU |
- FCF_SIZEBORDER | FCF_TITLEBAR |
- FCF_VERTSCROLL| FCF_HORZSCROLL |
- FCF_MINMAX;
-
- hand_ab = WinInitialize(NULL);
-
- hand_mq = WinCreateMsgQueue(hand_ab, 0);
-
- if(!WinRegisterClass(hand_ab, /* anchor block */
- class, /* class name */
- window_func, /* address of window function */
- CS_SIZEREDRAW, /* window style */
- 0)) /* no storage reserved */
- exit(1);
-
- hand_frame = WinCreateStdWindow(HWND_DESKTOP,
- WS_VISIBLE,
- (void far *) &flags,
- (char far *) class,
- (char far *) "My Window",
- 0L, /* resource modules */
- NULL,
- 0,
- &hand_client); /* client handle */
-
- /* message loop */
- while(WinGetMsg(hand_ab, &q_mess, NULL, 0, 0))
- WinDispatchMsg(hand_ab, &q_mess);
-
- WinDestroyWindow(hand_frame);
-
- WinDestroyMsgQueue(hand_mq);
- WinTerminate(hand_ab);
- }
-
- /* This is the window function. */
- void far * pascal far window_func(void far *handle,
- unsigned short mess,
- void far *parm1,
- void far *parm2)
- {
-
- switch(mess) {
- case WM_CREATE:
- /* Perform any necessary initializations here. */
- break;
-
- case WM_PAINT:
- /* Refresh the window each time the WM_PAINT message
- is received.
- */
- break;
-
- case WM_ERASEBACKGROUND:
- /* By returning TRUE, the PM automatically erases
- the old window each time the window is resized
- or moved. Without this, your program must
- manually handle erasing the window with it changes
- size or location.
- */
- return(TRUE);
-
- case WM_CHAR:
- /* Process keystrokes here. */
- break;
-
- case WM_HSCROLL:
- /* Process horizontal scroll request. */
- break;
-
- case WM_VSCROLL:
- /* Process vertical scroll request. */
- break;
-
- case WM_MOUSEMOVE:
- /* Process a mouse motion message. */
- break;
-
- case WM_BUTTON1DOWN:
- /* 1st mouse button is pressed. */
- break;
-
- case WM_BUTTON2DOWN:
- /* 2nd mouse button is pressed. */
- break;
-
- case WM_BUTTON3DOWN:
- /* 3rd mouse button is pressed. */
- break;
-
- /* If required by your application, you may also need to
- process these mouse messages:
-
- WM_BUTTON1UP
- WM_BUTTON1DBLCLK
- WM_BUTTON2UP
- WM_BUTTON2DBLCLK
- WM_BUTTON3UP
- WM_BUTTON3DBLCLK
- */
- }
- /* All messages not handled by the window_func,
- must be passed along to the PM for default
- processing.
- */
- return WinDefWindowProc(handle, mess, parm1, parm2);
- }
-
-
- [LISTING TWO]
-
- NAME skeleton
- HEAPSIZE 4096
- STACKSIZE 4096
- EXPORTS window_func
-
-