source: trunk/src/user32/new/pmwindow.cpp@ 4

Last change on this file since 4 was 4, checked in by ktk, 26 years ago

Import

File size: 4.4 KB
Line 
1/* $Id: pmwindow.cpp,v 1.1 1999-05-24 20:20:04 ktk Exp $ */
2
3/*
4 * Win32 Window Managment Code for OS/2
5 *
6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 */
9#define INCL_WIN
10#define INCL_GPI
11
12#include <os2.h> /* PM header file */
13#include "misc.h"
14#include "win32wnd.h"
15#include "win32dlg.h"
16
17HMQ hmq = 0; /* Message queue handle */
18HAB hab = 0;
19
20MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
21MRESULT EXPENTRY Win32DialogProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2);
22
23//******************************************************************************
24//Initialize PM; create hab, message queue and register special Win32 window class
25//******************************************************************************
26BOOL InitPM()
27{
28 hab = WinInitialize(0);
29 hmq = WinCreateMsgQueue(hab, 0);
30
31 if(!hab || !hmq) {
32 dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
33 return(FALSE);
34 }
35
36 if(!WinRegisterClass( /* Register window class */
37 hab, /* Anchor block handle */
38 (PSZ)"Win32Window", /* Window class name */
39 (PFNWP)Win32WindowProc, /* Address of window procedure */
40 CS_SIZEREDRAW, /* Class style */
41 4)) {
42 dprintf(("WinRegisterClass Win32Window failed"));
43 return(FALSE);
44 }
45
46 if(!WinRegisterClass( /* Register window class */
47 hab, /* Anchor block handle */
48 (PSZ)"Win32Dialog", /* Window class name */
49 (PFNWP)Win32DialogProc, /* Address of window procedure */
50 CS_SIZEREDRAW, /* Class style */
51 4)) {
52 dprintf(("WinRegisterClass Win32Dialog failed"));
53 return(FALSE);
54 }
55
56 return(TRUE);
57} /* End of main */
58//******************************************************************************
59//Win32 window message handler
60//******************************************************************************
61MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
62{
63 Win32Window *win32wnd = (Win32Window *)WinQueryWindowULong(hwnd, 0);
64 MRESULT rc;
65
66 switch( msg )
67 {
68 case WM_CREATE:
69 win32wnd = new Win32Window(hwnd, msg, mp1, mp2);
70 if(win32wnd == NULL) {
71 dprintf(("new win32wnd failed!"));
72 }
73 if(WinSetWindowULong(hwnd, 0, (ULONG)win32wnd) == FALSE) {
74 dprintf(("WinSetWindowULong %X failed!!", hwnd));
75 }
76 break;
77
78 default:
79 /*
80 * Everything else comes here. This call MUST exist
81 * in your window procedure.
82 */
83 if(win32wnd == NULL) {
84 dprintf(("Win32WindowProc: win32wnd NULL!"));
85 return WinDefWindowProc( hwnd, msg, mp1, mp2 );
86 }
87
88 if(win32wnd->ProcessMessage(hwnd, msg, mp1, mp2, &rc) == TRUE) {
89 return(rc);
90 }
91 return WinDefWindowProc( hwnd, msg, mp1, mp2 );
92 }
93 return (MRESULT)FALSE;
94} /* End of Win32WindowProc */
95//******************************************************************************
96//Win32 dialog message handler
97//******************************************************************************
98MRESULT EXPENTRY Win32DialogProc( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 )
99{
100 Win32Dialog *win32dlg = (Win32Dialog *)WinQueryWindowULong(hwndDlg, 0);
101 MRESULT rc;
102
103 switch(msg)
104 {
105 case WM_INITDLG:
106 win32dlg = new Win32Dialog(hwndDlg, msg, mp1, mp2);
107 if(win32dlg == NULL) {
108 dprintf(("new win32dlg failed!"));
109 }
110 if(WinSetWindowULong(hwndDlg, 0, (ULONG)win32dlg) == FALSE) {
111 dprintf(("WinSetWindowULong %X failed!!", hwndDlg));
112 }
113 break;
114
115 default:
116 /*
117 * Any event messages that the dialog procedure has not processed
118 * come here and are processed by WinDefDlgProc.
119 * This call MUST exist in your dialog procedure.
120 */
121 if(win32dlg == NULL) {
122 dprintf(("Win32DialogProc: win32dlg NULL!"));
123 return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
124 }
125 if(win32dlg->ProcessDlgMessage(hwndDlg, msg, mp1, mp2, &rc) == TRUE) {
126 return(rc);
127 }
128 return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
129 }
130 return (MRESULT) FALSE;
131}
132//******************************************************************************
133//******************************************************************************
Note: See TracBrowser for help on using the repository browser.