source: trunk/mediafolder/test_progs/pmtst.c@ 2

Last change on this file since 2 was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

File size: 34.4 KB
Line 
1/*
2 * pmwvinfo.c (C) Chris Wohlgemuth 2001
3 *
4 * This helper shows the format of a wavefile in a dialog box
5 */
6/*
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21#define INCL_DOS
22#define INCL_DOSFILEMGR
23#define INCL_DOSERRORS
24#define INCL_WIN
25#define INCL_OS2MM
26#define INCL_MMIOOS2
27#define INCL_MCIOS2
28#define INCL_REXXSAA
29#include <os2.h>
30//#include <rexxsaa.h> /* needed for RexxStart() */
31#include <sys\types.h>
32#include <sys\stat.h>
33#include <stdio.h>
34#include <string.h>
35#include "os2me.h"
36#include "pmtst.h"
37
38
39//#define DEBUG
40
41#define CLASS_NAME "MY_WIN"
42#define SLIDERID 200
43
44char chrInstallDir[CCHMAXPATH];
45char logName[]="WaveInfo.log";
46
47int numArgs;
48char* params[4];
49
50 /* argv[0]: progname
51 * argv[1]: installdir of Audio/Data-CD-Creator
52 * argv[2]: wavefile
53 */
54
55HWND hwndNew;
56PFNWP oldProc;
57
58/*
59Sliderdata:
60
61USHORT sliderarmwidth
62USHORT sliderarmheight
63USHORT ptr position in sliderarm
64
65*/
66
67
68ULONG rexxFunc1(PSZ name, PLONG argc, RXSTRING argv[], PSZ queuename,PRXSTRING retstring, LONG next)
69{
70 PRXSTRING prx;
71char text[200];
72 DosBeep(1000, 100);
73 DosBeep(2000, 100);
74 DosBeep(3000, 100);
75 DosBeep(2000, 100);
76 DosBeep(1000, 100);
77 prx=&argv[0];
78 // prx=(RXSTRING*)(*prx);
79
80 sprintf(text, "%x %x %s %d ", argc, prx->strlength, prx->strptr,123);
81 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE);
82 prx++;
83 sprintf(text, "%x %x %s %d ", argc, prx->strlength, prx->strptr,123);
84 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE);
85
86#if 0
87 if(argc==1)
88 {
89
90 sprintf(text, "%s %x",argv[0].strptr, atol(argv[0].strptr));
91 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE);
92 }
93 else
94 {
95#endif
96
97#if 0
98 }
99 #endif
100 return 0;
101}
102
103#define SLIDERARMWITH 0
104#define SLIDERARMHEIGHT 2
105#define PTRPOSINSLARM 4
106#define USRESERVED1 6
107#define SLIDERCX 8 /* ULONG */
108#define SLIDERCY 12 /* ULONG */
109#define SLIDERX 16 /* ULONG */
110#define SLIDERY 20 /* ULONG */
111#define SLIDERARMPOS 24 /* LONG */
112#define SLDRAGGING 28 /* BOOL */
113
114#define SLADDBYTES 32
115
116//USHORT usWidth=10;
117
118//USHORT usHeight=10;
119//USHORT usPosInSl=0;
120//USHORT usReserved1;
121//ULONG ulSlidercx;
122//ULONG ulSlidercy;
123//LONG lPos=0;
124//BOOL bDragging=FALSE;
125
126//SWP swpSl;
127
128char text[200];
129
130#if 0
131MRESULT EXPENTRY newProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
132{
133
134 switch (msg)
135 {
136 case WM_CREATE:
137 {
138 PCREATESTRUCT pCreate=PVOIDFROMMP(mp2);
139
140 /* Initialize the slider data */
141 WinSetWindowUShort(hwnd, SLIDERARMWITH,20);
142 WinSetWindowUShort(hwnd, SLIDERARMHEIGHT,10);
143 /* Dimensions of slider. The slider active area is smaller than the window to
144 allow drawing of active state. */
145 WinSetWindowULong(hwnd, SLIDERCX,pCreate->cx-4);
146 WinSetWindowULong(hwnd, SLIDERCY,pCreate->cy-4);
147 WinSetWindowULong(hwnd, SLIDERX,2);
148 WinSetWindowULong(hwnd, SLIDERY,2);
149 WinSetWindowULong(hwnd, SLIDERARMPOS, 0);
150 WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
151 return (MRESULT)0;
152 }
153 case WM_SIZE:
154 WinSetWindowULong(hwnd, SLIDERCX, SHORT1FROMMP(mp2)-4);
155 WinSetWindowULong(hwnd, SLIDERCY, SHORT2FROMMP(mp2)-4);
156 WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
157 return (MRESULT)0;
158 case WM_BUTTON1DOWN:
159 {
160 SHORT x=SHORT1FROMMP( mp1);
161 SHORT y=SHORT2FROMMP( mp1);
162 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
163 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
164#if 0
165 sprintf(text,"%d %d %d %d", WinQueryWindowUShort(hwnd, SLIDERY) ,WinQueryWindowUShort(hwnd, SLIDERCY)
166,x, y);
167 WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text,
168 "",
169 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
170#endif
171 if(x<lPos+usWidth && y<WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
172 && y>WinQueryWindowUShort(hwnd, SLIDERY)) {
173 WinSetWindowUShort(hwnd, PTRPOSINSLARM, x-lPos);
174 }
175 WinSetFocus(HWND_DESKTOP, hwnd);
176 break;
177 }
178 case WM_FOCUSCHANGE:
179 {
180 HPS hps;
181 RECTL rcl;
182 POINTL ptl;
183
184 if(SHORT1FROMMP(mp2)) {
185 hps=WinGetPS(hwnd);
186 WinQueryWindowRect(hwnd, &rcl);
187 GpiSetLineType(hps, LINETYPE_DOT);
188 ptl.x=rcl.xLeft;
189 ptl.y=rcl.yBottom;
190 GpiMove(hps,&ptl);
191 ptl.x=rcl.xRight-1;
192 GpiLine(hps,&ptl);
193 ptl.y=rcl.yTop-1;
194 GpiLine(hps,&ptl);
195 ptl.x=rcl.xLeft;
196 GpiLine(hps,&ptl);
197 ptl.y=rcl.yBottom;
198 GpiLine(hps,&ptl);
199 WinReleasePS(hps);
200 }
201 else {
202 WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
203 }
204
205 break;
206 }
207 case WM_CHAR:
208 if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
209 /* We have the focus */
210 if((SHORT1FROMMP(mp1) & (KC_VIRTUALKEY))==(KC_VIRTUALKEY)) {
211 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
212 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
213 ULONG ulCx=WinQueryWindowULong(hwnd, SLIDERCX);
214
215 /*(KC_KEYUP|KC_PREVDOWN|KC_VIRTUALKEY)*/
216 switch(SHORT2FROMMP(mp2))
217 {
218 case VK_RIGHT:
219 if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
220 lPos+=2;
221 if(lPos>ulCx-usWidth)
222 lPos=ulCx-usWidth;
223 else {
224 WinPostMsg( hwnd,
225 SLM_SETSLIDERINFO,
226 MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
227 MPFROMLONG( (LONG) lPos ));
228 /* Post SLN_CHANGE notification */
229 WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
230 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
231 MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));
232 }
233 WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
234 }
235 return (MRESULT)TRUE;
236 case VK_LEFT:
237 if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
238 lPos-=2;
239 if(lPos<0) {
240 lPos=0;
241 }
242 else {
243 WinPostMsg( hwnd,
244 SLM_SETSLIDERINFO,
245 MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
246 MPFROMLONG( (LONG) lPos ));
247 /* Post SLN_CHANGE notification */
248 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_CONTROL,
249 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
250 MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));
251
252 }
253 WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
254 }
255 return (MRESULT)TRUE;
256 default:
257 break;
258 }
259 }
260 }
261 break;
262 case WM_BUTTON1MOTIONSTART:
263 {
264 SHORT x=SHORT1FROMMP( mp1);
265 SHORT y=SHORT2FROMMP( mp1);
266 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
267 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
268
269 if(x<lPos+usWidth && y<WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
270 && y>WinQueryWindowUShort(hwnd, SLIDERY)) {
271 WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
272 WinSetCapture(HWND_DESKTOP, hwnd);
273 }
274 break;
275 }
276 case WM_BUTTON1MOTIONEND:
277 if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
278 WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
279 WinSetCapture(HWND_DESKTOP, NULLHANDLE);
280 /* Post SLN_CHANGE notification */
281 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
282 MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));
283 }
284 break;
285 case SLM_SETSLIDERINFO:
286 switch(SHORT1FROMMP(mp1))
287 {
288 case SMA_SLIDERARMPOSITION:
289 /* SMA_RANGEVALUE only for now !! */
290 if(SHORT2FROMMP(mp1)==SMA_RANGEVALUE) {
291 WinSetWindowULong(hwnd, SLIDERARMPOS, LONGFROMMP(mp2));
292 WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
293 return (MRESULT)0;
294 }
295 break;
296 default:
297 break;
298 }
299 break;
300 case WM_MOUSEMOVE:
301 if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
302 HPS hps;
303 RECTL rcl, rcl2, rcl3;
304 LONG lTemp;
305 SHORT x=SHORT1FROMMP(mp1);
306 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
307 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
308
309 lTemp=lPos;
310
311 rcl.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
312 rcl.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
313 rcl.xRight=rcl.xLeft+WinQueryWindowULong(hwnd, SLIDERCX);
314 rcl.yTop=rcl.yBottom+WinQueryWindowULong(hwnd, SLIDERCY);
315
316 rcl2=rcl3=rcl;
317 rcl.xLeft=x-WinQueryWindowUShort(hwnd, PTRPOSINSLARM);
318 if(rcl.xLeft<rcl2.xLeft)/* Make sure we stop at the left border */
319 rcl.xLeft=rcl2.xLeft;
320
321 rcl.xRight=rcl.xLeft+usWidth;
322 if(rcl.xRight>rcl2.xRight)
323 {/* Make sure we stop at the right border */
324 rcl.xRight=rcl2.xRight;
325 rcl.xLeft=rcl.xRight-usWidth;
326 }
327 lPos=rcl.xLeft-WinQueryWindowULong(hwnd, SLIDERX);/* Save position zero based */
328 WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
329 if(lPos!=lTemp) {
330 hps=WinGetPS(hwnd);
331 /* Paint Background not necessary here */
332 /* Shaft */
333 /* Left part */
334 rcl3.xRight=rcl.xLeft;
335 WinFillRect(hps, &rcl3, CLR_GREEN);
336 /* Right part */
337 rcl3.xRight=rcl2.xRight;
338 rcl3.xLeft=rcl.xRight;
339 WinFillRect(hps, &rcl3, CLR_WHITE);
340
341 /* Paint Slider */
342 WinFillRect(hps,&rcl, CLR_BLUE);
343 WinDrawBorder(hps, &rcl, 2, 2, 0, 0 ,0x0400);
344
345 WinReleasePS(hps);
346 /* Post SLN_SLIDERTRACK notification */
347 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
348 MPFROMLONG(lPos));
349 }
350 }
351 break;
352 case WM_PAINT:
353 {
354 HPS hps, hps2;
355 RECTL rcl, rcl2, rcl3;
356 POINTL ptl;
357 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
358 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
359
360 WinQueryWindowRect(hwnd, &rcl);
361
362 /* Shaft */
363 rcl2.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
364 rcl2.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
365 rcl2.xRight=rcl2.xLeft+WinQueryWindowULong(hwnd, SLIDERCX)-1;
366 rcl2.yTop=rcl2.yBottom+WinQueryWindowULong(hwnd, SLIDERCY)-1;
367
368 /* Background */
369 hps2=WinGetPS(hwnd);
370 GpiExcludeClipRectangle(hps2,&rcl2);
371 WinFillRect(hps2, &rcl, CLR_PALEGRAY);
372 WinReleasePS(hps2);
373 rcl2.yTop+=1;
374 rcl2.xRight+=1;
375
376 hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
377 /* Focus */
378 if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
379 GpiSetLineType(hps, LINETYPE_DOT);
380 ptl.x=rcl.xLeft;
381 ptl.y=rcl.yBottom;
382 GpiMove(hps,&ptl);
383 ptl.x=rcl.xRight-1;
384 GpiLine(hps,&ptl);
385 ptl.y=rcl.yTop-1;
386 GpiLine(hps,&ptl);
387 ptl.x=rcl.xLeft;
388 GpiLine(hps,&ptl);
389 ptl.y=rcl.yBottom;
390 GpiLine(hps,&ptl);
391 }
392
393 rcl3=rcl=rcl2;
394
395 /* Arm pos */
396 rcl2.xLeft+=lPos;
397 /* Arm size */
398 rcl2.xRight=rcl2.xLeft+usWidth;
399
400 /* Shaft */
401 /* Left part */
402 rcl3.xRight=rcl2.xLeft;
403 WinFillRect(hps, &rcl3, CLR_GREEN);
404
405 /* Right part */
406 rcl3.xRight=rcl.xRight;
407 rcl3.xLeft=rcl2.xRight;
408 WinFillRect(hps, &rcl3, CLR_WHITE);
409
410 WinFillRect(hps,&rcl2, CLR_BLUE);
411 WinDrawBorder(hps, &rcl2, 2, 2, 0, 0 ,0x0400);
412
413 WinEndPaint(hps);
414 return (MRESULT)0;
415 }
416 break;
417 default:
418 break;
419 }
420
421 return WinDefWindowProc(hwnd, msg, mp1, mp2);
422}
423#endif
424
425
426
427
428
429
430
431
432
433
434#define USERSLIDER 1
435
436MRESULT EXPENTRY newProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
437{
438
439 switch (msg)
440 {
441 case WM_CREATE:
442 {
443 PCREATESTRUCT pCreate=PVOIDFROMMP(mp2);
444
445 /* Initialize the slider data */
446 WinSetWindowUShort(hwnd, SLIDERARMWITH,20);
447 WinSetWindowUShort(hwnd, SLIDERARMHEIGHT,10);
448 /* Dimensions of slider. The slider active area is smaller than the window to
449 allow drawing of active state. */
450 WinSetWindowULong(hwnd, SLIDERCX,pCreate->cx-4);
451 WinSetWindowULong(hwnd, SLIDERCY,pCreate->cy-4);
452 WinSetWindowULong(hwnd, SLIDERX,2);
453 WinSetWindowULong(hwnd, SLIDERY,2);
454 WinSetWindowULong(hwnd, SLIDERARMPOS, 0);
455 WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
456 return (MRESULT)0;
457 }
458 case WM_SIZE:
459 WinSetWindowULong(hwnd, SLIDERCX, SHORT1FROMMP(mp2)-4);
460 WinSetWindowULong(hwnd, SLIDERCY, SHORT2FROMMP(mp2)-4);
461 WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
462 return (MRESULT)0;
463 case WM_BUTTON1DOWN:
464 {
465 SHORT x=SHORT1FROMMP( mp1);
466 SHORT y=SHORT2FROMMP( mp1);
467 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
468 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
469
470 if(x<lPos+usWidth && y<WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
471 && y>WinQueryWindowUShort(hwnd, SLIDERY)) {
472 WinSetWindowUShort(hwnd, PTRPOSINSLARM, x-lPos);
473 }
474 WinSetFocus(HWND_DESKTOP, hwnd);
475 break;
476 }
477 case WM_FOCUSCHANGE:
478 {
479 HPS hps;
480 RECTL rcl;
481 POINTL ptl;
482
483 if(SHORT1FROMMP(mp2)) {
484 hps=WinGetPS(hwnd);
485 WinQueryWindowRect(hwnd, &rcl);
486 GpiSetLineType(hps, LINETYPE_DOT);
487 ptl.x=rcl.xLeft;
488 ptl.y=rcl.yBottom;
489 GpiMove(hps,&ptl);
490 ptl.x=rcl.xRight-1;
491 GpiLine(hps,&ptl);
492 ptl.y=rcl.yTop-1;
493 GpiLine(hps,&ptl);
494 ptl.x=rcl.xLeft;
495 GpiLine(hps,&ptl);
496 ptl.y=rcl.yBottom;
497 GpiLine(hps,&ptl);
498 WinReleasePS(hps);
499 }
500 else {
501 WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
502 }
503
504 break;
505 }
506 case WM_CHAR:
507 if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
508 /* We have the focus */
509 if((SHORT1FROMMP(mp1) & (KC_VIRTUALKEY))==(KC_VIRTUALKEY)) {
510 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
511 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
512 ULONG ulCx=WinQueryWindowULong(hwnd, SLIDERCX);
513#if 0
514 FILE* file;
515 file=fopen("d:\\md.log","a");
516 fprintf(file,"0x%x 0x%x \n",SHORT1FROMMP(mp1),SHORT2FROMMP(mp1) );
517 fclose(file);
518#endif
519 /*(KC_KEYUP|KC_PREVDOWN|KC_VIRTUALKEY)*/
520 switch(SHORT2FROMMP(mp2))
521 {
522 case VK_RIGHT:
523
524 if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
525 lPos+=2;
526 if(lPos>ulCx-usWidth)
527 lPos=ulCx-usWidth;
528 else {
529 WinPostMsg( hwnd,
530 SLM_SETSLIDERINFO,
531 MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
532 MPFROMLONG( (LONG) lPos ));
533 if(SHORT1FROMMP(mp1) & KC_LONEKEY)
534 /* Post SLN_CHANGE notification */
535 WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
536 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
537 MPFROMLONG(lPos));
538 else
539 /* Post SLN_SLIDERTRACK notification */
540 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
541 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
542 MPFROMLONG(lPos));
543
544 }
545 WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
546 }
547 return (MRESULT)TRUE;
548 case VK_LEFT:
549 if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
550 lPos-=2;
551 if(lPos<0) {
552 lPos=0;
553 }
554 else {
555 WinPostMsg( hwnd,
556 SLM_SETSLIDERINFO,
557 MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
558 MPFROMLONG( (LONG) lPos ));
559 /* Post SLN_CHANGE notification */
560 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_CONTROL,
561 MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
562 MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));
563
564 }
565 WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
566 }
567 return (MRESULT)TRUE;
568 default:
569 break;
570 }
571 }
572 }
573 break;
574 case WM_BUTTON1MOTIONSTART:
575 {
576 SHORT x=SHORT1FROMMP( mp1);
577 SHORT y=SHORT2FROMMP( mp1);
578 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
579 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
580
581 if(x<lPos+usWidth && y<WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
582 && y>WinQueryWindowUShort(hwnd, SLIDERY)) {
583 WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
584 WinSetCapture(HWND_DESKTOP, hwnd);
585 }
586 break;
587 }
588 case WM_BUTTON1MOTIONEND:
589 if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
590 WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
591 WinSetCapture(HWND_DESKTOP, NULLHANDLE);
592 /* Post SLN_CHANGE notification */
593 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
594 MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));
595 }
596 break;
597 case SLM_SETSLIDERINFO:
598 switch(SHORT1FROMMP(mp1))
599 {
600 case SMA_SLIDERARMPOSITION:
601 /* SMA_RANGEVALUE only for now !! */
602 if(SHORT2FROMMP(mp1)==SMA_RANGEVALUE) {
603 WinSetWindowULong(hwnd, SLIDERARMPOS, LONGFROMMP(mp2));
604 WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
605 return (MRESULT)0;
606 }
607 break;
608 default:
609 break;
610 }
611 break;
612 case WM_MOUSEMOVE:
613 if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
614 HPS hps;
615 RECTL rcl, rcl2, rcl3;
616 LONG lTemp;
617 SHORT x=SHORT1FROMMP(mp1);
618 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
619 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
620
621 lTemp=lPos;
622
623 rcl.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
624 rcl.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
625 rcl.xRight=rcl.xLeft+WinQueryWindowULong(hwnd, SLIDERCX);
626 rcl.yTop=rcl.yBottom+WinQueryWindowULong(hwnd, SLIDERCY);
627
628 rcl2=rcl3=rcl;
629 rcl.xLeft=x-WinQueryWindowUShort(hwnd, PTRPOSINSLARM);
630 if(rcl.xLeft<rcl2.xLeft)/* Make sure we stop at the left border */
631 rcl.xLeft=rcl2.xLeft;
632
633 rcl.xRight=rcl.xLeft+usWidth;
634 if(rcl.xRight>rcl2.xRight)
635 {/* Make sure we stop at the right border */
636 rcl.xRight=rcl2.xRight;
637 rcl.xLeft=rcl.xRight-usWidth;
638 }
639 lPos=rcl.xLeft-WinQueryWindowULong(hwnd, SLIDERX);/* Save position zero based */
640 WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
641 if(lPos!=lTemp) {
642 BOOL rc;
643
644 hps=WinGetPS(hwnd);
645 /* Paint Background not necessary here */
646
647 /* Shaft */
648 /* Left part */
649 rcl3.xRight=rcl.xLeft;
650 rc=FALSE;
651 if(USERSLIDER) {
652 OWNERITEM oi={0};
653 oi.hwnd=hwnd;
654 oi.hps=hps;
655 oi.fsState=SLS_OWNERDRAW;/* More to come */
656 oi.rclItem=rcl3;
657 oi.idItem=SDA_SLIDERSHAFT;
658 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
659 MPFROMP(&oi) );
660 }
661 if(!rc)
662 WinFillRect(hps, &rcl3, CLR_GREEN);
663
664 /* Right part */
665 rcl3.xRight=rcl2.xRight;
666 rcl3.xLeft=rcl.xRight;
667 rc=FALSE;
668 if(USERSLIDER) {
669 OWNERITEM oi={0};
670 oi.hwnd=hwnd;
671 oi.hps=hps;
672 oi.fsState=SLS_OWNERDRAW;/* More to come */
673 oi.rclItem=rcl3;
674 oi.idItem=SDA_SLIDERSHAFT;
675 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
676 MPFROMP(&oi) );
677 }
678 if(!rc)
679 WinFillRect(hps, &rcl3, CLR_WHITE);
680
681 /* Paint Slider */
682 rc=FALSE;
683 if(USERSLIDER) {
684 OWNERITEM oi={0};
685 oi.hwnd=hwnd;
686 oi.hps=hps;
687 oi.fsState=SLS_OWNERDRAW;/* More to come */
688 oi.rclItem=rcl;
689 oi.idItem=SDA_SLIDERARM;
690 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
691 MPFROMP(&oi) );
692 }
693 if(!rc)
694 {
695 WinFillRect(hps,&rcl, CLR_BLUE);
696 WinDrawBorder(hps, &rcl, 2, 2, 0, 0 ,0x0400);
697 }
698
699 WinReleasePS(hps);
700
701 /* Post SLN_SLIDERTRACK notification */
702 WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
703 MPFROMLONG(lPos));
704 }
705 }
706 break;
707 case WM_PAINT:
708 {
709 HPS hps, hps2;
710 RECTL rcl, rcl2, rcl3;
711 POINTL ptl;
712 LONG lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
713 USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
714 BOOL rc;
715
716 WinQueryWindowRect(hwnd, &rcl);
717
718 /* Shaft */
719 rcl2.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
720 rcl2.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
721 rcl2.xRight=rcl2.xLeft+WinQueryWindowULong(hwnd, SLIDERCX)-1;
722 rcl2.yTop=rcl2.yBottom+WinQueryWindowULong(hwnd, SLIDERCY)-1;
723
724 /* Background */
725 hps2=WinGetPS(hwnd);
726 GpiExcludeClipRectangle(hps2,&rcl2);
727 WinFillRect(hps2, &rcl, CLR_PALEGRAY);
728 WinReleasePS(hps2);
729 rcl2.yTop+=1;
730 rcl2.xRight+=1;
731
732 hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
733 /* Focus */
734 if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
735 GpiSetLineType(hps, LINETYPE_DOT);
736 ptl.x=rcl.xLeft;
737 ptl.y=rcl.yBottom;
738 GpiMove(hps,&ptl);
739 ptl.x=rcl.xRight-1;
740 GpiLine(hps,&ptl);
741 ptl.y=rcl.yTop-1;
742 GpiLine(hps,&ptl);
743 ptl.x=rcl.xLeft;
744 GpiLine(hps,&ptl);
745 ptl.y=rcl.yBottom;
746 GpiLine(hps,&ptl);
747 }
748
749 rcl3=rcl=rcl2;
750
751 /* Arm pos */
752 rcl2.xLeft+=lPos;
753 /* Arm size */
754 rcl2.xRight=rcl2.xLeft+usWidth;
755
756 /* Shaft */
757 /* Left part */
758 rcl3.xRight=rcl2.xLeft;
759 rc=FALSE;
760 if(USERSLIDER) {
761 OWNERITEM oi={0};
762 oi.hwnd=hwnd;
763 oi.hps=hps;
764 oi.fsState=SLS_OWNERDRAW;/* More to come */
765 oi.rclItem=rcl3;
766 oi.idItem=SDA_SLIDERSHAFT;
767 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
768 MPFROMP(&oi) );
769 }
770 if(!rc)
771 WinFillRect(hps, &rcl3, CLR_GREEN);
772
773 /* Right part */
774 rcl3.xRight=rcl.xRight;
775 rcl3.xLeft=rcl2.xRight;
776 rc=FALSE;
777 if(USERSLIDER) {
778 OWNERITEM oi={0};
779 oi.hwnd=hwnd;
780 oi.hps=hps;
781 oi.fsState=SLS_OWNERDRAW;/* More to come */
782 oi.rclItem=rcl3;
783 oi.idItem=SDA_SLIDERSHAFT;
784 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
785 MPFROMP(&oi) );
786 }
787 if(!rc)
788 WinFillRect(hps, &rcl3, CLR_WHITE);
789
790 rc=FALSE;
791 if(USERSLIDER) {
792 OWNERITEM oi={0};
793 oi.hwnd=hwnd;
794 oi.hps=hps;
795 oi.fsState=SLS_OWNERDRAW;/* More to come */
796 oi.rclItem=rcl2;
797 oi.idItem=SDA_SLIDERARM;
798 rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
799 MPFROMP(&oi) );
800 }
801 if(!rc)
802 {
803 WinFillRect(hps,&rcl2, CLR_BLUE);
804 WinDrawBorder(hps, &rcl2, 2, 2, 0, 0 ,0x0400);
805 }
806
807 WinEndPaint(hps);
808 return (MRESULT)0;
809 }
810 break;
811 default:
812 break;
813 }
814
815 return WinDefWindowProc(hwnd, msg, mp1, mp2);
816}
817
818
819MRESULT drawSlider(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, USHORT id)
820{
821 POWNERITEM poi;
822
823 RECTL rcl;
824 POINTL ptl= {0};
825
826 poi=(POWNERITEM)PVOIDFROMMP(mp2);
827
828 switch(poi->idItem)
829 {
830 case SDA_SLIDERARM:
831
832 WinFillRect(poi->hps,&poi->rclItem, CLR_RED);
833 WinDrawBorder(poi->hps,&poi->rclItem, 2, 2, 0, 0 ,0x0400);
834
835 return (MRESULT) TRUE;
836 break;
837 case SDA_BACKGROUND:
838 {
839 HPS hps;
840
841 WinFillRect(poi->hps,&poi->rclItem, CLR_WHITE);
842
843 return (MRESULT) TRUE;
844 }
845 case SDA_SLIDERSHAFT:
846 {
847 HPS hps;
848 RECTL rcl;
849 MRESULT mr;
850
851 WinFillRect(poi->hps,&poi->rclItem, CLR_BLUE);
852
853 return (MRESULT)TRUE;
854 }
855 default:
856 return (MRESULT)TRUE;
857 }
858
859 /* Done */
860 return (MRESULT)TRUE;
861}
862
863
864/* This Proc handles the on-the-fly data CD writing */
865MRESULT EXPENTRY waveinfoStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
866{
867 char text[CCHMAXPATH*2 +10];
868 char title[CCHMAXPATH];
869 SWCNTRL swctl;
870 PID pid;
871 int a;
872
873
874 switch (msg)
875 {
876 case WM_DRAWITEM:
877 switch(SHORT1FROMMP(mp1))
878 {
879 case SLIDERID:
880 return drawSlider(hwnd, msg, mp1, mp2, SHORT1FROMMP(mp1));
881 default:
882 break;
883 }
884 break;
885 case WM_INITDLG:
886 /* Add switch entry */
887 memset(&swctl,0,sizeof(swctl));
888 WinQueryWindowProcess(hwnd,&pid,NULL);
889 swctl.hwnd=hwnd;
890 swctl.uchVisibility=SWL_VISIBLE;
891 swctl.idProcess=pid;
892 swctl.bProgType=PROG_DEFAULT;
893 swctl.fbJump=SWL_JUMPABLE;
894 WinAddSwitchEntry(&swctl);
895
896#if 0
897 WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "",
898 "",
899 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
900#endif
901 // oldProc=WinSubclassWindow(WinWindowFromID(hwnd, IDST_TEXT), newProc);
902 hwndNew=WinCreateWindow(hwnd, CLASS_NAME, "Title", WS_VISIBLE |WS_TABSTOP, 10,50, SLIDERID, 40,
903 hwnd, HWND_TOP, SLIDERID, NULLHANDLE, NULLHANDLE);
904 WinShowWindow(hwnd, TRUE);
905 // WinQueryWindowPos(hwndNew,&swpSl);
906 return (MRESULT) TRUE;
907 /* WM_APPTERMINATENOTIFY messages are sent from the helper programs e.g. format checker. */
908 case WM_CLOSE:
909 WinDismissDlg(hwnd,0);
910 return FALSE;
911 case WM_CONTROL:
912 {
913 switch(SHORT2FROMMP(mp1))
914 {
915 case SLN_SLIDERTRACK:
916 {
917 switch(SHORT1FROMMP(mp1))
918 {
919 case SLIDERID:
920 DosBeep(5000, 10);
921 break;
922 default:
923 break;
924 }/* switch */
925 return (MRESULT) 0;
926 break;
927 }
928 case SLN_CHANGE:
929 {
930 switch(SHORT1FROMMP(mp1))
931 {
932 case SLIDERID:
933 DosBeep(500, 100);
934 break;
935 default:
936 break;
937 }/* switch */
938 return (MRESULT)TRUE;
939 }
940 default:
941 break;
942 }/* switch */
943 break;
944 }/* WM_CONTROL */
945
946 case WM_COMMAND:
947 switch(SHORT1FROMMP(mp1))
948 {
949 case DID_OK:
950 /* User pressed the OK button */
951 WinPostMsg(hwnd,WM_CLOSE,0,0);
952 break;
953 case IDPB_RIGHT:
954 WinPostMsg( WinWindowFromID(hwnd, SLIDERID),
955 SLM_SETSLIDERINFO,
956 MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
957 MPFROMLONG( (LONG) 70 ));
958
959 break;
960 case IDPB_LEFT:
961 WinPostMsg( WinWindowFromID(hwnd, SLIDERID),
962 SLM_SETSLIDERINFO,
963 MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
964 MPFROMLONG( (LONG) 20 ));
965
966 break;
967 case IDPB_SIZE:
968 {
969 SWP swp;
970 RXSTRING arg[2]; /* argument string for REXX */
971 RXSTRING rexxretval; /* return value from REXX */
972 APIRET rc; /* return code from REXX */
973 SHORT rexxrc = 0; /* return code from function */
974 char chrThis[20];
975 char chrHwnd[20];
976
977 char *str = "These words will be swapped"; /* text to swap */
978
979
980 RexxRegisterFunctionExe("CWRXFunc1", (PFN)rexxFunc1);
981
982
983 sprintf(chrThis, "%d",123);
984 sprintf(chrHwnd, "%d", WinQueryWindow(hwnd,QW_PARENT));
985
986 /* By setting the strlength of the output RXSTRING to zero, we */
987 /* force the interpreter to allocate memory and return it to us. */
988 /* We could provide a buffer for the interpreter to use instead. */
989 rexxretval.strlength = 0L; /* initialize return to empty*/
990
991 MAKERXSTRING(arg[0], chrHwnd, strlen(chrHwnd));/* create input argument */
992 MAKERXSTRING(arg[1], chrThis, strlen(chrThis));/* create input argument */
993
994 /* Here we call the interpreter. We don't really need to use */
995 /* all the casts in this call; they just help illustrate */
996 /* the data types used. */
997 rc=RexxStart((LONG) 2, /* number of arguments */
998 (PRXSTRING) &arg, /* array of arguments */
999 (PSZ) "G:\\Projects_working\\mmclasses-0.3.0\\testfunc.cwr",/* name of REXX file */
1000 (PRXSTRING) 0, /* No INSTORE used */
1001 (PSZ) "CWRXX", /* Command env. name */
1002 (LONG) RXSUBROUTINE, /* Code for how invoked */
1003 (PRXSYSEXIT) 0, /* No EXITs on this call */
1004 (PSHORT) &rexxrc, /* Rexx program output */
1005 (PRXSTRING) &rexxretval ); /* Rexx program output */
1006
1007 sprintf(text,"rc: %d, function return code: %d, %s ",
1008 rc, (int) rexxrc, rexxretval.strptr);
1009
1010 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE);
1011
1012 DosFreeMem(rexxretval.strptr); /* Release storage
1013 given to us by REXX. */
1014
1015
1016
1017 // WinQueryWindowPos(hwndNew,&swp);
1018 // WinSetWindowPos(hwndNew, NULLHANDLE, 0, 0, swp.cx-30, swp.cy+10,SWP_SIZE);
1019 break;
1020 }
1021 default:
1022 break;
1023 }
1024 return (MRESULT) FALSE;
1025 default:
1026 break;
1027 }/* switch */
1028
1029 return WinDefDlgProc( hwnd, msg, mp1, mp2);
1030}
1031
1032int main (int argc, char *argv[])
1033{
1034 HAB hab;
1035 HMQ hmq;
1036 QMSG qmsg;
1037 char text[CCHMAXPATH];
1038 char title[CCHMAXPATH];
1039 short a;
1040 HWND hwndClient;
1041 ULONG result;
1042 ULONG rc;
1043
1044 /* Create a copy of the args */
1045 /* argv[0]: progname
1046 argv[1]: installdir
1047 argv[2]: 0: query wave, 1: query mp3
1048 argv[3]: wavefile
1049 */
1050 numArgs=argc;
1051
1052 hab=WinInitialize(0);
1053 if(hab) {
1054 hmq=WinCreateMsgQueue(hab,0);
1055 if(hmq) {
1056 /* Save installation directory */
1057
1058 /* Get our ressource dll */
1059
1060 WinRegisterClass(hab, CLASS_NAME, newProc,0, SLADDBYTES);
1061 if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, waveinfoStatusDialogProc, NULLHANDLE, IDDL_PMTST, 0) == DID_ERROR )
1062 {
1063
1064 WinDestroyMsgQueue( hmq );
1065 WinTerminate( hab );
1066 DosBeep(100,600);
1067 return( 1 );
1068 }
1069
1070 WinDestroyMsgQueue(hmq);
1071 }
1072 WinTerminate(hab);
1073 }
1074 return 0;
1075}
1076
1077
1078
1079
1080
1081
1082
1083
1084
Note: See TracBrowser for help on using the repository browser.