|
|
1.1 root 1: /****************************** Module Header ******************************\
2: * Module Name: skelnres.c
3: *
4: * Non-resident portion of Presentation Manager Skel Application
5: *
6: * It illustrates the building of a class record, the registering of
7: * that class record with Presentattion Manager and the creation of a window
8: * of that class. See Skel.DEF for the associated module definition
9: * file
10: *
11: * This is a MIDDLE model application, it has three code segments _RES, _INIT
12: * and _NRES and one data segment _DATA.
13: *
14: * For MIDDLE model, procedures that are accessed from another segment
15: * must be declared FAR (see browse.h).
16: *
17: * Code that is NOT part of the Skel but is merely for demo purposes is
18: * marked as being for demo purposes and should be replaced/removed when this
19: * Skel is converted to a real application.
20: *
21: * Created: 25-Jul-88 (adapted from PM Template App.)
22: *
23: * Created by Microsoft Corporation
24: *
25: *
26: \***************************************************************************/
27:
28: #define INCL_GPI
29: #define INCL_WIN
30: #define INCL_AVIO
31: #define INCL_BASE
32:
33: #include <stdlib.h>
34: #include <os2.h>
35: #include <stdio.h>
36: #include "browse.h"
37:
38: /* min and max macros */
39: #define max(a,b) (((a) > (b)) ? (a) : (b))
40: #define min(a,b) (((a) < (b)) ? (a) : (b))
41:
42: HAB hAB;
43: HMQ hMsgQ;
44: HWND hwndSkel;
45: HWND hwndSkelFrame;
46: HDC hDC;
47: HVPS hVPS;
48: HPS hPS;
49: USHORT Vid_Cols, Vid_Rows;
50:
51: /************************************************************************\
52: * The following following are variables and definitions that are part of
53: * the Skel only for demo purposes and will be replaced when the
54: * Skel is converted to an application
55: \************************************************************************/
56:
57: #define RGBBLACK 0L
58: #define CCHSTR 15
59: #define CSTR 7
60: #define POSMIN 0
61: #define POSMAX 100
62: #define LINEINC 5
63: #define PAGEINC 25
64:
65: CHAR szContent[31];
66: CHAR szStr[CCHSTR+1];
67: CHAR szDefault[CCHSTR+1];
68: CHAR szAppName[10];
69: BOOL bCheckBox = TRUE;
70: BOOL fDoAsync = FALSE;
71: BOOL fDoFlash = FALSE;
72: SHORT fDisplay = IDMCOLOR;
73: SHORT cchContent;
74: SHORT iSel = 2;
75: SHORT posV = 50;
76: SHORT posH = 50;
77:
78: /*********** End of demo purpose variables and definitions ************/
79:
80: /***********************************************************************\
81: *
82: * Procedures in alphabetical order
83: *
84: \***********************************************************************/
85:
86:
87: ULONG FAR PASCAL SkelAboutDlg( hWndDlg, message, mp1, mp2 )
88: HWND hWndDlg;
89: USHORT message;
90: MPARAM mp1;
91: MPARAM mp2;
92: {
93: switch( message )
94: {
95: case WM_COMMAND: /* the user has pressed a button */
96: switch( SHORT1FROMMP( mp1 ) ) /* which button? */
97: {
98: case DID_OK:
99: case DID_CANCEL:
100: WinDismissDlg( hWndDlg, TRUE );
101: break;
102:
103: default:
104: return( FALSE );
105: }
106: break;
107:
108: default:
109: return( (ULONG) WinDefDlgProc( hWndDlg, message, mp1, mp2 ) );
110: }
111: return( FALSE );
112: }
113:
114:
115:
116: VOID SkelCharInput( hWnd, ch, flags, cRepeat )
117: HWND hWnd;
118: SHORT ch;
119: SHORT flags;
120: SHORT cRepeat;
121: {
122: /* ignore cRepeat if you want to ignore auto-repeated keys */
123: while (cRepeat-- != 0)
124: {
125: }
126: }
127:
128: VOID SkelCommand(hWnd, id, source, mouse)
129: HWND hWnd;
130: SHORT id;
131: SHORT source;
132: BOOL mouse;
133: {
134: /******* The code below is for demo purposes only *******/
135:
136: RECTL rect;
137: HPS hPS;
138:
139: switch( id )
140: {
141: case IDMFLASH:
142: WinQueryWindowRect( hWnd, (PRECTL)&rect );
143: hPS = WinGetPS(hWnd );
144: WinInvertRect( hPS, (PRECTL)&rect );
145: WinInvertRect( hPS, (PRECTL)&rect );
146: WinReleasePS( hPS );
147: break;
148:
149: case IDMABOUT:
150: WinDlgBox( HWND_DESKTOP, hWnd, (PFNWP)SkelAboutDlg, NULL,
151: IDD_ABOUT, NULL );
152: break;
153:
154: }
155: /******* The code above is for demo purposes only *******/
156: }
157:
158: VOID InvisoCursor()
159: {
160: VIOCURSORINFO vci;
161: vci.yStart = 0; /* beginning scan line for cursor */
162: vci.cEnd = 0; /* ending scan line, zero-based */
163: vci.cx = 0; /* default width, one character */
164: vci.attr = -1; /* invisible attribute */
165: VioSetCurType(&vci, hVPS);
166: }
167:
168: VOID SkelCreate(hWnd, lParam)
169: HWND hWnd;
170: LONG lParam;
171: {
172: char *pch1;
173: char *pch2;
174:
175: /******* The code below is for demo purposes only *******/
176:
177: cchContent = WinLoadString(hAB, NULL, IDSCONTENT, sizeof(szContent),
178: (PCH)szContent);
179:
180: WinLoadString(hAB, NULL, IDSDEFAULT, sizeof(szDefault), (PCH)szDefault);
181:
182: /* copy default string into szStr */
183: for (pch1 = szStr, pch2 = szDefault; *pch1++ = *pch2++; )
184: ;
185: /******* The code above is for demo purposes only *******/
186:
187: /* open Device Context for the window */
188: /* hWnd is the client window */
189: hDC = WinOpenWindowDC(hWnd);
190:
191: /* open PS for text drawing */
192: VioCreatePS( &hVPS, VIO_PS_ROWS, VIO_PS_COLUMNS, 0, CATTRBYTES, 0);
193:
194: /* associate VIO PS with the device context */
195: VioAssociate( hDC, hVPS);
196:
197: /* make cursor invisible */
198: InvisoCursor();
199:
200: }
201:
202:
203: VOID SkelSetFocus( hWnd )
204: HWND hWnd;
205: {
206: }
207:
208:
209:
210: VOID SkelHorzScroll( hWnd, code, posNew )
211: HWND hWnd;
212: SHORT code;
213: SHORT posNew;
214: {
215: switch( code )
216: {
217: case SB_LINELEFT: /* line left */
218: ExecuteAction( CHAR_LEFT, posNew);
219: break;
220: case SB_LINERIGHT: /* line right */
221: ExecuteAction( CHAR_RIGHT, posNew);
222: break;
223: case SB_PAGELEFT: /* page left */
224: ExecuteAction( PAGE_LEFT, posNew);
225: break;
226: case SB_PAGERIGHT: /* page right */
227: ExecuteAction( PAGE_RIGHT, posNew);
228: break;
229: case SB_SLIDERPOSITION: /* position to posNew */
230: ExecuteAction ( GOTO_HSCROLL, posNew);
231: case SB_SLIDERTRACK:
232: ExecuteAction( GOTO_HSCROLL_TRACK, posNew);
233: break;
234: }
235: }
236:
237: VOID SkelPaint( hWnd, hPS )
238: HWND hWnd;
239: HPS hPS;
240: {
241:
242: /* Here the application paints its window. */
243: /* draw the text */
244: VioShowPS( VIO_PS_ROWS, VIO_PS_COLUMNS, 0, hVPS);
245: }
246:
247:
248:
249: /******* The code below is for demo purposes only *******/
250:
251: VOID SkelQueryQuit( hWnd )
252: HWND hWnd;
253: {
254: CHAR szOkClose[CCHMAXSTRING];
255: CHAR szClose[CCHMAXSTRING];
256:
257: WinLoadString(hAB, NULL, IDSOKCLOSE, CCHMAXSTRING , (PCH)szOkClose);
258: WinLoadString(hAB, NULL, IDSCLOSE, CCHMAXSTRING , (PCH)szClose );
259: WinAlarm( HWND_DESKTOP, WA_WARNING );
260: if ( WinMessageBox(HWND_DESKTOP, hWnd, (PCH)szOkClose, (PCH)szClose,
261: NULL, MB_OKCANCEL|MB_ICONQUESTION ) == DID_OK )
262: WinPostMsg( hWnd, WM_QUIT, 0L, 0L );
263: }
264:
265: /******* The code above is for demo purposes only *******/
266:
267:
268: /******* The code below is for demo purposes only *******/
269:
270: VOID SkelTimer( hWnd, id )
271: HWND hWnd;
272: USHORT id;
273: {
274: }
275:
276: /******* The code above is for demo purposes only *******/
277:
278:
279:
280: VOID SkelVertScroll( hWnd, code, posNew )
281: HWND hWnd;
282: SHORT code;
283: USHORT posNew;
284: {
285: switch( code )
286: {
287: case SB_LINEUP:
288: ExecuteAction( LINE_UP, posNew );
289: break;
290: case SB_LINEDOWN:
291: ExecuteAction( LINE_DOWN, posNew );
292: break;
293: case SB_PAGEUP:
294: ExecuteAction( PAGE_UP, posNew );
295: break;
296: case SB_PAGEDOWN:
297: ExecuteAction( PAGE_DOWN, posNew );
298: break;
299: case SB_SLIDERPOSITION:
300: ExecuteAction( GOTO_LINE, posNew );
301: break;
302: case SB_SLIDERTRACK:
303: ExecuteAction( GOTO_LINE_TRACK, posNew);
304: break;
305: }
306: }
307:
308: VOID SetScrollPosVert( sPos, sMax )
309: SHORT sPos, sMax;
310: /* put the slider at the appropriate place.
311: parameters given are sPos=position of the slider, sMax=max position of
312: slider.
313: */
314: {
315: WinSendMsg(
316: WinWindowFromID(hwndSkelFrame, FID_VERTSCROLL), /* vscroll's handle */
317: SBM_SETSCROLLBAR, /* message: set parms */
318: (MPARAM) MAKEULONG ( sPos, 0 ), /* position */
319: (MPARAM) MAKEULONG ( 0, sMax ) /* min, max */
320: );
321: }
322:
323: VOID SetScrollPosHorz( sPos, sMax )
324: SHORT sPos, sMax;
325: /* put the slider at the appropriate place.
326: parameters given are sPos=position of the slider, sMax=max position of
327: slider.
328: */
329: {
330: WinSendMsg(
331: WinWindowFromID(hwndSkelFrame, FID_HORZSCROLL), /* vscroll's handle */
332: SBM_SETSCROLLBAR, /* message: set parms */
333: (MPARAM) MAKEULONG ( sPos, 0 ), /* position */
334: (MPARAM) MAKEULONG ( 0, sMax ) /* min, max */
335: );
336: }
337:
338: VOID GetWinCharSize( VOID )
339: {
340: LONG lCHeight, lCWidth;
341: RECTL rcl;
342:
343: DevQueryCaps(hDC, CAPS_CHAR_HEIGHT, 1L, &lCHeight);
344: DevQueryCaps(hDC, CAPS_CHAR_WIDTH, 1L, &lCWidth);
345: WinQueryWindowRect(hwndSkel, &rcl);
346: Vid_Rows=((SHORT)(rcl.yTop-rcl.yBottom))/(SHORT)lCHeight;
347: Vid_Cols=((SHORT)(rcl.xRight-rcl.xLeft))/(SHORT)lCWidth;
348: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.