1 | /*
|
---|
2 | * Volume.exe (C) Chris Wohlgemuth 2003
|
---|
3 | *
|
---|
4 | */
|
---|
5 | /*
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | * any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; see the file COPYING. If not, write to
|
---|
18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | */
|
---|
20 | /*
|
---|
21 | * If you need another license for your project/product (commercial,
|
---|
22 | * noncommercial, whatever) contact me at
|
---|
23 | *
|
---|
24 | * http://www.os2world.com/cdwriting
|
---|
25 | * http://www.geocities.com/SiliconValley/Sector/5785/
|
---|
26 | *
|
---|
27 | */
|
---|
28 |
|
---|
29 | #define INCL_DOS
|
---|
30 | #define INCL_GPI
|
---|
31 | #define INCL_DOSFILEMGR
|
---|
32 | #define INCL_DOSERRORS
|
---|
33 | #define INCL_WIN
|
---|
34 | #define INCL_OS2MM
|
---|
35 | #define INCL_MMIOOS2
|
---|
36 | #define INCL_MCIOS2
|
---|
37 | #define INCL_SECONDARYWINDOW
|
---|
38 | #define INCL_GRAPHICBUTTON
|
---|
39 | #include <os2.h>
|
---|
40 | #include <sw.h>
|
---|
41 | #include <sys\types.h>
|
---|
42 | #include <sys\stat.h>
|
---|
43 | #include <stdio.h>
|
---|
44 | #include <string.h>
|
---|
45 | #include <stdlib.h>
|
---|
46 | #include "os2me.h"
|
---|
47 | #include "common.h"
|
---|
48 | #include "mmres.h"
|
---|
49 | #include "mmprogs_defaults.h"
|
---|
50 |
|
---|
51 | #include "sys_funcs.h"
|
---|
52 |
|
---|
53 | #define ACTION_SETVOLUME 1L
|
---|
54 | #define ACTION_QUERYVOLUME 2L
|
---|
55 |
|
---|
56 | //#define INI_NAME_APP "volume"
|
---|
57 |
|
---|
58 | #define INI_TBVISIBLE_KEY "tbVisible"
|
---|
59 | #define INI_NAME_COLOR "color"
|
---|
60 | #define INI_BTNBGCLR_KEY "btnbg"
|
---|
61 | #define INI_BTNFGCLR_KEY "btnfg"
|
---|
62 |
|
---|
63 | #if 0
|
---|
64 | #define INI_BGCLR_KEY "bg"
|
---|
65 | #define INI_FGCLR_KEY "fg"
|
---|
66 | #define INI_ACTIVETBBGCLR_KEY "activetbbg"
|
---|
67 | #define INI_INACTIVETBBGCLR_KEY "inactivetbbg"
|
---|
68 | #define INI_ACTIVETBFGCLR_KEY "activetbfg"
|
---|
69 | #define INI_INACTIVETBFGCLR_KEY "inactivetbfg"
|
---|
70 | #endif
|
---|
71 | char logName[]="volume.log";
|
---|
72 |
|
---|
73 | BOOL bHaveWindowPos=FALSE;
|
---|
74 |
|
---|
75 | BOOL bMute=FALSE;
|
---|
76 | HMODULE RESSOURCEHANDLE=0;
|
---|
77 | int bTBVisible=0;
|
---|
78 | ULONG ulTBCy;
|
---|
79 |
|
---|
80 | HWND hwndThread;
|
---|
81 |
|
---|
82 | char* params[5];
|
---|
83 | char chrIniFile[CCHMAXPATH];
|
---|
84 |
|
---|
85 | //ULONG cwQueryOSRelease();
|
---|
86 | void pmUsage();
|
---|
87 | BOOL IniSaveWindowPos(char * iniFile, char* chrApp, char *chrKey, HWND hwnd);
|
---|
88 | BOOL IniRestoreWindowPos(char * iniFile, char* chrApp, char *chrKey, HWND hwnd);
|
---|
89 | BOOL IniSaveInt(char * iniFile, char* chrApp, char *chrKey, int theInt);
|
---|
90 | int IniRestoreInt(char * iniFile, char* chrApp, char *chrKey, int defaultInt);
|
---|
91 | BOOL IniSaveData(char * iniFile, char* chrApp, char *chrKey, void* theData, ULONG ulSize);
|
---|
92 | BOOL IniRestoreData(char * iniFile, char* chrApp, char *chrKey, void * theData, ULONG* ulMaxSize);
|
---|
93 | BOOL IniSaveWindowClrs(char * chrIniFile, char* chrApp , HWND hwnd);
|
---|
94 | BOOL IniRestoreWindowClrs(char * chrIniFile, char* chrApp , HWND hwnd);
|
---|
95 | BOOL HlpBuildMMProgIniFileName(char* chrProgname, char * chrBuffer, ULONG ulBufferSize);
|
---|
96 | HMODULE queryResModuleHandle(char *chrExePath);
|
---|
97 | void freeResHandle(void);
|
---|
98 |
|
---|
99 | ULONG queryMasterVolume(void)
|
---|
100 | {
|
---|
101 | char chrCommand[50];
|
---|
102 | char retMsg[20];
|
---|
103 | ULONG rc;
|
---|
104 |
|
---|
105 | strcpy(chrCommand, "MASTERAUDIO QUERY VOLUME WAIT");
|
---|
106 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
107 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
108 | /* Problem with MCI. */
|
---|
109 | return 75;
|
---|
110 | }
|
---|
111 | else
|
---|
112 | return atoi(retMsg);
|
---|
113 | }
|
---|
114 |
|
---|
115 | void setMasterVolume(HWND hwnd, SHORT sVolumeLevel)
|
---|
116 | {
|
---|
117 | char chrCommand[500];
|
---|
118 | char retMsg[20];
|
---|
119 | ULONG rc;
|
---|
120 |
|
---|
121 | WinPostMsg(hwndThread, WM_APPTERMINATENOTIFY, MPFROMLONG(ACTION_SETVOLUME), MPFROMSHORT(sVolumeLevel));
|
---|
122 | return;
|
---|
123 |
|
---|
124 | sprintf(chrCommand, "MASTERAUDIO volume %d wait ", sVolumeLevel);
|
---|
125 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwnd, 2);
|
---|
126 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
127 | /* Problem with MCI. */
|
---|
128 | mciGetErrorString(rc, chrCommand,sizeof(chrCommand));
|
---|
129 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrCommand, "", 1234, MB_MOVEABLE);
|
---|
130 | //DosBeep(100, 30);
|
---|
131 | return ;
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 | /* Masteraudio does not support NOTIFY so use a thread to prevent PM freeze */
|
---|
136 | MRESULT EXPENTRY volumeObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
137 | {
|
---|
138 | switch(msg)
|
---|
139 | {
|
---|
140 | case WM_APPTERMINATENOTIFY:
|
---|
141 | {
|
---|
142 | char chrCommand[500];
|
---|
143 | char retMsg[20];
|
---|
144 | ULONG rc;
|
---|
145 |
|
---|
146 | /* This queue is blocked until the query is over. This is the reason we've chosen an object window. */
|
---|
147 | switch(LONGFROMMP(mp1))
|
---|
148 | {
|
---|
149 | case ACTION_SETVOLUME:
|
---|
150 | {
|
---|
151 |
|
---|
152 | #if 0
|
---|
153 | ULONG mastervolume; /* Set to master volumepercentage
|
---|
154 | percentage by this example */
|
---|
155 |
|
---|
156 | USHORT usDeviceID=0;
|
---|
157 | MCI_MASTERAUDIO_PARMS masteraudioparms;
|
---|
158 | MCI_OPEN_PARMS openParms;
|
---|
159 |
|
---|
160 |
|
---|
161 | memset(&openParms,0, sizeof(openParms));
|
---|
162 | openParms.pszDeviceType="Masteraudio";
|
---|
163 |
|
---|
164 | rc=mciSendCommand(0, /* Device */
|
---|
165 | MCI_OPEN, /* Master audio message */
|
---|
166 | MCI_WAIT ,
|
---|
167 | /* Flags for this message */
|
---|
168 | (PVOID) &openParms, /* Data structure */
|
---|
169 | 0); /* User parm */
|
---|
170 |
|
---|
171 | mciGetErrorString(rc,chrCommand, sizeof(chrCommand));
|
---|
172 | //sprintf(chrCommand, "%x", rc);
|
---|
173 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrCommand, "", 1234, MB_MOVEABLE);
|
---|
174 | DosBeep(5000, 10);
|
---|
175 | usDeviceID=openParms.usDeviceID;
|
---|
176 | memset(&masteraudioparms,0, sizeof(masteraudioparms));
|
---|
177 | masteraudioparms.ulMasterVolume=32;
|
---|
178 | /* Get current system master
|
---|
179 | volume setting */
|
---|
180 |
|
---|
181 | mciSendCommand(usDeviceID, /* Device */
|
---|
182 | MCI_MASTERAUDIO, /* Master audio message */
|
---|
183 | MCI_WAIT | MCI_MASTERVOL,
|
---|
184 | /* Flags for this message */
|
---|
185 | (PVOID) &masteraudioparms, /* Data structure */
|
---|
186 | 0); /* User parm */
|
---|
187 |
|
---|
188 | /* Get current system master
|
---|
189 | volume setting */
|
---|
190 |
|
---|
191 | mciSendCommand(usDeviceID, /* Device */
|
---|
192 | MCI_MASTERAUDIO, /* Master audio message */
|
---|
193 | MCI_WAIT | MCI_QUERYCURRENTSETTING | MCI_MASTERVOL,
|
---|
194 | /* Flags for this message */
|
---|
195 | (PVOID) &masteraudioparms, /* Data structure */
|
---|
196 | 0); /* User parm */
|
---|
197 |
|
---|
198 | mastervolume = masteraudioparms.ulReturn;
|
---|
199 | DosBeep(500, 10);
|
---|
200 | #endif
|
---|
201 |
|
---|
202 | sprintf(chrCommand, "MASTERAUDIO VOLUME %d WAIT", SHORT1FROMMP(mp2));
|
---|
203 | // sprintf(chrCommand, "MASTERAUDIO VOLUME 39", SHORT1FROMMP(mp2));
|
---|
204 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
205 | //DosBeep(5000, 20);
|
---|
206 |
|
---|
207 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
208 | /* Problem with MCI. */
|
---|
209 | // DosBeep(1000, 10);
|
---|
210 | break;
|
---|
211 | }
|
---|
212 |
|
---|
213 | break;
|
---|
214 | }
|
---|
215 | case ACTION_QUERYVOLUME:
|
---|
216 | break;
|
---|
217 | default:
|
---|
218 | break;
|
---|
219 | }
|
---|
220 | return FALSE;
|
---|
221 | }
|
---|
222 | case WM_CLOSE:
|
---|
223 | WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
|
---|
224 | default:
|
---|
225 | break;
|
---|
226 | }
|
---|
227 | return WinDefWindowProc( hwnd, msg, mp1, mp2);
|
---|
228 | }
|
---|
229 |
|
---|
230 | void volumeThreadFunc (void *arg)
|
---|
231 | {
|
---|
232 | HAB hab;
|
---|
233 | HMQ hmq;
|
---|
234 | QMSG qmsg;
|
---|
235 |
|
---|
236 | hab=WinInitialize(0);
|
---|
237 | if(hab) {
|
---|
238 | hmq=WinCreateMsgQueue(hab,0);
|
---|
239 | if(hmq) {
|
---|
240 |
|
---|
241 | if((hwndThread=WinCreateWindow(HWND_OBJECT, WC_STATIC, "", 0,0,0,0,0, NULLHANDLE,
|
---|
242 | HWND_BOTTOM, 1, NULLHANDLE, NULLHANDLE))==NULLHANDLE) {
|
---|
243 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Can't start thread. Aborting...", "", 1234, MB_MOVEABLE);
|
---|
244 | exit(1);
|
---|
245 | }
|
---|
246 | WinSubclassWindow(hwndThread,&volumeObjectProc);
|
---|
247 | /* Window created. */
|
---|
248 |
|
---|
249 | while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
|
---|
250 | WinDispatchMsg(hab,&qmsg);
|
---|
251 | WinDestroyWindow(hwndThread);
|
---|
252 |
|
---|
253 | WinDestroyMsgQueue(hmq);
|
---|
254 | }
|
---|
255 | WinTerminate(hab);
|
---|
256 | }
|
---|
257 |
|
---|
258 | }
|
---|
259 |
|
---|
260 | static void contextMenu(HWND hwnd)
|
---|
261 | {
|
---|
262 | POINTL ptl;
|
---|
263 | HWND hwndPopup;
|
---|
264 | HWND hwndTitleBar;
|
---|
265 | BOOL bVisible;
|
---|
266 |
|
---|
267 | if((hwndTitleBar=WinWindowFromID(hwnd, FID_TITLEBAR))==NULLHANDLE)
|
---|
268 | return;
|
---|
269 |
|
---|
270 | hwndPopup = WinLoadMenu(hwnd, RESSOURCEHANDLE, IDM_POPUP);
|
---|
271 | if (hwndPopup == NULLHANDLE)
|
---|
272 | return;
|
---|
273 |
|
---|
274 | bVisible=WinIsWindowVisible(hwndTitleBar);
|
---|
275 |
|
---|
276 | if(!bVisible)
|
---|
277 | WinSendMsg(hwndPopup,MM_SETITEMATTR,MPFROM2SHORT(IDM_ITEMTITLEBAR,FALSE),
|
---|
278 | MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
|
---|
279 |
|
---|
280 | WinQueryPointerPos(HWND_DESKTOP, &ptl) ;
|
---|
281 | WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
|
---|
282 | WinPopupMenu(hwnd, hwnd, hwndPopup,
|
---|
283 | ptl.x, ptl.y, IDM_ITEMEXIT, PU_HCONSTRAIN | PU_VCONSTRAIN |
|
---|
284 | PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_NONE );
|
---|
285 | }
|
---|
286 |
|
---|
287 |
|
---|
288 | static BOOL toggleTitleBar(HWND hwnd)
|
---|
289 | {
|
---|
290 | HWND hwndTitleBar;
|
---|
291 |
|
---|
292 | if((hwndTitleBar=WinWindowFromID(hwnd, FID_TITLEBAR))!=NULLHANDLE)
|
---|
293 | {
|
---|
294 | SWP swp, swpFrame;
|
---|
295 |
|
---|
296 | if(!WinQueryWindowPos(hwndTitleBar,&swp))
|
---|
297 | return FALSE;
|
---|
298 |
|
---|
299 | if(!WinQueryWindowPos(hwnd,&swpFrame))
|
---|
300 | return FALSE;
|
---|
301 |
|
---|
302 | /* Shrink or expand the frame */
|
---|
303 | if(!bTBVisible) {
|
---|
304 | WinSetWindowPos(hwnd, NULLHANDLE, swpFrame.x, swpFrame.y,//-swp.cy,
|
---|
305 | swpFrame.cx, swpFrame.cy+swp.cy, SWP_SIZE|SWP_MOVE);
|
---|
306 | bTBVisible=TRUE;
|
---|
307 | }
|
---|
308 | else
|
---|
309 | {
|
---|
310 | WinSetWindowPos(hwnd, NULLHANDLE, swpFrame.x, swpFrame.y,//+swp.cy,
|
---|
311 | swpFrame.cx, swpFrame.cy-swp.cy, SWP_SIZE|SWP_MOVE);
|
---|
312 | bTBVisible=FALSE;
|
---|
313 | }
|
---|
314 | }
|
---|
315 | WinSendMsg(hwnd,WM_UPDATEFRAME,0,0);
|
---|
316 | return TRUE;
|
---|
317 | }
|
---|
318 |
|
---|
319 |
|
---|
320 | /* This Proc handles the on-the-fly data CD writing */
|
---|
321 | MRESULT EXPENTRY volumeDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
322 | {
|
---|
323 | //char text[CCHMAXPATH*4 +10];
|
---|
324 | //char title[CCHMAXPATH*4];
|
---|
325 | HPOINTER hpProgramIcon; /* handle to program's icon */
|
---|
326 |
|
---|
327 | switch (msg)
|
---|
328 | {
|
---|
329 | case WM_INITDLG:
|
---|
330 | {
|
---|
331 | RGB rgb;
|
---|
332 | ULONG ulSize;
|
---|
333 | SWP swp;
|
---|
334 | HWND hwndTB;
|
---|
335 | ULONG cy;
|
---|
336 |
|
---|
337 | /*
|
---|
338 | * The slider control cannot be completely set from the dialog
|
---|
339 | * template so some aspects must be set here. We will set the
|
---|
340 | * volume range to 0-100, increment to 1-10, and the initial
|
---|
341 | * volume level to 75.
|
---|
342 | */
|
---|
343 | WinSendMsg( WinWindowFromID(hwnd, IDCS_VOLUME),
|
---|
344 | CSM_SETRANGE,
|
---|
345 | (MPARAM) 0L,
|
---|
346 | (MPARAM) 100L);
|
---|
347 |
|
---|
348 | WinSendMsg( WinWindowFromID(hwnd, IDCS_VOLUME),
|
---|
349 | CSM_SETINCREMENT,
|
---|
350 | (MPARAM) 10L,
|
---|
351 | (MPARAM) 1L);
|
---|
352 |
|
---|
353 |
|
---|
354 | WinSendMsg( WinWindowFromID(hwnd, IDCS_VOLUME),
|
---|
355 | CSM_SETVALUE,
|
---|
356 | (MPARAM) queryMasterVolume(),
|
---|
357 | (MPARAM) NULL);
|
---|
358 |
|
---|
359 |
|
---|
360 | // getMessage(title, IDSTR_CONVERTCHANNELS, sizeof(title), RESSOURCEHANDLE, hwnd);
|
---|
361 | /* Set dialog font to WarpSans for Warp 4 and above */
|
---|
362 | if(SysQueryOSRelease()>=40) {
|
---|
363 | WinSetPresParam(hwnd,
|
---|
364 | PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
|
---|
365 | DEFAULT_DIALOG_FONT );
|
---|
366 | }
|
---|
367 |
|
---|
368 | hpProgramIcon =
|
---|
369 | WinLoadPointer(
|
---|
370 | HWND_DESKTOP,
|
---|
371 | (HMODULE) NULL, /* Resource is kept in .Exe file. */
|
---|
372 | ID_ICONVOLUME ); /* Which icon to use. */
|
---|
373 |
|
---|
374 | WinSendMsg(
|
---|
375 | hwnd, /* Dialog window handle. */
|
---|
376 | WM_SETICON, /* Message to the dialog. Set it's icon.*/
|
---|
377 | (MPARAM) hpProgramIcon,
|
---|
378 | (MPARAM) 0 ); /* mp2 no value. */
|
---|
379 | #if 0
|
---|
380 | WinDefSecondaryWindowProc(
|
---|
381 | hwnd, /* Dialog window handle. */
|
---|
382 | WM_SETICON, /* Message to the dialog. Set it's icon.*/
|
---|
383 | (MPARAM) hpProgramIcon,
|
---|
384 | (MPARAM) 0 ); /* mp2 no value. */
|
---|
385 | #endif
|
---|
386 |
|
---|
387 | bTBVisible=IniRestoreInt(chrIniFile, INI_VOLUME_APP, INI_TBVISIBLE_KEY, 1);
|
---|
388 | // sprintf(text, ": %d", bTBVisible);
|
---|
389 | // WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_MOVEABLE);
|
---|
390 |
|
---|
391 | IniRestoreWindowPos(chrIniFile, INI_VOLUME_APP, INI_WINDOWPOS_KEY, hwnd);
|
---|
392 | IniRestoreWindowClrs(chrIniFile, INI_VOLUME_APP , hwnd);
|
---|
393 |
|
---|
394 | ulSize=sizeof(RGB);
|
---|
395 | if(IniRestoreData(chrIniFile, INI_VOLUME_APP, INI_BTNBGCLR_KEY, &rgb, &ulSize))
|
---|
396 | {
|
---|
397 | // Set the background colour
|
---|
398 | WinSetPresParam(WinWindowFromID(hwnd, IDPB_MUTE),
|
---|
399 | PP_BACKGROUNDCOLOR,(ULONG)sizeof(rgb), &rgb);
|
---|
400 | }
|
---|
401 | ulSize=sizeof(RGB);
|
---|
402 | if(IniRestoreData(chrIniFile, INI_VOLUME_APP, INI_BTNFGCLR_KEY, &rgb, &ulSize))
|
---|
403 | {
|
---|
404 | // Set the foreground colour
|
---|
405 | WinSetPresParam(WinWindowFromID(hwnd, IDPB_MUTE),
|
---|
406 | PP_FOREGROUNDCOLOR,(ULONG)sizeof(rgb), &rgb);
|
---|
407 | }
|
---|
408 | //#if 0
|
---|
409 | if(!bTBVisible)
|
---|
410 | {
|
---|
411 | /* Reduce size of dialog */
|
---|
412 | hwndTB=WinWindowFromID(hwnd, FID_TITLEBAR);
|
---|
413 |
|
---|
414 | WinQueryWindowPos(hwndTB, &swp);
|
---|
415 | cy=swp.cy;
|
---|
416 | WinQueryWindowPos(hwnd, &swp);
|
---|
417 | WinSetWindowPos(hwnd, NULLHANDLE, 0, 0, swp.cx, swp.cy-cy, SWP_SIZE );
|
---|
418 | }
|
---|
419 | //#endif
|
---|
420 |
|
---|
421 | WinShowWindow( hwnd, TRUE );
|
---|
422 | _beginthread(volumeThreadFunc,NULL,8192*16, NULLHANDLE); //Fehlerbehandlung fehlt
|
---|
423 | return (MRESULT) FALSE;
|
---|
424 | }
|
---|
425 |
|
---|
426 | case WM_FORMATFRAME:
|
---|
427 | {
|
---|
428 | /* Remove top frame controls if titlebar is hidden */
|
---|
429 | SHORT countSwp;
|
---|
430 |
|
---|
431 | countSwp = (int) WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
432 | if(countSwp) {
|
---|
433 | if(bTBVisible==0) {
|
---|
434 | /* Hide frame controls */
|
---|
435 | /* countSWP: number of standard framecontrols
|
---|
436 | pswp: Array of SWP describing the framecontrols.
|
---|
437 | */
|
---|
438 | int a;
|
---|
439 | PSWP pswpTB=NULLHANDLE;
|
---|
440 | PSWP pswp=(PSWP)mp1;
|
---|
441 | int y;
|
---|
442 |
|
---|
443 | for (a = 0; a < countSwp; a++)
|
---|
444 | {
|
---|
445 | /* Find the titlebar window */
|
---|
446 | if ( WinQueryWindowUShort( pswp[a].hwnd, QWS_ID ) == FID_TITLEBAR )
|
---|
447 | {
|
---|
448 | pswpTB=&pswp[a];
|
---|
449 | y=pswp[a].y;
|
---|
450 | // DosBeep(500,600);
|
---|
451 | break;
|
---|
452 | }
|
---|
453 | }
|
---|
454 |
|
---|
455 | if(pswpTB) {
|
---|
456 | /* Hide all frame controls at the top */
|
---|
457 | for (a = 0; a < countSwp; a++)
|
---|
458 | {
|
---|
459 | if ( pswp[a].y == y )
|
---|
460 | {
|
---|
461 | pswp[a].fl|=SWP_HIDE;
|
---|
462 | pswp[a].fl&=~SWP_SHOW;
|
---|
463 | }
|
---|
464 | }/* for() */
|
---|
465 | /* Reduce size of dialog */
|
---|
466 | // WinQueryWindowPos(hwnd, &swp);
|
---|
467 | /*WinSetWindowPos(hwnd, NULLHANDLE, 0, 0, swp.cx, swp.cy-cy, SWP_SIZE );*/
|
---|
468 | // DosBeep(5000,600);
|
---|
469 | }
|
---|
470 | }
|
---|
471 | }
|
---|
472 | return MRFROMSHORT(countSwp);
|
---|
473 | }
|
---|
474 | case WM_CONTEXTMENU:
|
---|
475 | contextMenu(hwnd);
|
---|
476 | return (MRESULT) FALSE;
|
---|
477 | case WM_BUTTON1DBLCLK:
|
---|
478 | {
|
---|
479 | /* Remove frame controls (titlebar) when double clicking MB 1 */
|
---|
480 | toggleTitleBar(hwnd);
|
---|
481 | return (MRESULT) FALSE;
|
---|
482 | }
|
---|
483 | case WM_BUTTON2MOTIONSTART:
|
---|
484 | case WM_BUTTON1MOTIONSTART:
|
---|
485 | /* Drag the window without titlebar */
|
---|
486 | WinSendMsg(hwnd, WM_TRACKFRAME,
|
---|
487 | MPFROMSHORT(TF_MOVE /*| TF_SETPOINTERPOS */), NULL) ;
|
---|
488 | return (MRESULT) 0 ;
|
---|
489 | case WM_CONTROL:
|
---|
490 | if (SHORT1FROMMP(mp1)==IDCS_VOLUME)
|
---|
491 | {
|
---|
492 | if ((SHORT2FROMMP(mp1)==CSN_CHANGED) || /* change volume? */
|
---|
493 | (SHORT2FROMMP(mp1)==CSN_TRACKING)) /* tracking volume? */
|
---|
494 | {
|
---|
495 | SHORT sVolumeLevel;
|
---|
496 |
|
---|
497 | sVolumeLevel = SHORT1FROMMP (mp2);
|
---|
498 | if(!bMute)
|
---|
499 | setMasterVolume(hwnd, sVolumeLevel);
|
---|
500 | }
|
---|
501 | }
|
---|
502 | else if (SHORT1FROMMP(mp1)==IDPB_MUTE)
|
---|
503 | {
|
---|
504 | if (SHORT2FROMMP(mp1)==GBN_BUTTONDOWN) {
|
---|
505 | bMute=TRUE;
|
---|
506 | setMasterVolume(hwnd, 0);
|
---|
507 | }
|
---|
508 | else if (SHORT2FROMMP(mp1)==GBN_BUTTONUP) {
|
---|
509 | SHORT sValue;
|
---|
510 |
|
---|
511 | bMute=FALSE;
|
---|
512 | WinSendMsg(WinWindowFromID(hwnd, IDCS_VOLUME),CSM_QUERYVALUE ,MPFROMP(&sValue) ,0);
|
---|
513 | setMasterVolume(hwnd, sValue);
|
---|
514 | }
|
---|
515 | }
|
---|
516 | return( (MRESULT) 0);
|
---|
517 | case WM_CLOSE:
|
---|
518 | {
|
---|
519 | MCI_MASTERAUDIO_PARMS masteraudioparms;
|
---|
520 | ULONG attrFound;
|
---|
521 | RGB rgb;
|
---|
522 |
|
---|
523 | memset(&masteraudioparms,0, sizeof(masteraudioparms));
|
---|
524 | /* Save master audio level */
|
---|
525 | mciSendCommand( 0,
|
---|
526 | MCI_MASTERAUDIO, /* Master audio message */
|
---|
527 | MCI_WAIT | MCI_MASTERVOL | MCI_SAVESETTING,
|
---|
528 | /* Flags for this message */
|
---|
529 | (PVOID) &masteraudioparms,
|
---|
530 | 0);
|
---|
531 |
|
---|
532 | WinPostMsg(hwndThread, WM_CLOSE, 0, 0);
|
---|
533 | /* Save window position */
|
---|
534 | IniSaveWindowPos(chrIniFile, INI_VOLUME_APP, INI_WINDOWPOS_KEY, hwnd);
|
---|
535 | /* Save titlebar state */
|
---|
536 | bTBVisible=WinIsWindowVisible(WinWindowFromID(hwnd, FID_TITLEBAR));
|
---|
537 | IniSaveInt(chrIniFile, INI_VOLUME_APP, INI_TBVISIBLE_KEY, bTBVisible);
|
---|
538 | /* Save colors */
|
---|
539 | // Query the current button background colour
|
---|
540 | if(WinQueryPresParam(WinWindowFromID(hwnd, IDPB_MUTE),
|
---|
541 | PP_BACKGROUNDCOLOR,0,&attrFound,sizeof(rgb),
|
---|
542 | &rgb,QPF_NOINHERIT))
|
---|
543 | {
|
---|
544 | IniSaveData(chrIniFile, INI_VOLUME_APP, INI_BTNBGCLR_KEY, &rgb, sizeof(RGB));
|
---|
545 | }
|
---|
546 | // Query the current button foreground colour
|
---|
547 | if(WinQueryPresParam(WinWindowFromID(hwnd, IDPB_MUTE),
|
---|
548 | PP_FOREGROUNDCOLOR,0,&attrFound,sizeof(rgb),
|
---|
549 | &rgb,QPF_NOINHERIT))
|
---|
550 | {
|
---|
551 | IniSaveData(chrIniFile, INI_VOLUME_APP, INI_BTNFGCLR_KEY, &rgb, sizeof(RGB));
|
---|
552 | }
|
---|
553 | IniSaveWindowClrs(chrIniFile, INI_VOLUME_APP , hwnd);
|
---|
554 | WinPostMsg(hwnd, WM_QUIT, 0, 0);
|
---|
555 | return (MRESULT )FALSE;
|
---|
556 | }
|
---|
557 | case WM_COMMAND:
|
---|
558 | switch(SHORT1FROMMP(mp1))
|
---|
559 | {
|
---|
560 | case IDM_ITEMTITLEBAR:
|
---|
561 | toggleTitleBar(hwnd);
|
---|
562 | break;
|
---|
563 | case IDM_ITEMEXIT:
|
---|
564 | WinPostMsg(hwnd, WM_CLOSE, 0, 0);/* Timer error so do a hard quit */
|
---|
565 | break;
|
---|
566 | default:
|
---|
567 | break;
|
---|
568 | }
|
---|
569 | return (MRESULT) FALSE;
|
---|
570 | default:
|
---|
571 | break;
|
---|
572 | }/* switch */
|
---|
573 | //return (MRESULT) WinDefSecondaryWindowProc( hwnd, msg, mp1, mp2 ) ;
|
---|
574 | return WinDefDlgProc( hwnd, msg, mp1, mp2);
|
---|
575 | }
|
---|
576 |
|
---|
577 |
|
---|
578 | int main (int argc, char *argv[])
|
---|
579 | {
|
---|
580 | HAB hab;
|
---|
581 | HMQ hmq;
|
---|
582 | //char text[CCHMAXPATH];
|
---|
583 | //char title[CCHMAXPATH];
|
---|
584 |
|
---|
585 | hab=WinInitialize(0);
|
---|
586 | if(hab) {
|
---|
587 | hmq=WinCreateMsgQueue(hab,0);
|
---|
588 | if(hmq) {
|
---|
589 |
|
---|
590 | RESSOURCEHANDLE=queryResModuleHandle(argv[0]);
|
---|
591 |
|
---|
592 | HlpBuildMMProgIniFileName(argv[0], chrIniFile, sizeof(chrIniFile));
|
---|
593 | bTBVisible=IniRestoreInt(chrIniFile, INI_VOLUME_APP, INI_TBVISIBLE_KEY, 1);
|
---|
594 |
|
---|
595 | if( WinDlgBox( HWND_DESKTOP, NULLHANDLE,
|
---|
596 | volumeDialogProc, RESSOURCEHANDLE, IDDLG_VOLUME, 0) == DID_ERROR )
|
---|
597 | {
|
---|
598 | /*
|
---|
599 | Text:
|
---|
600 | Title: "Installation problem"
|
---|
601 | */
|
---|
602 | #if 0
|
---|
603 | messageBox( text, IDSTR_CONVERTDIALOGERROR , sizeof(text),
|
---|
604 | title, IDSTR_INSTALLERRORTITLE , sizeof(title),
|
---|
605 | RESSOURCEHANDLE, HWND_DESKTOP, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE);
|
---|
606 | #endif
|
---|
607 | WinDestroyMsgQueue( hmq );
|
---|
608 | WinTerminate( hab );
|
---|
609 | DosBeep(100,600);
|
---|
610 | freeResHandle();
|
---|
611 | return( 1 );
|
---|
612 | }
|
---|
613 | #if 0
|
---|
614 | hwndFrame=WinLoadSecondaryWindow(
|
---|
615 | HWND_DESKTOP, /* Parent of the dialog box. */
|
---|
616 | HWND_DESKTOP, /* Owner of the dialog box. */
|
---|
617 | (PFNWP) volumeDialogProc, /* */
|
---|
618 | (HMODULE) RESSOURCEHANDLE, /* */
|
---|
619 | IDDLG_VOLUME, /* Dialog ID. */
|
---|
620 | (PVOID) NULL); /* Creation */
|
---|
621 | hwndMainDialogBox = WinQuerySecondaryHWND(hwndFrame, QS_DIALOG);
|
---|
622 | WinShowWindow( hwndFrame, TRUE );
|
---|
623 | hpProgramIcon =
|
---|
624 | WinLoadPointer(
|
---|
625 | HWND_DESKTOP,
|
---|
626 | (HMODULE) NULL, /* Resource is kept in .Exe file. */
|
---|
627 | ID_ICONVOLUME ); /* Which icon to use. */
|
---|
628 | WinSendMsg(
|
---|
629 | hwndFrame, /* Dialog window handle. */
|
---|
630 | WM_SETICON, /* Message to the dialog. Set it's icon.*/
|
---|
631 | (MPARAM) hpProgramIcon,
|
---|
632 | (MPARAM) 0 ); /* mp2 no value. */
|
---|
633 | WinPostMsg( WinWindowFromID(hwndFrame, IDCS_VOLUME),
|
---|
634 | CSM_SETVALUE,
|
---|
635 | (MPARAM) queryMasterVolume(),
|
---|
636 | (MPARAM) NULL);
|
---|
637 | while ( WinGetMsg( hab, (PQMSG) &qmsg, (HWND) NULL, 0, 0) )
|
---|
638 | WinDispatchMsg( hab, (PQMSG) &qmsg );
|
---|
639 | #endif
|
---|
640 | freeResHandle();
|
---|
641 | WinDestroyMsgQueue(hmq);
|
---|
642 | }
|
---|
643 | WinTerminate(hab);
|
---|
644 | }
|
---|
645 | return 0;
|
---|
646 | }
|
---|
647 |
|
---|
648 |
|
---|
649 |
|
---|
650 |
|
---|
651 |
|
---|
652 |
|
---|
653 |
|
---|
654 |
|
---|
655 |
|
---|
656 |
|
---|
657 |
|
---|
658 |
|
---|