|
|
1.1 root 1: #include <stdlib.h>
2:
3: #include "mltithrd.h"
4: #include <stdarg.h>
5:
6: #define CCOLORS 16
7: #define CPOINTS 20
8: #define COBJS 1
9:
10:
11: /*
12: * Some handy globals.
13: */
14: HANDLE ghModule;
15: HWND ghwndMain = NULL;
16: HBRUSH ghbrWhite, ghbrBlack;
17: HBRUSH gahbrColor[CCOLORS];
18: int cmdDemo = 0;
19: BOOL bKillMe = FALSE;
20:
21: HMENU hMenu, hMenuWindow;
22:
23: DWORD aclr[CCOLORS] = {
24: 0x00000000, // black
25: 0x007F0000, // red
26: 0x00007F00, // green
27: 0x007F7F00, // mustard/brown
28: 0x0000007F, // blue
29: 0x007F007F, // magenta
30: 0x00007F7F, // cyan
31: 0x00BFBFBF, // light gray
32: 0x007F7F7F, // dark gray
33: 0x00FF0000, // bright red
34: 0x0000FF00, // bright green
35: 0x00FFFF00, // bright yellow
36: 0x000000FF, // bright blue
37: 0x00FF00FF, // bright magenta
38: 0x0000FFFF, // bright cyan
39: 0x00FFFFFF // bright white
40: };
41:
42:
43: typedef struct _b {
44: POINT apt[CPOINTS];
45: int dx;
46: int dy;
47: int vx;
48: int vy;
49: int ax;
50: int ay;
51: int iColor;
52: } B;
53:
54:
55: typedef struct _ThreadBlockInfo {
56: HANDLE hThread;
57: BOOL bKillThrd;
58: HWND hwndClient;
59: HWND hwndThreadWindow;
60: LONG lThreadId;
61: char CaptionBarText[SIZEOFCAPTIONTEXT];
62: B gab[COBJS];
63: RECT rcClient;
64: HDC hdcThreadWindow;
65: } THREADBLOCKINFO, *PTHREADBLOCKINFO;
66:
67:
68: typedef struct _node {
69: THREADBLOCKINFO ThreadWindow;
70: HANDLE hNext;
71: } NODE, *PNODE;
72:
73:
74: /*
75: * Forward declarations.
76: */
77: BOOL InitializeApp (void);
78: LONG MainWndProc (HWND, UINT, DWORD, LONG);
79: LONG ThreadWndProc (HWND, UINT, DWORD, LONG);
80: LONG About (HWND, UINT, DWORD, LONG);
81:
82: LONG StartBounce (PTHREADBLOCKINFO);
83: void DrawBox (int, int, HBRUSH, PTHREADBLOCKINFO);
84: void MoveBox (int *px, int *py, int *pdx, int *pdy, int *pvx, int *pvy, int ax, int ay, PTHREADBLOCKINFO pThreadBlockInfo);
85: void BounceProc (PTHREADBLOCKINFO);
86: BOOL StartDemo (int, PTHREADBLOCKINFO);
87: int GetRandomVector ();
88: void InitializeBoxes (BOOL, PTHREADBLOCKINFO);
89:
90: /***************************************************************************\
91: * main
92: *
93: *
94: * History:
95: * 04-17-91 ??????? Created.
96:
97: \***************************************************************************/
98:
99: int WinMain(
100: HANDLE hInstance,
101: HANDLE hPrevInstance,
102: LPSTR lpCmdLine,
103: int nShowCmd)
104: {
105: MSG msg;
106:
107: // this will change to something more reasonable
108:
109: ghModule = GetModuleHandle(NULL);
110:
111: if (!InitializeApp()) {
112: MessageBox(ghwndMain, "MLTITHRD: InitializeApp failure!", "Error", MB_OK);
113: return 0;
114: }
115:
116: while (GetMessage(&msg, NULL, 0, 0)) {
117: TranslateMessage(&msg);
118: DispatchMessage(&msg);
119: }
120:
121: return 1;
122:
123: hInstance;
124: hPrevInstance;
125: lpCmdLine;
126: nShowCmd;
127: }
128:
129:
130: /***************************************************************************\
131: * InitializeApp
132: *
133: * History:
134: * 04-17-91 ??????? Created.
135:
136: * 09-09-91 PetrusW Rewrote.
137: \***************************************************************************/
138:
139: BOOL InitializeApp(void)
140: {
141: WNDCLASS wc;
142: int i;
143:
144: srand(51537);
145:
146: for (i = 0; i < CCOLORS; i++) {
147: gahbrColor[i] = CreateSolidBrush(aclr[i]);
148: }
149:
150: ghbrWhite = CreateSolidBrush(0x00FFFFFF);
151: ghbrBlack = CreateSolidBrush(0x00000000);
152:
153: wc.style = CS_OWNDC;
1.1.1.2 ! root 154: wc.lpfnWndProc = (WNDPROC)MainWndProc;
1.1 root 155: wc.cbClsExtra = 0;
156: wc.cbWndExtra = sizeof(LONG);
157: wc.hInstance = ghModule;
158: wc.hIcon = LoadIcon(ghModule,MAKEINTRESOURCE(APPICON));
159: wc.hCursor = LoadCursor(NULL, IDC_ARROW);
160: wc.hbrBackground = ghbrWhite;
161: wc.lpszMenuName = "MainMenu";
162: wc.lpszClassName = "MltithrdClass";
163:
164: if (!RegisterClass(&wc))
165: return FALSE;
166:
167: wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
1.1.1.2 ! root 168: wc.lpfnWndProc = (WNDPROC)ThreadWndProc;
1.1 root 169: wc.cbClsExtra = 0;
170: wc.cbWndExtra = 0;
171: wc.hInstance = ghModule;
172: wc.hIcon = LoadIcon(ghModule,MAKEINTRESOURCE(APPICON));
173: wc.hCursor = LoadCursor(NULL, IDC_ARROW);
174: wc.hbrBackground = ghbrWhite;
175: wc.lpszMenuName = NULL;
176: wc.lpszClassName = "ThreadClass";
177:
178: if (!RegisterClass(&wc))
179: return FALSE;
180:
181: hMenu = LoadMenu(ghModule, "MainMenu");
182: hMenuWindow = GetSubMenu(hMenu, 1);
183:
184: ghwndMain = CreateWindowEx(0L, "MltithrdClass", "Mltithrd",
185: WS_OVERLAPPED | WS_CAPTION | WS_BORDER | WS_THICKFRAME |
186: WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN |
187: WS_VISIBLE | WS_SYSMENU,
188: 80, 70, 400, 300,
189: NULL, hMenu, ghModule, NULL);
190:
191: if (ghwndMain == NULL)
192: return FALSE;
193:
194: SetWindowLong(ghwndMain, GWL_USERDATA, 0L);
195:
196: SetFocus(ghwndMain); /* set initial focus */
197:
198: return TRUE;
199: }
200:
201:
202: /***************************************************************************\
203: * MainWndProc
204: *
205: * History:
206: * 04-17-91 ??????? Created.
207:
208: * 09-09-91 PetrusW Rewrote.
209: \***************************************************************************/
210:
211: long MainWndProc(
212: HWND hwnd,
213: UINT message,
214: DWORD wParam,
215: LONG lParam)
216: {
217: static int iCount=1;
218: static HWND hwndClient;
219: CLIENTCREATESTRUCT clientcreate;
220: HWND hwndChildWindow;
221:
222:
223: switch (message) {
224:
225:
226: case WM_CREATE:
227: SetWindowLong(hwnd, 0, (LONG)NULL);
228:
229: clientcreate.hWindowMenu = hMenuWindow;
230: clientcreate.idFirstChild = 1;
231:
232: hwndClient = CreateWindow("MDICLIENT", NULL,
233: WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
234: 0,0,0,0,
235: hwnd, NULL, ghModule, (LPVOID)&clientcreate);
236: return 0L;
237:
238: case WM_DESTROY: {
239: HANDLE hHead, hTmp;
240: PNODE pHead;
241:
242: bKillMe = TRUE;
243:
244: hHead = (HANDLE) GetWindowLong(hwnd, 0);
245: if (hHead) {
246: if ((pHead = (PNODE) LocalLock(hHead))==NULL)
247: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK);
248: while (pHead->hNext != NULL) {
249:
250: hTmp = hHead;
251: hHead = pHead->hNext;
252: LocalUnlock(hTmp);
253:
254: if (LocalFree(hTmp)!=NULL)
255: MessageBox(ghwndMain, "Failed in LocalFree!", "Error", MB_OK);
256: if ((pHead = (PNODE) LocalLock(hHead))==NULL)
257: MessageBox(ghwndMain, "Failed in LocalLock, hHead!", "Error", MB_OK);
258: }
259: LocalUnlock(hHead);
260:
261: if (LocalFree(hHead)!=NULL)
262: MessageBox(ghwndMain, "LocalFree failed to free hHead!", "Error", MB_OK);
263: }
264: PostQuitMessage(0);
265: return 0L;
266: }
267:
268: #ifdef LATER
269: case WM_LBUTTONDOWN:
270: InitializeBoxes(TRUE, &ThreadWindow);
271: break;
272: #endif
273:
274: case WM_COMMAND:
275:
276: switch (LOWORD(wParam)) {
277: case IDM_TILE:
278: SendMessage(hwndClient, WM_MDITILE, 0L, 0L);
279: return 0L;
280: case IDM_CASCADE:
281: SendMessage(hwndClient, WM_MDICASCADE, 0L, 0L);
282: return 0L;
283: case IDM_ARRANGE:
284: SendMessage(hwndClient, WM_MDIICONARRANGE, 0L, 0L);
285: return 0L;
286: case MM_BOUNCE: {
287: HANDLE hNode, hHead;
288: HANDLE hThrd;
289: PNODE pNode;
290: MDICREATESTRUCT mdicreate;
291:
292: hNode = LocalAlloc(LHND, (WORD) sizeof(NODE));
293: if (hNode) {
294: if ((pNode = (PNODE)LocalLock(hNode))==NULL)
295: MessageBox(ghwndMain, "Failed in LocalLock, hNode!", "Error", MB_OK);
296:
297: wsprintf((LPSTR)&(pNode->ThreadWindow.CaptionBarText), "Thread Window %d", iCount);
298:
299: mdicreate.szClass = "ThreadClass";
300: mdicreate.szTitle = (LPSTR)&(pNode->ThreadWindow.CaptionBarText);
301: mdicreate.hOwner = ghModule;
302: mdicreate.x =
303: mdicreate.y =
304: mdicreate.cx =
305: mdicreate.cy = CW_USEDEFAULT;
306: mdicreate.style = 0l;
307: mdicreate.lParam = 0L;
308:
309: /*Create Child Window*/
310: hwndChildWindow = (HANDLE) SendMessage(hwndClient, WM_MDICREATE,
311: 0L,
312: (LONG)(LPMDICREATESTRUCT)&mdicreate);
313:
314: if (hwndChildWindow == NULL) {
315: MessageBox(ghwndMain, "Failed in Creating Thread Window!", "Error", MB_OK);
316: return 0L;
317: }
318:
319: // This stuff is here for simplicity. Initialization should
320: // be done in StartDemo
321: pNode->ThreadWindow.hwndClient = hwndClient;
322: pNode->ThreadWindow.hwndThreadWindow = hwndChildWindow;
323: hHead = (HANDLE)GetWindowLong(hwnd, 0);
324: pNode->hNext = hHead;
325: SetWindowLong(hwnd, 0, (LONG) hNode);
326:
327: // Create the thread suspended so we can alter its priority
328:
329: // before it begins to run.
330:
331:
332:
333: hThrd = CreateThread(NULL, 0,
334: (LPTHREAD_START_ROUTINE)StartBounce,
335: &pNode->ThreadWindow,
336: CREATE_SUSPENDED | STANDARD_RIGHTS_REQUIRED,
337:
338: (LPDWORD) &pNode->ThreadWindow.lThreadId );
339: if (hThrd) {
340:
341: // I really don't need this info, it won't even be
342: // updated right the way for this thread will be
343: // preempted.
344: pNode->ThreadWindow.hThread = hThrd;
345: iCount++;
346:
347:
348: // This way the primary (input) thread will be higher priority
349:
350: // than the bouncers, thus keeping MLTITHRD responsive to user
351:
352: // input.
353:
354:
355:
356: SetThreadPriority(hThrd, THREAD_PRIORITY_BELOW_NORMAL);
357:
358:
359:
360: // Everything's set, let it go.
361:
362:
363:
364: ResumeThread(hThrd);
365:
366:
367: } else {
368: MessageBox(ghwndMain, "Create Thread Failed!", "Error", MB_OK);
369: }
370: LocalUnlock(hNode);
371:
372: } else {
373: MessageBox(ghwndMain, "Failed to Allocate Node!", "Error", MB_OK);
374: }
375: return 0L;
376: }
377:
378: case MM_ABOUT:
1.1.1.2 ! root 379: if (DialogBox(ghModule, "AboutBox", ghwndMain, (DLGPROC)About) == -1)
1.1 root 380: MessageBox(ghwndMain, "Mltithrd: About Dialog Creation Error!", "Error", MB_OK);
381: return 0L;
382:
383: default:
384: return DefFrameProc(hwnd, hwndClient, message, wParam, lParam);
385: }
386:
387: default:
388:
389: return DefFrameProc(hwnd, hwndClient, message, wParam, lParam);
390: }
391: }
392:
393: /********************************************************************\
394: * ThreadWndProc
395: *
396: * History:
397: * 04-17-91 ??????? Created.
398:
399: * 09-09-91 PetrusW Rewrote.
400: \***************************************************************************/
401:
402: long ThreadWndProc(
403: HWND hwnd,
404: UINT message,
405: DWORD wParam,
406: LONG lParam)
407: {
408: switch (message) {
409: case WM_SIZE:
410:
411: case WM_CREATE: {
412: PTHREADBLOCKINFO pThreadBlockInfo;
413: PNODE pHead;
414: HANDLE hHead, hTmp;
415:
416:
417:
418: // now find match
419: hHead = (HANDLE) GetWindowLong(ghwndMain, 0);
420: if (hHead) {
421: if ((pHead = (PNODE)LocalLock(hHead))==NULL)
422: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK);
423:
424: while ((pHead->ThreadWindow.hwndThreadWindow != hwnd) &&
425: (pHead->hNext != NULL)) {
426: hTmp = hHead;
427: hHead = pHead->hNext;
428: LocalUnlock(hTmp);
429:
430: if ((pHead = (PNODE) LocalLock(hHead))==NULL)
431: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK);
432: }
433: if (pHead->ThreadWindow.hwndThreadWindow == hwnd) {
434: pThreadBlockInfo = &pHead->ThreadWindow;
435: goto Thread_Found;
436: } else {
437: //MessageBox(ghwndMain, "Trouble - Can't find the thread node!", "Error", MB_OK);
438: goto Thread_Out;
439: }
440:
441: Thread_Found:
442: if (!GetClientRect(pThreadBlockInfo->hwndThreadWindow,
443: &pThreadBlockInfo->rcClient))
444: MessageBox(ghwndMain, "Failed in GetClientRect!", "Error", MB_OK);
445: Thread_Out:
446: LocalUnlock(hHead);
447:
448: return DefMDIChildProc(hwnd, message, wParam, lParam);
449: } else {
450: //MessageBox(ghwndMain, "Can't GetWindowLong(ghwndMain,0) !", "Error", MB_OK);
451: } return DefMDIChildProc(hwnd, message, wParam, lParam);
452: }
453:
454: case WM_CLOSE: {
455: PTHREADBLOCKINFO pThreadBlockInfo;
456: PNODE pHead;
457: HANDLE hHead, hTmp;
458:
459:
460:
461: // now find match
462: hHead = (HANDLE) GetWindowLong(ghwndMain, 0);
463: if (hHead) {
464: if ((pHead = (PNODE)LocalLock(hHead))==NULL)
465: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK);
466:
467: while ((pHead->ThreadWindow.hwndThreadWindow != hwnd) &&
468: (pHead->hNext != NULL)) {
469: hTmp = hHead;
470: hHead = pHead->hNext;
471: LocalUnlock(hTmp);
472:
473: if ((pHead = (PNODE) LocalLock(hHead))==NULL)
474: MessageBox(ghwndMain, "Failed in LocalLock!", "Error", MB_OK);
475: }
476: if (pHead->ThreadWindow.hwndThreadWindow == hwnd) {
477: pThreadBlockInfo = &pHead->ThreadWindow;
478: goto Thread_Found1;
479: } else {
480: //MessageBox(ghwndMain, "Trouble - Can't find the thread node!", "Error", MB_OK);
481: goto Thread_Out1;
482: }
483:
484: Thread_Found1:
485: pThreadBlockInfo->bKillThrd = TRUE;
486:
487: Thread_Out1:
488: LocalUnlock(hHead);
489:
490: } else {
491: //MessageBox(ghwndMain, "Can't GetWindowLong(ghwndMain,0) !", "Error", MB_OK);
492: }
493: return DefMDIChildProc(hwnd, message, wParam, lParam);
494: }
495:
496: case WM_DESTROY:
497:
498:
499: return 0L;
500:
501: default:
502: return DefMDIChildProc(hwnd, message, wParam, lParam);
503: }
504:
505: }
506:
507:
508: /***************************************************************************\
509: * About
510: *
511: * About dialog proc.
512: *
513: * History:
514: * 04-13-91 ??????? Created.
515:
516: * 09-09-91 PetrusW Rewrote.
517: \***************************************************************************/
518:
519: long About(
520: HWND hDlg,
521: UINT message,
522: DWORD wParam,
523: LONG lParam)
524: {
525: switch (message) {
526: case WM_INITDIALOG:
527: return TRUE;
528:
529: case WM_COMMAND:
530: if (wParam == IDOK)
531: EndDialog(hDlg, wParam);
532: break;
533: }
534:
535: return FALSE;
536:
537: lParam;
538: hDlg;
539: }
540:
541: long StartBounce(PTHREADBLOCKINFO pThreadBlockInfo)
542: {
543: if (!StartDemo(MM_BOUNCE, pThreadBlockInfo))
544: return(0);
545:
546: cmdDemo = MM_BOUNCE;
547: /* Here everythings been initialized, ThreadBlockINfo, etc*/
548: /* Now loop and call BounceProc to draw and move boxes*/
549:
550: /* NOTE NOTE, each thread MUST have its own message loop!*/
551:
552: while (TRUE) {
553:
554: if (!bKillMe && !pThreadBlockInfo->bKillThrd) {
555: BounceProc(pThreadBlockInfo);
556: } else {
557: break;
558: }
559: }
560:
561:
562: ExitThread(0);
563: if (!CloseHandle(pThreadBlockInfo->hThread))
564: MessageBox(ghwndMain, "Failed in CloseHandle!", "Error", MB_OK);
565: }
566:
567:
568: BOOL StartDemo(
569: int cmd,
570: PTHREADBLOCKINFO pThreadBlockInfo)
571: {
572:
573: // Initializing the rcClient for the bouncing box
574: // Better be initializing here for once CreateThread is called, this
575: // thread got the time slice; parent thread is preempted.
576: if (!GetClientRect(pThreadBlockInfo->hwndThreadWindow,
577: &pThreadBlockInfo->rcClient))
578: MessageBox(ghwndMain, "Failed in GetClientRect!", "Error", MB_OK);
579: pThreadBlockInfo->bKillThrd = FALSE;
580:
581: InitializeBoxes(FALSE, pThreadBlockInfo);
582:
583: return TRUE;
584: UNREFERENCED_PARAMETER(cmd);
585: }
586:
587:
588: void InitializeBoxes(
589: BOOL fVectorsOnly,
590: PTHREADBLOCKINFO pThreadBlockInfo)
591: {
592: int j;
593: int i;
594:
595: /*
596: * Initialize bounce arrays...
597: */
598: for (i = 0; i < COBJS; i++) {
599:
600: if (!fVectorsOnly) {
601: for (j = 0; j < CPOINTS; j++) {
602: pThreadBlockInfo->gab[i].apt[j].x = 0;
603: pThreadBlockInfo->gab[i].apt[j].y = 0;
604: }
605: pThreadBlockInfo->gab[i].iColor = 0;
606: }
607:
608: if (GetRandomVector() <= 3) {
609: if (GetRandomVector() >= 4) {
610: pThreadBlockInfo->gab[i].vx = 4;
611: } else {
612: pThreadBlockInfo->gab[i].vx = 1;
613: }
614:
615: pThreadBlockInfo->gab[i].vy = GetRandomVector();
616: } else {
617: if (GetRandomVector() >= 4) {
618: pThreadBlockInfo->gab[i].vy = 4;
619: } else {
620: pThreadBlockInfo->gab[i].vy = 1;
621: }
622:
623: pThreadBlockInfo->gab[i].vx = GetRandomVector();
624: }
625:
626: pThreadBlockInfo->gab[i].dx = pThreadBlockInfo->gab[i].vx;
627: pThreadBlockInfo->gab[i].dy = pThreadBlockInfo->gab[i].vy;
628:
629: pThreadBlockInfo->gab[i].ax = GetRandomVector() + 3;
630: pThreadBlockInfo->gab[i].ay = GetRandomVector() + 3;
631: }
632: }
633:
634: int GetRandomVector()
635: {
636: /*
637: * Returns a number between 1 and 6.
638: */
639: return (rand() % 6) + 1;
640: }
641:
642: void BounceProc( PTHREADBLOCKINFO pThreadBlockInfo)
643: {
644: int i;
645: LONG lCurrentThreadId;
646:
647: #ifdef LATER
648: // not erasing looks cool
649: /*
650: * Erase...
651: */
652: for (i = 0; i < COBJS; i++)
653: DrawBox(gab[i].apt[0].x, gab[i].apt[0].y, ghbrWhite);
654: #endif
655:
656:
657: /*
658: * Move, and bounce on wall
659: */
660: for (i = 0; i < COBJS; i++)
661: MoveBox((int *)&pThreadBlockInfo->gab[i].apt[0].x, (int *)&pThreadBlockInfo->gab[i].apt[0].y,
662: (int *)&pThreadBlockInfo->gab[i].dx, (int *)&pThreadBlockInfo->gab[i].dy,
663: (int *)&pThreadBlockInfo->gab[i].vx, (int *)&pThreadBlockInfo->gab[i].vy,
664: (int)pThreadBlockInfo->gab[i].ax, (int)pThreadBlockInfo->gab[i].ay, pThreadBlockInfo);
665:
666: /*
667: * Draw new...
668: */
669: for (i = 0; i < COBJS; i++) {
670: DrawBox(pThreadBlockInfo->gab[i].apt[0].x, pThreadBlockInfo->gab[i].apt[0].y,
671: gahbrColor[pThreadBlockInfo->gab[i].iColor++ % CCOLORS], pThreadBlockInfo);
672: }
673:
674: UNREFERENCED_PARAMETER(lCurrentThreadId);
675: }
676:
677: void DrawBox(
678: int x,
679: int y,
680: HBRUSH hbr,
681: PTHREADBLOCKINFO pThreadBlockInfo)
682: {
683: HBRUSH hbrOld;
684:
685: pThreadBlockInfo->hdcThreadWindow =
686: GetDC(pThreadBlockInfo->hwndThreadWindow);
687: if (pThreadBlockInfo->hdcThreadWindow) {
688: if ((hbrOld = SelectObject(pThreadBlockInfo->hdcThreadWindow, hbr))==0)
689: MessageBox(ghwndMain, "Failed in SelectObject!", "Error", MB_OK);
690: if (!BitBlt(pThreadBlockInfo->hdcThreadWindow, x, y, 20, 20, NULL, 0, 0, PATCOPY))
691: MessageBox(ghwndMain, "Failed in BitBlt!", "Error", MB_OK);
692: if (SelectObject(pThreadBlockInfo->hdcThreadWindow, hbrOld)==0)
693: MessageBox(ghwndMain, "Failed in SelectObject!", "Error", MB_OK);
694: if (ReleaseDC(pThreadBlockInfo->hwndThreadWindow, pThreadBlockInfo->hdcThreadWindow)==0)
695: MessageBox(ghwndMain, "Failed in ReleaseDC!", "Error", MB_OK);
696: } else {
697: MessageBox(ghwndMain, "Failed in GetDC!", "Error", MB_OK);
698: }
699: }
700:
701: void MoveBox(
702: int *px,
703: int *py,
704: int *pdx,
705: int *pdy,
706: int *pvx,
707: int *pvy,
708: int ax,
709: int ay,
710: PTHREADBLOCKINFO pThreadBlockInfo)
711: {
712:
713: (*pdx)--;
714: if (*pdx == 0) {
715: *px -= ax;
716: *pdx = *pvx;
717: } else if (*pdx == 3) {
718: *px += ax;
719: *pdx = *pvx;
720: }
721:
722: (*pdy)--;
723: if (*pdy == 0) {
724: *py -= ay;
725: *pdy = *pvy;
726: } else if (*pdy == 3) {
727: *py += ay;
728: *pdy = *pvy;
729: }
730:
731: if (*px < pThreadBlockInfo->rcClient.left) {
732: *px = pThreadBlockInfo->rcClient.left;
733:
734: if (*pvx >= 4)
735: *pvx -= 3;
736: else
737: *pvx += 3;
738:
739: *pdx = *pvx;
740: }
741:
742: if (*px > (pThreadBlockInfo->rcClient.right - 20)) {
743: *px = pThreadBlockInfo->rcClient.right - 20;
744:
745: if (*pvx >= 4)
746: *pvx -= 3;
747: else
748: *pvx += 3;
749:
750: *pdx = *pvx;
751: }
752:
753: if (*py < pThreadBlockInfo->rcClient.top) {
754: *py = pThreadBlockInfo->rcClient.top;
755:
756: if (*pvy >= 4)
757: *pvy -= 3;
758: else
759: *pvy += 3;
760:
761: *pdy = *pvy;
762: }
763:
764: if (*py > (pThreadBlockInfo->rcClient.bottom - 20)) {
765: *py = pThreadBlockInfo->rcClient.bottom - 20;
766:
767: if (*pvy >= 4)
768: *pvy -= 3;
769: else
770: *pvy += 3;
771:
772: *pdy = *pvy;
773: }
774: }
1.1.1.2 ! root 775:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.