Changeset 104 for trunk/classes/mm-progs/master_volume/volume.c
- Timestamp:
- Oct 2, 2023, 11:34:35 PM (23 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to
/branches/v2.9 merged eligible /branches/v2.9_Lars merged eligible
-
Property svn:mergeinfo
set to
-
trunk/classes/mm-progs/master_volume/volume.c
r2 r104 17 17 * along with this program; see the file COPYING. If not, write to 18 18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 */ 19 */ 20 20 /* 21 21 * If you need another license for your project/product (commercial, 22 22 * noncommercial, whatever) contact me at 23 * 23 * 24 24 * http://www.os2world.com/cdwriting 25 25 * http://www.geocities.com/SiliconValley/Sector/5785/ … … 35 35 #define INCL_MMIOOS2 36 36 #define INCL_MCIOS2 37 #define INCL_SECONDARYWINDOW 38 #define INCL_GRAPHICBUTTON 37 #define INCL_SECONDARYWINDOW 38 #define INCL_GRAPHICBUTTON 39 39 #include <os2.h> 40 40 #include <sw.h> … … 73 73 BOOL bHaveWindowPos=FALSE; 74 74 75 BOOL bMute=FALSE; 75 BOOL bMute=FALSE; 76 76 HMODULE RESSOURCEHANDLE=0; 77 77 int bTBVisible=0; … … 134 134 135 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) 136 MRESULT EXPENTRY volumeObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 137 137 { 138 138 switch(msg) … … 153 153 ULONG mastervolume; /* Set to master volumepercentage 154 154 percentage by this example */ 155 155 156 156 USHORT usDeviceID=0; 157 157 MCI_MASTERAUDIO_PARMS masteraudioparms; … … 161 161 memset(&openParms,0, sizeof(openParms)); 162 162 openParms.pszDeviceType="Masteraudio"; 163 163 164 164 rc=mciSendCommand(0, /* Device */ 165 165 MCI_OPEN, /* Master audio message */ … … 171 171 mciGetErrorString(rc,chrCommand, sizeof(chrCommand)); 172 172 //sprintf(chrCommand, "%x", rc); 173 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrCommand, "", 1234, MB_MOVEABLE); 173 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrCommand, "", 1234, MB_MOVEABLE); 174 174 DosBeep(5000, 10); 175 175 usDeviceID=openParms.usDeviceID; … … 178 178 /* Get current system master 179 179 volume setting */ 180 180 181 181 mciSendCommand(usDeviceID, /* Device */ 182 182 MCI_MASTERAUDIO, /* Master audio message */ … … 188 188 /* Get current system master 189 189 volume setting */ 190 190 191 191 mciSendCommand(usDeviceID, /* Device */ 192 192 MCI_MASTERAUDIO, /* Master audio message */ … … 195 195 (PVOID) &masteraudioparms, /* Data structure */ 196 196 0); /* User parm */ 197 197 198 198 mastervolume = masteraudioparms.ulReturn; 199 199 DosBeep(500, 10); … … 228 228 } 229 229 230 void _OptlinkvolumeThreadFunc (void *arg)230 void volumeThreadFunc (void *arg) 231 231 { 232 232 HAB hab; … … 238 238 hmq=WinCreateMsgQueue(hab,0); 239 239 if(hmq) { 240 240 241 241 if((hwndThread=WinCreateWindow(HWND_OBJECT, WC_STATIC, "", 0,0,0,0,0, NULLHANDLE, 242 242 HWND_BOTTOM, 1, NULLHANDLE, NULLHANDLE))==NULLHANDLE) { … … 245 245 } 246 246 WinSubclassWindow(hwndThread,&volumeObjectProc); 247 /* Window created. */ 247 /* Window created. */ 248 248 249 249 while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0)) 250 250 WinDispatchMsg(hab,&qmsg); 251 251 WinDestroyWindow(hwndThread); 252 252 253 253 WinDestroyMsgQueue(hmq); 254 254 } … … 267 267 if((hwndTitleBar=WinWindowFromID(hwnd, FID_TITLEBAR))==NULLHANDLE) 268 268 return; 269 269 270 270 hwndPopup = WinLoadMenu(hwnd, RESSOURCEHANDLE, IDM_POPUP); 271 271 if (hwndPopup == NULLHANDLE) 272 272 return; 273 273 274 274 bVisible=WinIsWindowVisible(hwndTitleBar); 275 275 276 276 if(!bVisible) 277 WinSendMsg(hwndPopup,MM_SETITEMATTR,MPFROM2SHORT(IDM_ITEMTITLEBAR,FALSE), 277 WinSendMsg(hwndPopup,MM_SETITEMATTR,MPFROM2SHORT(IDM_ITEMTITLEBAR,FALSE), 278 278 MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED)); 279 279 280 280 WinQueryPointerPos(HWND_DESKTOP, &ptl) ; 281 281 WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1); 282 WinPopupMenu(hwnd, hwnd, hwndPopup, 282 WinPopupMenu(hwnd, hwnd, hwndPopup, 283 283 ptl.x, ptl.y, IDM_ITEMEXIT, PU_HCONSTRAIN | PU_VCONSTRAIN | 284 284 PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_NONE ); … … 296 296 if(!WinQueryWindowPos(hwndTitleBar,&swp)) 297 297 return FALSE; 298 298 299 299 if(!WinQueryWindowPos(hwnd,&swpFrame)) 300 300 return FALSE; 301 301 302 302 /* Shrink or expand the frame */ 303 303 if(!bTBVisible) { 304 WinSetWindowPos(hwnd, NULLHANDLE, swpFrame.x, swpFrame.y,//-swp.cy, 304 WinSetWindowPos(hwnd, NULLHANDLE, swpFrame.x, swpFrame.y,//-swp.cy, 305 305 swpFrame.cx, swpFrame.cy+swp.cy, SWP_SIZE|SWP_MOVE); 306 306 bTBVisible=TRUE; … … 308 308 else 309 309 { 310 WinSetWindowPos(hwnd, NULLHANDLE, swpFrame.x, swpFrame.y,//+swp.cy, 310 WinSetWindowPos(hwnd, NULLHANDLE, swpFrame.x, swpFrame.y,//+swp.cy, 311 311 swpFrame.cx, swpFrame.cy-swp.cy, SWP_SIZE|SWP_MOVE); 312 312 bTBVisible=FALSE; 313 313 } 314 314 } 315 WinSendMsg(hwnd,WM_UPDATEFRAME,0,0); 315 WinSendMsg(hwnd,WM_UPDATEFRAME,0,0); 316 316 return TRUE; 317 317 } … … 326 326 327 327 switch (msg) 328 { 328 { 329 329 case WM_INITDLG: 330 330 { … … 345 345 (MPARAM) 0L, 346 346 (MPARAM) 100L); 347 347 348 348 WinSendMsg( WinWindowFromID(hwnd, IDCS_VOLUME), 349 349 CSM_SETINCREMENT, 350 350 (MPARAM) 10L, 351 351 (MPARAM) 1L); 352 353 352 353 354 354 WinSendMsg( WinWindowFromID(hwnd, IDCS_VOLUME), 355 355 CSM_SETVALUE, 356 356 (MPARAM) queryMasterVolume(), 357 357 (MPARAM) NULL); 358 359 358 359 360 360 // getMessage(title, IDSTR_CONVERTCHANNELS, sizeof(title), RESSOURCEHANDLE, hwnd); 361 361 /* Set dialog font to WarpSans for Warp 4 and above */ … … 365 365 DEFAULT_DIALOG_FONT ); 366 366 } 367 367 368 368 hpProgramIcon = 369 369 WinLoadPointer( … … 371 371 (HMODULE) NULL, /* Resource is kept in .Exe file. */ 372 372 ID_ICONVOLUME ); /* Which icon to use. */ 373 373 374 374 WinSendMsg( 375 375 hwnd, /* Dialog window handle. */ … … 399 399 PP_BACKGROUNDCOLOR,(ULONG)sizeof(rgb), &rgb); 400 400 } 401 ulSize=sizeof(RGB); 401 ulSize=sizeof(RGB); 402 402 if(IniRestoreData(chrIniFile, INI_VOLUME_APP, INI_BTNFGCLR_KEY, &rgb, &ulSize)) 403 403 { … … 428 428 /* Remove top frame controls if titlebar is hidden */ 429 429 SHORT countSwp; 430 430 431 431 countSwp = (int) WinDefDlgProc(hwnd, msg, mp1, mp2); 432 432 if(countSwp) { 433 if(bTBVisible==0) { 434 /* Hide frame controls */ 433 if(bTBVisible==0) { 434 /* Hide frame controls */ 435 435 /* countSWP: number of standard framecontrols 436 436 pswp: Array of SWP describing the framecontrols. … … 439 439 PSWP pswpTB=NULLHANDLE; 440 440 PSWP pswp=(PSWP)mp1; 441 int y , cy;441 int y; 442 442 443 443 for (a = 0; a < countSwp; a++) … … 448 448 pswpTB=&pswp[a]; 449 449 y=pswp[a].y; 450 cy=pswp[a].cy;451 450 // DosBeep(500,600); 452 451 break; … … 485 484 case WM_BUTTON1MOTIONSTART: 486 485 /* Drag the window without titlebar */ 487 WinSendMsg(hwnd, WM_TRACKFRAME, 486 WinSendMsg(hwnd, WM_TRACKFRAME, 488 487 MPFROMSHORT(TF_MOVE /*| TF_SETPOINTERPOS */), NULL) ; 489 488 return (MRESULT) 0 ; … … 504 503 { 505 504 if (SHORT2FROMMP(mp1)==GBN_BUTTONDOWN) { 506 bMute=TRUE; 505 bMute=TRUE; 507 506 setMasterVolume(hwnd, 0); 508 507 } 509 508 else if (SHORT2FROMMP(mp1)==GBN_BUTTONUP) { 510 509 SHORT sValue; 511 510 512 511 bMute=FALSE; 513 512 WinSendMsg(WinWindowFromID(hwnd, IDCS_VOLUME),CSM_QUERYVALUE ,MPFROMP(&sValue) ,0); … … 524 523 memset(&masteraudioparms,0, sizeof(masteraudioparms)); 525 524 /* Save master audio level */ 526 mciSendCommand( 0, 525 mciSendCommand( 0, 527 526 MCI_MASTERAUDIO, /* Master audio message */ 528 527 MCI_WAIT | MCI_MASTERVOL | MCI_SAVESETTING, … … 594 593 bTBVisible=IniRestoreInt(chrIniFile, INI_VOLUME_APP, INI_TBVISIBLE_KEY, 1); 595 594 596 if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, 595 if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, 597 596 volumeDialogProc, RESSOURCEHANDLE, IDDLG_VOLUME, 0) == DID_ERROR ) 598 597 { 599 598 /* 600 Text: 601 Title: "Installation problem" 599 Text: 600 Title: "Installation problem" 602 601 */ 603 602 #if 0 … … 605 604 title, IDSTR_INSTALLERRORTITLE , sizeof(title), 606 605 RESSOURCEHANDLE, HWND_DESKTOP, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE); 607 #endif 606 #endif 608 607 WinDestroyMsgQueue( hmq ); 609 608 WinTerminate( hab ); … … 637 636 (MPARAM) NULL); 638 637 while ( WinGetMsg( hab, (PQMSG) &qmsg, (HWND) NULL, 0, 0) ) 639 WinDispatchMsg( hab, (PQMSG) &qmsg ); 638 WinDispatchMsg( hab, (PQMSG) &qmsg ); 640 639 #endif 641 640 freeResHandle();
Note:
See TracChangeset
for help on using the changeset viewer.