[2] | 1 | /*
|
---|
| 2 | * mmplayer.c (C) Chris Wohlgemuth 2002-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
|
---|
[104] | 23 | *
|
---|
[2] | 24 | * http://www.os2world.com/cdwriting
|
---|
| 25 | * http://www.geocities.com/SiliconValley/Sector/5785/
|
---|
| 26 | *
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | #define INCL_DOS
|
---|
| 30 | #define INCL_DOSFILEMGR
|
---|
| 31 | #define INCL_DOSERRORS
|
---|
| 32 | #define INCL_WIN
|
---|
| 33 | #define INCL_WINWORKPLACE
|
---|
| 34 | #define INCL_OS2MM
|
---|
| 35 | #define INCL_MMIOOS2
|
---|
| 36 | #define INCL_MCIOS2
|
---|
| 37 | #define INCL_GPI
|
---|
| 38 | #define INCL_PM
|
---|
| 39 |
|
---|
| 40 | #include <os2.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 "mmplayerres.h"
|
---|
| 49 | #include "mmres.h"
|
---|
| 50 | #include "mmplayer.h"
|
---|
| 51 | #include "mmprogs_defaults.h"
|
---|
| 52 | #include "sys_funcs.h"
|
---|
| 53 |
|
---|
[193] | 54 | #if 0
|
---|
| 55 | #define _PMPRINTF_
|
---|
| 56 | #include "PMPRINTF.H"
|
---|
| 57 | #endif
|
---|
| 58 |
|
---|
[104] | 59 | #ifndef OPEN_DEFAULT
|
---|
[2] | 60 | /* Open views for the wpOpen() method */
|
---|
| 61 |
|
---|
| 62 | #define OPEN_UNKNOWN -1
|
---|
| 63 | #define OPEN_DEFAULT 0
|
---|
| 64 | #define OPEN_CONTENTS 1
|
---|
| 65 | #define OPEN_SETTINGS 2
|
---|
| 66 | #define OPEN_HELP 3
|
---|
| 67 | #define OPEN_RUNNING 4
|
---|
| 68 | #define OPEN_PROMPTDLG 5
|
---|
| 69 | #define OPEN_PALETTE 121 /*SPLIT*/
|
---|
| 70 | #define OPEN_USER 0x6500
|
---|
| 71 | #endif
|
---|
| 72 |
|
---|
| 73 | LOADEDBITMAP allBMPs[NUM_CTRL_IDX];
|
---|
| 74 |
|
---|
| 75 | /* Format:
|
---|
| 76 | typedef struct
|
---|
| 77 | {
|
---|
| 78 | INT id;
|
---|
| 79 | RECTL rclSource;
|
---|
| 80 | HBITMAP hbmSource;
|
---|
| 81 | RECTL rclDest;
|
---|
| 82 | }CONTROLINFO;
|
---|
| 83 | */
|
---|
| 84 | CONTROLINFO ciControls[NUM_CTRL_IDX]={
|
---|
| 85 | {0,{0,0,414,70}, NULLHANDLE,{0}}, /* main */
|
---|
| 86 | /* Achtung destination verwendet fuer position */
|
---|
| 87 |
|
---|
| 88 | {IDPB_MMPLAYERPLAY, {0, 0, 36, 36},NULLHANDLE, { 108, 24, 144, 60} },/* Play */
|
---|
| 89 | {IDPB_MMPLAYERPLAY, {0, 0, 36,36},NULLHANDLE, { 108, 24, 144, 60} }, /* Playsel */
|
---|
| 90 | {IDPB_MMPLAYERSTOP, {0, 0, 36, 36},NULLHANDLE, { 24, 24, 60, 60} },/* Stop */
|
---|
| 91 | {IDPB_MMPLAYERSTOP, {0, 0, 36,36},NULLHANDLE, { 24, 24, 60, 60} }, /* Stop sel */
|
---|
| 92 | {IDPB_MMPLAYERPAUSE, {0, 0, 36, 36},NULLHANDLE, { 66, 24, 101, 60} },/* Pause */
|
---|
| 93 | {IDPB_MMPLAYERPAUSE, {0, 0, 36,36},NULLHANDLE, { 66, 24, 101, 60} }, /* Pause sel */
|
---|
| 94 | {IDSL_MMPLAYERPOSBAR,{191-5, 19-4, 389-5,32-4}, NULLHANDLE, { 191, 19, 389, 32} }, //NULLHANDLE, { 0, 0, 191,10} },
|
---|
| 95 | {IDPB_MMPLAYERSLIDERARM,{0,1,9,8},NULLHANDLE, {0,0,9,9} },
|
---|
| 96 | {IDST_MMPLAYERPLAYTIME, {191, 32, 391,54},NULLHANDLE, { 0, 0, 190, 25} },
|
---|
| 97 | {IDSL_MMPLAYERVOLUME,{15, 2,141,17},NULLHANDLE, {20, 6, 146, 21} }, //{0, 0, 126, 9} /* {10,18,93,13} */ },
|
---|
| 98 | {IDSL_MMPLAYERVOLUMEARM,{0,0,9,9},NULLHANDLE, {0,0,9,9}},
|
---|
| 99 | {IDSL_MMPLAYERVOLUMEARM,{0,0,9,9},NULLHANDLE, {0,0,9,9}},
|
---|
| 100 | };
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 | #define NUMPARAMS 2
|
---|
| 104 |
|
---|
| 105 | /* argv[0]: progname
|
---|
| 106 | * argv[1]: audio file
|
---|
| 107 | * ( argv[2]: class )
|
---|
| 108 | */
|
---|
| 109 |
|
---|
| 110 | //#define DEBUG
|
---|
| 111 | #ifdef DEBUG
|
---|
| 112 | void HlpWriteToTrapLog(const char* chrFormat, ...);
|
---|
| 113 | #endif
|
---|
| 114 |
|
---|
| 115 | BOOL IniSaveWindowPos(char * iniFile, char* chrApp, char *chrKey, HWND hwnd);
|
---|
| 116 | BOOL IniRestoreWindowPos(char * iniFile, char* chrApp, char *chrKey, HWND hwnd);
|
---|
| 117 | int IniRestoreInt(char * iniFile, char* chrApp, char *chrKey, int defaultInt);
|
---|
| 118 | BOOL IniSaveInt(char * iniFile, char* chrApp, char *chrKey, int theInt);
|
---|
| 119 | BOOL HlpBuildMMProgIniFileName(char* chrProgname, char * chrBuffer, ULONG ulBufferSize);
|
---|
[144] | 120 | void freeResHandle(void);
|
---|
[2] | 121 | HMODULE queryResModuleHandle(char *chrExePath);
|
---|
| 122 | BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
|
---|
| 123 | //MRESULT menuInsertMenuSeparator(int iPosition, HWND hwndMenu, HWND hwndSubMenu);
|
---|
| 124 | MRESULT menuInsertMenuSeparator(HWND hwndMenu, HWND hwndSubMenu, SHORT sPosition );
|
---|
| 125 | //MRESULT menuInsertMenuItem(int iPosition, HWND hwndMenu, HWND hwndSubMenu, int iID, char * chrText);
|
---|
| 126 | SHORT menuInsertMenuItem( HWND hwndMenu, HWND hwndSubMenu, SHORT sPosition, int iID, char * chrText);
|
---|
[144] | 127 | void pmUsage(void);
|
---|
[2] | 128 | ULONG messageBox( char* text, ULONG ulTextID , LONG lSizeText,
|
---|
| 129 | char* title, ULONG ulTitleID, LONG lSizeTitle,
|
---|
| 130 | HMODULE hResource, HWND hwnd, ULONG ulFlags);
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | MRESULT EXPENTRY playTimeTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
| 134 | MRESULT drawSlider(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, USHORT id);
|
---|
| 135 | MRESULT EXPENTRY privateSliderProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
| 136 | BOOL paintHilitedControl(HWND hwnd, USHORT usControl, BOOL bHilite);
|
---|
| 137 | MRESULT paintControls(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
| 138 | MRESULT EXPENTRY bgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
| 139 | MRESULT EXPENTRY buttonProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
| 140 |
|
---|
| 141 | /* Every folder has one running play thread to handle play commands */
|
---|
[104] | 142 | void playThreadFunc (void *arg);
|
---|
[2] | 143 | void controlPlaying(HWND hwndDialog, ULONG ulAction, ULONG ulReserved);
|
---|
| 144 | BOOL stopAudioFile(HWND hwndFrame);
|
---|
| 145 | BOOL seekAudioFile(LONG lPosSec);
|
---|
| 146 | void showPlayTimeDisplay(HWND hwndFrame, BOOL bShow);
|
---|
| 147 | void togglePlayTimeDisplayVisibility(HWND hwndFrame);
|
---|
| 148 | void setPlayTimeText(HWND hwndFrame);
|
---|
| 149 |
|
---|
| 150 | BOOL writeVolumeToIni(char * iniFile, char* chrApp, char *chrKey, ULONG ulVoume);
|
---|
| 151 | int readVolumeFromIni(char * iniFile, char* chrApp, char *chrKey, int iDefault);
|
---|
| 152 | BOOL writeDisplayTypeToIni(char * iniFile, char* chrApp, char *chrKey, int iDisplay);
|
---|
| 153 | int readDisplayTypeFromIni(char * iniFile, char* chrApp, char *chrKey, int iDefault);
|
---|
| 154 |
|
---|
| 155 | char logName[]="mmplayer.log";
|
---|
| 156 |
|
---|
| 157 | extern SWP swpWindow;
|
---|
| 158 | BOOL bHaveWindowPos=FALSE;
|
---|
| 159 |
|
---|
| 160 | /* Track to play. Full path */
|
---|
| 161 | char chrSourceName[CCHMAXPATH]={0};
|
---|
| 162 | char * chrPtrName=NULLHANDLE; /* Pointer to filename */
|
---|
| 163 | char chrClassName[100]= {0};
|
---|
| 164 |
|
---|
| 165 | char chrIniFile[CCHMAXPATH];
|
---|
| 166 |
|
---|
| 167 | int numArgs;
|
---|
| 168 | char* params[NUMPARAMS];
|
---|
| 169 |
|
---|
| 170 | /* TRUE when track is playing */
|
---|
| 171 | BOOL bIsPlaying=FALSE;
|
---|
| 172 | /* TRUE when track is paused */
|
---|
| 173 | BOOL bPaused=FALSE;
|
---|
| 174 | /* TRUE when user drags the position slider */
|
---|
| 175 | BOOL bPosDragging=FALSE;
|
---|
| 176 | BOOL bIsMidi=FALSE;
|
---|
| 177 |
|
---|
| 178 | /* Which display to show */
|
---|
| 179 | /* 0: time, 1: remaining, 2: filename */
|
---|
| 180 | int iWhichDisplay=0;
|
---|
| 181 | /* Display timer for changing between track info */
|
---|
| 182 | ULONG ulDisplayTimer=0;
|
---|
| 183 |
|
---|
| 184 | ULONG ulVolume=75;
|
---|
| 185 |
|
---|
| 186 | PID ulPid;
|
---|
| 187 | /* The play time of the track */
|
---|
| 188 | ULONG ulTotalLength=0;
|
---|
| 189 | /* Current time in track */
|
---|
| 190 | ULONG ulPos=0;
|
---|
| 191 |
|
---|
| 192 | HMODULE RESSOURCEHANDLE=0;
|
---|
| 193 |
|
---|
| 194 | HMODULE BMP_RESSOURCEHANDLE=0;
|
---|
| 195 |
|
---|
| 196 | PFNWP oldPlayTimeProc;
|
---|
| 197 | PFNWP orgBgProc=NULLHANDLE; /* Org proc of background */
|
---|
| 198 | PFNWP orgButtonProc=NULLHANDLE;
|
---|
| 199 |
|
---|
| 200 | HPOINTER hptrArrowWE=NULLHANDLE;
|
---|
| 201 |
|
---|
| 202 | void HlpContextMenu(HWND hwnd, USHORT usItem, BOOL fCheckItem)
|
---|
| 203 | {
|
---|
| 204 | POINTL ptl;
|
---|
| 205 | HWND hwndPopup;
|
---|
| 206 |
|
---|
| 207 | // hwndPopup = WinLoadMenu(hwnd, _queryResModuleHandle(), ID_MENUTIMECONTEXT) ;
|
---|
| 208 | hwndPopup = WinLoadMenu(hwnd, RESSOURCEHANDLE, ID_MENUTIMECONTEXT) ;
|
---|
| 209 | if (hwndPopup == NULLHANDLE) {
|
---|
| 210 | DosBeep(100,1000);
|
---|
| 211 | return;
|
---|
| 212 | }
|
---|
| 213 | if(fCheckItem)
|
---|
| 214 | WinSendMsg(hwndPopup,MM_SETITEMATTR,MPFROM2SHORT(usItem, TRUE), MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
|
---|
| 215 |
|
---|
| 216 | WinQueryPointerPos(HWND_DESKTOP, &ptl) ;
|
---|
| 217 | WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
|
---|
[104] | 218 | WinPopupMenu(hwnd, hwnd, hwndPopup,
|
---|
[2] | 219 | ptl.x, ptl.y, 0, PU_HCONSTRAIN | PU_VCONSTRAIN |
|
---|
[104] | 220 | PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_NONE );
|
---|
| 221 |
|
---|
[2] | 222 | }
|
---|
| 223 |
|
---|
[144] | 224 | static void _loadBmps(void)
|
---|
[2] | 225 | {
|
---|
| 226 | HPS hps;
|
---|
| 227 | HMODULE hResource;
|
---|
| 228 |
|
---|
| 229 | if(allBMPs[MAIN_BMP_IDX].hbm)
|
---|
| 230 | return;
|
---|
| 231 |
|
---|
| 232 | hResource=BMP_RESSOURCEHANDLE; //_queryResModuleHandle();
|
---|
| 233 | hps=WinGetPS(HWND_DESKTOP);
|
---|
[104] | 234 |
|
---|
[2] | 235 | /* The main BMP */
|
---|
| 236 | allBMPs[MAIN_BMP_IDX].hbm=GpiLoadBitmap(hps, hResource, IDBMP_TOPMIDDLE, 0, 0);
|
---|
| 237 | GpiQueryBitmapParameters(allBMPs[MAIN_BMP_IDX].hbm, &allBMPs[MAIN_BMP_IDX].bmpInfoHdr);
|
---|
| 238 |
|
---|
| 239 | /* Stop */
|
---|
| 240 | allBMPs[CTRLIDX_STOPBUTTON].hbm=GpiLoadBitmap(hps, hResource, IDBMP_STOP, 0, 0);
|
---|
| 241 | GpiQueryBitmapParameters(allBMPs[CTRLIDX_STOPBUTTON].hbm, &allBMPs[CTRLIDX_STOPBUTTON].bmpInfoHdr);
|
---|
| 242 | ciControls[CTRLIDX_STOPBUTTON].hbmSource=allBMPs[CTRLIDX_STOPBUTTON].hbm;
|
---|
| 243 |
|
---|
| 244 | /* Stop sel */
|
---|
| 245 | allBMPs[CTRLIDX_STOPBUTTONSEL].hbm=GpiLoadBitmap(hps, hResource, IDBMP_STOPSEL, 0, 0);
|
---|
| 246 | GpiQueryBitmapParameters(allBMPs[CTRLIDX_STOPBUTTONSEL].hbm, &allBMPs[CTRLIDX_STOPBUTTONSEL].bmpInfoHdr);
|
---|
| 247 | ciControls[CTRLIDX_STOPBUTTONSEL].hbmSource=allBMPs[CTRLIDX_STOPBUTTONSEL].hbm;
|
---|
| 248 |
|
---|
| 249 | /* Pause */
|
---|
| 250 | allBMPs[CTRLIDX_PAUSEBUTTON].hbm=GpiLoadBitmap(hps, hResource, IDBMP_PAUSE, 0, 0);
|
---|
| 251 | GpiQueryBitmapParameters(allBMPs[CTRLIDX_PAUSEBUTTON].hbm, &allBMPs[CTRLIDX_PAUSEBUTTON].bmpInfoHdr);
|
---|
| 252 | ciControls[CTRLIDX_PAUSEBUTTON].hbmSource=allBMPs[CTRLIDX_PAUSEBUTTON].hbm;
|
---|
| 253 |
|
---|
| 254 | /* Pause sel */
|
---|
| 255 | allBMPs[CTRLIDX_PAUSEBUTTONSEL].hbm=GpiLoadBitmap(hps, hResource, IDBMP_PAUSESEL, 0, 0);
|
---|
| 256 | GpiQueryBitmapParameters(allBMPs[CTRLIDX_PAUSEBUTTONSEL].hbm, &allBMPs[CTRLIDX_PAUSEBUTTONSEL].bmpInfoHdr);
|
---|
| 257 | ciControls[CTRLIDX_PAUSEBUTTONSEL].hbmSource=allBMPs[CTRLIDX_PAUSEBUTTONSEL].hbm;
|
---|
| 258 |
|
---|
| 259 | /* Play */
|
---|
| 260 | allBMPs[CTRLIDX_PLAYBUTTON].hbm=GpiLoadBitmap(hps, hResource, IDBMP_PLAY, 0, 0);
|
---|
| 261 | GpiQueryBitmapParameters(allBMPs[CTRLIDX_PLAYBUTTON].hbm, &allBMPs[CTRLIDX_PLAYBUTTON].bmpInfoHdr);
|
---|
| 262 | ciControls[CTRLIDX_PLAYBUTTON].hbmSource=allBMPs[CTRLIDX_PLAYBUTTON].hbm;
|
---|
| 263 |
|
---|
| 264 | /* Play sel */
|
---|
| 265 | allBMPs[CTRLIDX_PLAYBUTTONSEL].hbm=GpiLoadBitmap(hps, hResource, IDBMP_PLAYSEL, 0, 0);
|
---|
| 266 | GpiQueryBitmapParameters(allBMPs[CTRLIDX_PLAYBUTTONSEL].hbm, &allBMPs[CTRLIDX_PLAYBUTTONSEL].bmpInfoHdr);
|
---|
| 267 | ciControls[CTRLIDX_PLAYBUTTONSEL].hbmSource=allBMPs[CTRLIDX_PLAYBUTTONSEL].hbm;
|
---|
| 268 |
|
---|
| 269 | /* Positionslider bg */
|
---|
| 270 | ciControls[CTRLIDX_POSSLIDER].hbmSource=allBMPs[MAIN_BMP_IDX].hbm;
|
---|
| 271 |
|
---|
| 272 | /* Positionslider arm */
|
---|
| 273 | allBMPs[CTRLIDX_POSSLIDERARM].hbm=GpiLoadBitmap(hps, hResource, IDBMP_POSSLIDERARM, 0, 0);
|
---|
| 274 | GpiQueryBitmapParameters(allBMPs[CTRLIDX_POSSLIDERARM].hbm, &allBMPs[CTRLIDX_POSSLIDERARM].bmpInfoHdr);
|
---|
| 275 | ciControls[CTRLIDX_POSSLIDERARM].hbmSource=allBMPs[CTRLIDX_POSSLIDERARM].hbm;
|
---|
| 276 |
|
---|
| 277 | /* Playtime text field */
|
---|
| 278 | ciControls[CTRLIDX_PLAYTIME].hbmSource=allBMPs[MAIN_BMP_IDX].hbm;
|
---|
| 279 |
|
---|
| 280 | /* Volume slider background */
|
---|
| 281 | ciControls[CTRLIDX_VOLSLIDER].hbmSource=allBMPs[MAIN_BMP_IDX].hbm;
|
---|
| 282 |
|
---|
| 283 | /* Volume slider arm */
|
---|
| 284 | allBMPs[CTRLIDX_VOLSLIDERARM].hbm=GpiLoadBitmap(hps, hResource, IDBMP_VOLSLIDERARM, 0, 0);
|
---|
| 285 | GpiQueryBitmapParameters(allBMPs[CTRLIDX_VOLSLIDERARM].hbm, &allBMPs[CTRLIDX_VOLSLIDERARM].bmpInfoHdr);
|
---|
| 286 | ciControls[CTRLIDX_VOLSLIDERARM].hbmSource=allBMPs[CTRLIDX_VOLSLIDERARM].hbm;
|
---|
| 287 |
|
---|
| 288 | /* Volume slider arm selected*/
|
---|
| 289 | allBMPs[CTRLIDX_VOLSLIDERARMSEL].hbm=GpiLoadBitmap(hps, hResource, IDBMP_VOLSLIDERARMSEL, 0, 0);
|
---|
| 290 | GpiQueryBitmapParameters(allBMPs[CTRLIDX_VOLSLIDERARMSEL].hbm, &allBMPs[CTRLIDX_VOLSLIDERARMSEL].bmpInfoHdr);
|
---|
| 291 | ciControls[CTRLIDX_VOLSLIDERARMSEL].hbmSource=allBMPs[CTRLIDX_VOLSLIDERARMSEL].hbm;
|
---|
| 292 |
|
---|
| 293 | WinReleasePS(hps);
|
---|
| 294 | }
|
---|
| 295 |
|
---|
| 296 |
|
---|
| 297 | /***********************************************************/
|
---|
| 298 | /* */
|
---|
| 299 | /* Move the controls to the position defined by the */
|
---|
| 300 | /* background bitmap. */
|
---|
| 301 | /* */
|
---|
| 302 | /***********************************************************/
|
---|
| 303 | void adjustDialogControlPos(HWND hwnd)
|
---|
| 304 | {
|
---|
| 305 | CONTROLINFO ci;
|
---|
| 306 | ULONG ulStyle;
|
---|
| 307 |
|
---|
| 308 | /* STOP button */
|
---|
| 309 | ci=ciControls[CTRLIDX_STOPBUTTON];
|
---|
| 310 | ulStyle=WinQueryWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE);
|
---|
| 311 | WinSetWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE,ulStyle|BS_USERBUTTON);
|
---|
| 312 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id), HWND_TOP, ci.rclDest.xLeft , ci.rclDest.yBottom,
|
---|
| 313 | ci.rclDest.xRight-ci.rclDest.xLeft,
|
---|
| 314 | ci.rclDest.yTop-ci.rclDest.yBottom, SWP_MOVE|SWP_SIZE);
|
---|
| 315 | /* Pause button */
|
---|
| 316 | ci=ciControls[CTRLIDX_PAUSEBUTTON];
|
---|
| 317 | ulStyle=WinQueryWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE);
|
---|
| 318 | WinSetWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE,ulStyle|BS_USERBUTTON);
|
---|
| 319 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft , ci.rclDest.yBottom,
|
---|
| 320 | ci.rclDest.xRight-ci.rclDest.xLeft,
|
---|
| 321 | ci.rclDest.yTop-ci.rclDest.yBottom, SWP_MOVE|SWP_SIZE);
|
---|
| 322 | /* Play button */
|
---|
| 323 | ci=ciControls[CTRLIDX_PLAYBUTTON];
|
---|
| 324 | ulStyle=WinQueryWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE);
|
---|
| 325 | WinSetWindowULong(WinWindowFromID(hwnd, ci.id),QWL_STYLE,ulStyle|BS_USERBUTTON);
|
---|
| 326 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft , ci.rclDest.yBottom,
|
---|
| 327 | ci.rclDest.xRight-ci.rclDest.xLeft,
|
---|
| 328 | ci.rclDest.yTop-ci.rclDest.yBottom, SWP_MOVE|SWP_SIZE);
|
---|
| 329 |
|
---|
| 330 | /* Playtime text */
|
---|
| 331 | ci=ciControls[CTRLIDX_PLAYTIME];
|
---|
| 332 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclSource.xLeft,ci.rclSource.yBottom,
|
---|
| 333 | ci.rclSource.xRight-ci.rclSource.xLeft,
|
---|
[104] | 334 | ci.rclSource.yTop-ci.rclSource.yBottom, SWP_MOVE|SWP_SIZE);
|
---|
[2] | 335 | oldPlayTimeProc=WinSubclassWindow(WinWindowFromID(hwnd, IDST_MMPLAYERPLAYTIME), playTimeTextProc);
|
---|
| 336 |
|
---|
| 337 | /* Pos slider */
|
---|
| 338 | ci=ciControls[CTRLIDX_POSSLIDER];//ciPosSlider;
|
---|
[104] | 339 | WinCreateWindow(hwnd, SLIDER_CLASS, "", WS_VISIBLE | WS_TABSTOP, 0,0, 10, 10,
|
---|
[2] | 340 | hwnd, HWND_TOP, ci.id, NULLHANDLE, NULLHANDLE);
|
---|
| 341 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft, ci.rclDest.yBottom,
|
---|
| 342 | ci.rclSource.xRight-ci.rclSource.xLeft,
|
---|
| 343 | ci.rclSource.yTop-ci.rclSource.yBottom, SWP_MOVE | SWP_SIZE);
|
---|
[104] | 344 |
|
---|
[2] | 345 | WinSendMsg(WinWindowFromID(hwnd, ci.id),SLM_SETSLIDERINFO,
|
---|
| 346 | MPFROM2SHORT(SMA_SLIDERARMDIMENSIONS,0),
|
---|
[104] | 347 | MPFROM2SHORT( 9, 9));
|
---|
[2] | 348 |
|
---|
| 349 | /* Vol slider */
|
---|
| 350 | ci=ciControls[CTRLIDX_VOLSLIDER];//ciVolSlider;
|
---|
[104] | 351 | WinCreateWindow(hwnd, SLIDER_CLASS, "", WS_VISIBLE | WS_TABSTOP, 0,0, 10, 10,
|
---|
[2] | 352 | hwnd, HWND_TOP, ci.id, NULLHANDLE, NULLHANDLE);
|
---|
| 353 | WinSetWindowPos(WinWindowFromID(hwnd, ci.id),HWND_TOP, ci.rclDest.xLeft, ci.rclDest.yBottom,
|
---|
| 354 | ci.rclSource.xRight-ci.rclSource.xLeft,
|
---|
| 355 | ci.rclSource.yTop-ci.rclSource.yBottom, SWP_MOVE | SWP_SIZE);
|
---|
| 356 | WinSendMsg(WinWindowFromID(hwnd, ci.id),SLM_SETSLIDERINFO,
|
---|
| 357 | MPFROM2SHORT(SMA_SLIDERARMDIMENSIONS,0),
|
---|
[104] | 358 | MPFROM2SHORT( 9, 9));
|
---|
[2] | 359 |
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 |
|
---|
| 363 | void playTimeCallback(HWND hwndFrame, LONG lPosSec)
|
---|
| 364 | {
|
---|
| 365 | char chrCommand[50];
|
---|
| 366 | char retMsg[20];
|
---|
| 367 | ULONG rc;
|
---|
| 368 | int iWavePriv;
|
---|
| 369 |
|
---|
| 370 | iWavePriv=ulPid;
|
---|
| 371 |
|
---|
| 372 | /* Timeout. Check if wave is still playing */
|
---|
| 373 | sprintf(chrCommand,"STATUS wave%d MODE WAIT", iWavePriv);
|
---|
| 374 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
| 375 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
| 376 | /* Problem with MCI. Clean up. The Timer will be stopped in the method */
|
---|
[104] | 377 | stopAudioFile(hwndFrame);
|
---|
[2] | 378 | }
|
---|
| 379 | else {
|
---|
| 380 | if(!stricmp(retMsg, "stopped")) {
|
---|
| 381 | /* Audio file played. */
|
---|
[104] | 382 | stopAudioFile(hwndFrame);
|
---|
[2] | 383 | }
|
---|
| 384 | showPlayTimeDisplay(hwndFrame, TRUE);/* Ensure display is visible */
|
---|
| 385 | }
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 | USHORT DrgGetNumObjects(PDRAGINFO pDragInfo)
|
---|
| 389 | {
|
---|
| 390 | if(DrgAccessDraginfo(pDragInfo))
|
---|
| 391 | {
|
---|
| 392 | USHORT usItems=DrgQueryDragitemCount(pDragInfo);
|
---|
| 393 |
|
---|
| 394 |
|
---|
| 395 | DrgFreeDraginfo(pDragInfo);
|
---|
| 396 | return usItems;
|
---|
| 397 | }
|
---|
[104] | 398 |
|
---|
[2] | 399 | return 0;
|
---|
| 400 | }
|
---|
| 401 |
|
---|
| 402 | BOOL DrgVerifyTypeCW(PDRAGITEM pDragItem, char * chrType)
|
---|
| 403 | {
|
---|
[104] | 404 | /* DrgVerifyType() seems not to work when several types are in the list??
|
---|
[2] | 405 | Dokumentation says, it works... */
|
---|
| 406 | /* Only check for a single type for now */
|
---|
| 407 | char text[CCHMAXPATH];
|
---|
| 408 |
|
---|
| 409 | DrgQueryStrName(pDragItem->hstrType,sizeof(text), text); /* May be MP3, WAV etc... */
|
---|
| 410 |
|
---|
| 411 | if(strstr(text, chrType))
|
---|
| 412 | return TRUE;
|
---|
| 413 |
|
---|
| 414 | return FALSE;
|
---|
| 415 | }
|
---|
| 416 |
|
---|
| 417 | /* Check if we know the file type dragged */
|
---|
| 418 | BOOL DrgCheckForKnownType(PDRAGINFO pDragInfo , HWND hwnd )
|
---|
| 419 | {
|
---|
| 420 | BOOL rc=FALSE;
|
---|
| 421 |
|
---|
| 422 | if(DrgAccessDraginfo(pDragInfo))
|
---|
| 423 | {
|
---|
| 424 | PDRAGITEM pDragItem;
|
---|
| 425 | // char text[100];
|
---|
| 426 |
|
---|
| 427 | pDragItem=DrgQueryDragitemPtr(pDragInfo, 0);
|
---|
| 428 | // DrgQueryStrName(pDragItem->hstrType,sizeof(text), text); /* May be MP3, WAV etc... */
|
---|
| 429 |
|
---|
| 430 | // WinSetWindowText(hwnd, text);
|
---|
| 431 | bIsMidi=FALSE;
|
---|
| 432 | if(DrgVerifyTypeCW(pDragItem, "Digital Audio")) /* This should work for audio files added using the MM configuration */
|
---|
| 433 | rc=TRUE;
|
---|
| 434 | else if(DrgVerifyTypeCW(pDragItem, "WAV"))
|
---|
| 435 | rc=TRUE;
|
---|
| 436 | else if(DrgVerifyTypeCW(pDragItem, "MP3"))
|
---|
| 437 | rc=TRUE;
|
---|
| 438 | else if(DrgVerifyTypeCW(pDragItem, "MIDI")) {
|
---|
| 439 | rc=TRUE;
|
---|
| 440 | bIsMidi=TRUE;
|
---|
| 441 | }
|
---|
| 442 | else if(DrgVerifyTypeCW(pDragItem, "OGGS"))
|
---|
| 443 | rc=TRUE;
|
---|
| 444 | else if(DrgVerifyTypeCW(pDragItem, "VOC"))
|
---|
| 445 | rc=TRUE;
|
---|
| 446 | else if(DrgVerifyTypeCW(pDragItem, "IFF"))
|
---|
| 447 | rc=TRUE;
|
---|
| 448 | else if(DrgVerifyTypeCW(pDragItem, "AIF"))
|
---|
| 449 | rc=TRUE;
|
---|
| 450 | else if(DrgVerifyTypeCW(pDragItem, "AU"))
|
---|
| 451 | rc=TRUE;
|
---|
| 452 | else if(DrgVerifyTypeCW(pDragItem, "SND"))
|
---|
| 453 | rc=TRUE;
|
---|
| 454 | else if(DrgVerifyTypeCW(pDragItem, "_AU"))
|
---|
| 455 | rc=TRUE;
|
---|
| 456 | else if(DrgVerifyTypeCW(pDragItem, "FLAC"))
|
---|
| 457 | rc=TRUE;
|
---|
| 458 | DrgFreeDraginfo(pDragInfo);
|
---|
| 459 | }
|
---|
| 460 |
|
---|
| 461 | return rc;
|
---|
| 462 | }
|
---|
| 463 |
|
---|
| 464 | #if 0
|
---|
| 465 | #define HASHSIZE 101
|
---|
| 466 | /* This is poor mans HASH function... */
|
---|
| 467 | USHORT calculateHash(char * theString)
|
---|
| 468 | {
|
---|
| 469 | ULONG ulHash=0;
|
---|
| 470 |
|
---|
| 471 | if(theString)
|
---|
| 472 | for(ulHash=0;*theString!='\0'; theString++)
|
---|
| 473 | ulHash=*theString+37*ulHash;
|
---|
[104] | 474 |
|
---|
[2] | 475 | return ulHash%HASHSIZE;
|
---|
| 476 | }
|
---|
| 477 |
|
---|
| 478 | /*
|
---|
| 479 | Hashes:
|
---|
| 480 |
|
---|
| 481 | AIF: 0x30
|
---|
| 482 | AU: 0x42
|
---|
| 483 | WAV: 0x5b
|
---|
| 484 | MP3: 0x33
|
---|
| 485 | MIDI: 0x4c
|
---|
| 486 | OGGS: 0x58
|
---|
| 487 | IFF: 0x52
|
---|
| 488 | SND: 0x1b
|
---|
| 489 | VOC: 0x1d
|
---|
| 490 | _AU: 0x20
|
---|
| 491 | */
|
---|
| 492 | BOOL DrgCheckForKnownType(PDRAGINFO pDragInfo /* , HWND hwnd */)
|
---|
| 493 | {
|
---|
| 494 | BOOL rc=FALSE;
|
---|
| 495 |
|
---|
| 496 | return FALSE;
|
---|
| 497 | if(DrgAccessDraginfo(pDragInfo))
|
---|
| 498 | {
|
---|
| 499 | PDRAGITEM pDragItem;
|
---|
| 500 | char text[100];
|
---|
| 501 | USHORT usHash;
|
---|
| 502 |
|
---|
| 503 | pDragItem=DrgQueryDragitemPtr(pDragInfo, 0);
|
---|
| 504 | DrgQueryStrName(pDragItem->hstrType,sizeof(text), text); /* May be MP3, WAV etc... */
|
---|
| 505 |
|
---|
| 506 | usHash=calculateHash(text);
|
---|
| 507 | //sprintf(text,"%s, %x", text, usHash);
|
---|
| 508 | // WinSetWindowText(hwnd, text);
|
---|
| 509 | switch(usHash)
|
---|
| 510 | {
|
---|
| 511 | case 0x30:
|
---|
| 512 | case 0x42:
|
---|
| 513 | case 0x5b:
|
---|
| 514 | case 0x33:
|
---|
| 515 | case 0x4c:
|
---|
| 516 | case 0x58:
|
---|
| 517 | case 0x52:
|
---|
| 518 | case 0x1b:
|
---|
| 519 | case 0x1d:
|
---|
| 520 | case 0x21:
|
---|
| 521 | rc=TRUE;
|
---|
| 522 | default:
|
---|
| 523 | break;
|
---|
| 524 | }
|
---|
| 525 |
|
---|
| 526 | /* FIXME: Ugly Hack for MP3 files.
|
---|
| 527 | Some versions of the MP3 IO proc scan the whole file during identifying.
|
---|
| 528 | This is bad during dragging. */
|
---|
| 529 | /* Check if type contains MP3 type. There may be different types in the string */
|
---|
| 530 | if(!rc)
|
---|
| 531 | if(strstr(strupr(text), "MP3"))
|
---|
| 532 | rc=TRUE;
|
---|
| 533 |
|
---|
| 534 | DrgFreeDraginfo(pDragInfo);
|
---|
| 535 | }
|
---|
| 536 |
|
---|
| 537 |
|
---|
| 538 | return rc;
|
---|
| 539 | }
|
---|
| 540 | #endif
|
---|
| 541 |
|
---|
| 542 |
|
---|
| 543 | MRESULT handleDrag0ver(PDRAGINFO pdi, HWND hwnd)
|
---|
| 544 | {
|
---|
[104] | 545 |
|
---|
[2] | 546 | /* Only accept one file */
|
---|
| 547 | if(DrgGetNumObjects(pdi)!=1) {
|
---|
| 548 | return MRFROM2SHORT(DOR_NODROP, DO_LINK);
|
---|
| 549 | }
|
---|
| 550 | /* Check if the file is a known type. that's way faster than using mmioIdentifyFile() to check */
|
---|
| 551 | if(DrgCheckForKnownType(pdi, hwnd))
|
---|
| 552 | return MRFROM2SHORT(DOR_DROP, DO_COPY);
|
---|
[104] | 553 |
|
---|
| 554 | return MRFROM2SHORT(DOR_NEVERDROP, DO_COPY);
|
---|
[2] | 555 | }
|
---|
| 556 |
|
---|
| 557 | MRESULT handleDrop(PDRAGINFO pdi, HWND hwnd)
|
---|
| 558 | {
|
---|
| 559 |
|
---|
| 560 | /* Stop current track (if any) */
|
---|
| 561 | paintHilitedControl(WinWindowFromID(hwnd, IDPB_MMPLAYERPLAY), IDPB_MMPLAYERPLAY, FALSE);
|
---|
| 562 | paintHilitedControl(WinWindowFromID(hwnd, IDPB_MMPLAYERPAUSE), IDPB_MMPLAYERPAUSE, FALSE);
|
---|
| 563 | controlPlaying(hwnd, STOP_TRACK, 0);
|
---|
| 564 | /* Get file name */
|
---|
| 565 | if(DrgAccessDraginfo(pdi))
|
---|
| 566 | {
|
---|
| 567 | char chrFile[CCHMAXPATH];
|
---|
| 568 | PDRAGITEM pDragItem;
|
---|
[104] | 569 |
|
---|
[2] | 570 | pDragItem=DrgQueryDragitemPtr(pdi, 0);
|
---|
[104] | 571 | DrgQueryStrName(pDragItem->hstrSourceName,sizeof(chrFile), chrFile);
|
---|
| 572 | DrgQueryStrName(pDragItem->hstrContainerName,sizeof(chrSourceName), chrSourceName);
|
---|
[2] | 573 | strcat(chrSourceName, chrFile);
|
---|
[104] | 574 |
|
---|
[2] | 575 | /* Start new file */
|
---|
| 576 | controlPlaying(hwnd, PLAY_FIRST, 0);
|
---|
| 577 | DrgFreeDraginfo(pdi);
|
---|
| 578 | }
|
---|
| 579 | return MRFALSE;
|
---|
| 580 | }
|
---|
| 581 |
|
---|
| 582 | /****************************************************************
|
---|
| 583 | * FixSysMenu procedure
|
---|
| 584 | *--------------------------------------------------------------
|
---|
| 585 | *
|
---|
| 586 | * Name: FixSysMenu(HWND hwndDlg)
|
---|
| 587 | *
|
---|
| 588 | * Purpose: This routine removes the Restore, Size, Minimize, and
|
---|
| 589 | * Maximize options from the system menu of a dialog.
|
---|
| 590 | *
|
---|
| 591 | * Usage
|
---|
| 592 | *
|
---|
| 593 | * Method: Called during the WM_INITDLG of a dialog procedure.
|
---|
| 594 | *
|
---|
| 595 | * Returns: VOID
|
---|
| 596 | *
|
---|
| 597 | ****************************************************************/
|
---|
| 598 | VOID FixSysMenu(HWND hwndDlg)
|
---|
| 599 | {
|
---|
| 600 | HWND hwndMenu; /* Handle to system menu */
|
---|
| 601 | MENUITEM mi={0};
|
---|
| 602 |
|
---|
| 603 | hwndMenu = WinWindowFromID(hwndDlg, FID_SYSMENU);
|
---|
| 604 |
|
---|
| 605 |
|
---|
| 606 | WinSendMsg(hwndMenu, /* Delete Restore from the system menu */
|
---|
| 607 | MM_DELETEITEM,
|
---|
| 608 | MPFROM2SHORT(SC_RESTORE, TRUE),
|
---|
| 609 | MPFROMP(NULL));
|
---|
| 610 |
|
---|
| 611 | WinSendMsg(hwndMenu, /* Delete Size from the system menu */
|
---|
| 612 | MM_DELETEITEM,
|
---|
| 613 | MPFROM2SHORT(SC_SIZE, TRUE),
|
---|
| 614 | MPFROMP(NULL));
|
---|
[104] | 615 |
|
---|
[2] | 616 | WinSendMsg(hwndMenu, /* Delete Minimize from the system menu */
|
---|
| 617 | MM_DELETEITEM,
|
---|
| 618 | MPFROM2SHORT(SC_MINIMIZE, TRUE),
|
---|
| 619 | MPFROMP(NULL));
|
---|
[104] | 620 |
|
---|
[2] | 621 | WinSendMsg(hwndMenu, /* Delete Maximize from the system menu */
|
---|
| 622 | MM_DELETEITEM,
|
---|
| 623 | MPFROM2SHORT(SC_MAXIMIZE, TRUE),
|
---|
| 624 | MPFROMP(NULL));
|
---|
| 625 |
|
---|
| 626 | WinSendMsg(hwndMenu, /* Delete Maximize from the system menu */
|
---|
| 627 | MM_DELETEITEM,
|
---|
| 628 | MPFROM2SHORT(SC_HIDE, TRUE),
|
---|
| 629 | MPFROMP(NULL));
|
---|
| 630 |
|
---|
| 631 | if(WinSendMsg(hwndMenu, /* Get sys menu menuitem */
|
---|
| 632 | MM_QUERYITEM,
|
---|
| 633 | MPFROM2SHORT(SC_SYSMENU, FALSE),
|
---|
| 634 | MPFROMP(&mi)))
|
---|
| 635 | {
|
---|
| 636 | char chrText[100];
|
---|
| 637 | menuInsertMenuSeparator( mi.hwndSubMenu, NULLHANDLE, MIT_END);
|
---|
| 638 | if(!getMessage(chrText, IDSTR_MASTERVOLUMEITEM, sizeof(chrText), RESSOURCEHANDLE, hwndMenu))
|
---|
| 639 | strcpy(chrText, "Master ~Volume");
|
---|
| 640 | menuInsertMenuItem( mi.hwndSubMenu, NULLHANDLE, MIT_END, ID_MENUITEMMASTERVOLUME, chrText);
|
---|
| 641 | }
|
---|
| 642 | return;
|
---|
| 643 | }
|
---|
| 644 |
|
---|
| 645 |
|
---|
| 646 | /* This Proc handles the main dialog */
|
---|
| 647 | MRESULT EXPENTRY decodeStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 648 | {
|
---|
| 649 | // char text[CCHMAXPATH*4 +10];
|
---|
| 650 | // char title[CCHMAXPATH*4];
|
---|
| 651 | SWCNTRL swctl;
|
---|
| 652 | PID pid;
|
---|
| 653 |
|
---|
| 654 | switch (msg)
|
---|
[104] | 655 | {
|
---|
[2] | 656 | case DM_DRAGOVER:
|
---|
| 657 | {
|
---|
| 658 | PDRAGINFO pdi=PVOIDFROMMP(mp1);
|
---|
| 659 |
|
---|
| 660 | return handleDrag0ver( pdi, hwnd);
|
---|
| 661 |
|
---|
| 662 | break;
|
---|
| 663 | }
|
---|
| 664 | case DM_DROP:
|
---|
| 665 | {
|
---|
| 666 | PDRAGINFO pdi=PVOIDFROMMP(mp1);
|
---|
| 667 |
|
---|
| 668 | return handleDrop( pdi, hwnd);
|
---|
| 669 | }
|
---|
| 670 | case WM_INITDLG:
|
---|
| 671 | {
|
---|
| 672 | IniRestoreWindowPos(chrIniFile, INI_MMPLAYER_APP, INI_WINDOWPOS_KEY, hwnd);
|
---|
| 673 |
|
---|
| 674 | /* Add switch entry */
|
---|
| 675 | memset(&swctl,0,sizeof(swctl));
|
---|
| 676 | WinQueryWindowProcess(hwnd,&pid,NULL);
|
---|
| 677 | swctl.hwnd=hwnd;
|
---|
| 678 | swctl.uchVisibility=SWL_VISIBLE;
|
---|
| 679 | swctl.idProcess=pid;
|
---|
| 680 | swctl.bProgType=PROG_DEFAULT;
|
---|
| 681 | swctl.fbJump=SWL_JUMPABLE;
|
---|
| 682 | WinAddSwitchEntry(&swctl);
|
---|
[104] | 683 |
|
---|
[2] | 684 | adjustDialogControlPos(hwnd);
|
---|
[104] | 685 |
|
---|
[2] | 686 | /* Set volume slider*/
|
---|
| 687 | WinSendMsg( WinWindowFromID(hwnd, IDSL_MMPLAYERVOLUME),
|
---|
| 688 | SLM_SETSLIDERINFO,
|
---|
| 689 | MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
|
---|
| 690 | MPFROMLONG( ulVolume));
|
---|
[104] | 691 |
|
---|
[2] | 692 | /* Subclass buttons for DnD */
|
---|
| 693 | orgButtonProc=WinSubclassWindow(WinWindowFromID(hwnd, IDPB_MMPLAYERPLAY), buttonProc);
|
---|
| 694 | WinSubclassWindow(WinWindowFromID(hwnd, IDPB_MMPLAYERPAUSE), buttonProc);
|
---|
| 695 | WinSubclassWindow(WinWindowFromID(hwnd, IDPB_MMPLAYERSTOP), buttonProc);
|
---|
[104] | 696 |
|
---|
[2] | 697 | FixSysMenu(hwnd);
|
---|
| 698 |
|
---|
| 699 | /* Size dialog */
|
---|
| 700 | if(allBMPs[MAIN_BMP_IDX].hbm) {
|
---|
| 701 | SWP swp;
|
---|
[104] | 702 |
|
---|
| 703 | WinQueryWindowPos(WinWindowFromID(hwnd, FID_TITLEBAR), &swp);
|
---|
| 704 | WinSetWindowPos(WinWindowFromID(hwnd, ID_CLIENT), NULLHANDLE,
|
---|
| 705 | WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME),
|
---|
| 706 | WinQuerySysValue(HWND_DESKTOP, SV_CYDLGFRAME),
|
---|
[2] | 707 | allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cx,
|
---|
| 708 | allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cy,
|
---|
| 709 | SWP_SIZE|SWP_MOVE);
|
---|
| 710 | orgBgProc=WinSubclassWindow(WinWindowFromID(hwnd, ID_CLIENT), bgProc);
|
---|
[104] | 711 |
|
---|
[2] | 712 | WinSetWindowPos(hwnd, NULLHANDLE, 0, 0,
|
---|
| 713 | allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cx+WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME)*2,
|
---|
| 714 | allBMPs[MAIN_BMP_IDX].bmpInfoHdr.cy+swp.cy+WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME)*2
|
---|
| 715 | , SWP_SIZE);
|
---|
| 716 | }
|
---|
| 717 | /* Set dialog font to WarpSans for Warp 4 and above */
|
---|
| 718 | if(SysQueryOSRelease()>=40) {
|
---|
| 719 | WinSetPresParam(WinWindowFromID(hwnd, IDST_MMPLAYERPLAYTIME),
|
---|
| 720 | PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
|
---|
| 721 | DEFAULT_DIALOG_FONT );
|
---|
| 722 | }
|
---|
| 723 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, IDPB_MMPLAYERPLAY));
|
---|
| 724 | WinStartTimer(WinQueryAnchorBlock(HWND_DESKTOP), hwnd, IDTIMER_START_PLAYING, START_TIMEOUT);
|
---|
| 725 | return (MRESULT) TRUE;
|
---|
| 726 | }
|
---|
| 727 | case WM_CLOSE:
|
---|
| 728 | controlPlaying(hwnd, STOP_TRACK, 0);
|
---|
| 729 | IniSaveWindowPos(chrIniFile, INI_MMPLAYER_APP, INI_WINDOWPOS_KEY, hwnd);
|
---|
| 730 | writeVolumeToIni(chrIniFile, INI_MMPLAYER_APP, INI_VOLUME_KEY, ulVolume);
|
---|
| 731 | writeDisplayTypeToIni(chrIniFile, INI_MMPLAYER_APP, INI_DISPLAY_KEY, iWhichDisplay);
|
---|
| 732 | // WinSendMsg(hwndPlayObject, WM_CLOSE, 0, 0);
|
---|
| 733 | break;
|
---|
| 734 | /*****************************************************/
|
---|
| 735 | /* Handle playtime display switching. */
|
---|
| 736 | /* The messages are coming from the static text. */
|
---|
| 737 | /*****************************************************/
|
---|
| 738 | case WM_APPTERMINATENOTIFY:
|
---|
[104] | 739 |
|
---|
[2] | 740 | switch(SHORT1FROMMP(mp1))
|
---|
| 741 | {
|
---|
| 742 | case NOTIFY_CLICK:
|
---|
| 743 | /* Clicked on the playtime display */
|
---|
| 744 | iWhichDisplay++;
|
---|
| 745 | if(iWhichDisplay>2)
|
---|
| 746 | iWhichDisplay=0;
|
---|
| 747 | if(iWhichDisplay==2)
|
---|
| 748 | ulDisplayTimer=0;
|
---|
| 749 | setPlayTimeText(hwnd);
|
---|
| 750 | return MRFALSE;
|
---|
| 751 | case NOTIFY_CONTEXT:
|
---|
[104] | 752 | /* Show context menu. */
|
---|
[2] | 753 | HlpContextMenu(hwnd, iWhichDisplay+ID_MENUITEMELAPSED, TRUE);
|
---|
| 754 | return MRFALSE;
|
---|
| 755 | default:
|
---|
| 756 | break;
|
---|
| 757 | }
|
---|
| 758 | return MRFALSE;
|
---|
[104] | 759 |
|
---|
[2] | 760 | /*****************************************************/
|
---|
| 761 | /* The following two messages are for device sharing */
|
---|
| 762 | /*****************************************************/
|
---|
| 763 | case WM_ACTIVATE:
|
---|
| 764 | if(SHORT1FROMMP(mp1)){
|
---|
| 765 | char chrCommand[100];
|
---|
| 766 | int iWavePriv;
|
---|
[104] | 767 |
|
---|
[2] | 768 | iWavePriv=ulPid;
|
---|
| 769 |
|
---|
| 770 | if(bIsPlaying) {
|
---|
| 771 | sprintf(chrCommand,"ACQUIRE wave%d QUEUE wait", iWavePriv);
|
---|
| 772 | mciSendString(chrCommand, NULL, 0, 0, 0);
|
---|
| 773 | }
|
---|
| 774 | }
|
---|
| 775 | break;
|
---|
| 776 |
|
---|
| 777 | case MM_MCIPASSDEVICE:
|
---|
| 778 | {
|
---|
| 779 | switch(SHORT1FROMMP(mp2))
|
---|
| 780 | {
|
---|
| 781 | case MCI_GAINING_USE:
|
---|
| 782 | bPaused=FALSE;/* The time display will not be increased */
|
---|
| 783 | paintHilitedControl(WinWindowFromID(hwnd, IDPB_MMPLAYERPAUSE), IDPB_MMPLAYERPAUSE, FALSE);
|
---|
| 784 | return (MRESULT)0;
|
---|
| 785 | case MCI_LOSING_USE:
|
---|
| 786 | bPaused=TRUE;
|
---|
| 787 | paintHilitedControl(WinWindowFromID(hwnd, IDPB_MMPLAYERPLAY), IDPB_MMPLAYERPLAY, FALSE);
|
---|
| 788 | return (MRESULT)0;
|
---|
| 789 | default:
|
---|
| 790 | break;
|
---|
| 791 | }
|
---|
| 792 | }
|
---|
| 793 | break;
|
---|
| 794 | /*****************************************************/
|
---|
| 795 | /* Set the time in the palytime display. */
|
---|
| 796 | /* SETPOSITIONADVICE does not work for some reason, */
|
---|
| 797 | /* so a timer is used. Yes, it's quit cumbersome... */
|
---|
[104] | 798 | /*****************************************************/
|
---|
[2] | 799 | case WM_TIMER:
|
---|
| 800 | if(SHORT1FROMMP(mp1)==IDTIMER_PLAY) {
|
---|
| 801 | if(!bPaused) {
|
---|
| 802 | /* Adjust position info */
|
---|
| 803 | ulPos++;
|
---|
| 804 | if(ulPos*1000>ulTotalLength)
|
---|
| 805 | ulPos=ulTotalLength/1000;/* Prevent wrong time if timer info isn't accurate.
|
---|
| 806 | I know all this timing stuff is an ugly thing. */
|
---|
| 807 |
|
---|
| 808 |
|
---|
| 809 | if(!bPosDragging) {
|
---|
| 810 | ULONG ulInc=ulTotalLength/1000;
|
---|
| 811 | setPlayTimeText(hwnd); /* Set time display */
|
---|
| 812 | /* Catch potential division by zero trap */
|
---|
| 813 | if(ulInc)
|
---|
| 814 | ulInc=ulPos*100/ulInc;
|
---|
| 815 | else
|
---|
| 816 | ulInc=100;
|
---|
| 817 | /* Set slider position */
|
---|
| 818 |
|
---|
[104] | 819 | WinPostMsg( WinWindowFromID(hwnd, IDSL_MMPLAYERPOSBAR),
|
---|
[2] | 820 | SLM_SETSLIDERINFO,
|
---|
| 821 | MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
|
---|
| 822 | MPFROMLONG(ulInc));
|
---|
| 823 |
|
---|
| 824 | }
|
---|
| 825 |
|
---|
| 826 | playTimeCallback(hwnd, ulPos);
|
---|
| 827 | /* Blink play control */
|
---|
| 828 | paintHilitedControl(WinWindowFromID(hwnd, IDPB_MMPLAYERPLAY), IDPB_MMPLAYERPLAY, ulPos%2);
|
---|
| 829 | }
|
---|
| 830 | else {
|
---|
| 831 | /* Currently pausing */
|
---|
| 832 | togglePlayTimeDisplayVisibility(hwnd);
|
---|
| 833 | paintHilitedControl( WinWindowFromID(hwnd, IDPB_MMPLAYERPAUSE), IDPB_MMPLAYERPAUSE,
|
---|
| 834 | WinIsWindowVisible(WinWindowFromID(hwnd, IDST_MMPLAYERPLAYTIME)));
|
---|
| 835 | }
|
---|
| 836 | return (MRESULT)0;
|
---|
| 837 | }
|
---|
[46] | 838 | else if(SHORT1FROMMP(mp1)==IDTIMER_START_PLAYING)
|
---|
[2] | 839 | {
|
---|
| 840 | WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, IDTIMER_START_PLAYING);
|
---|
| 841 | controlPlaying(hwnd, PLAY_FIRST, 0);
|
---|
| 842 | return (MRESULT)0;
|
---|
| 843 | }
|
---|
| 844 | break;
|
---|
| 845 |
|
---|
| 846 | /* The play control handling for starting, stopping etc. */
|
---|
| 847 | case WM_COMMAND:
|
---|
| 848 | {
|
---|
| 849 | switch(SHORT1FROMMP(mp1))
|
---|
| 850 | {
|
---|
| 851 | case IDPB_MMPLAYERPLAY:
|
---|
| 852 | paintHilitedControl(WinWindowFromID(hwnd, IDPB_MMPLAYERPAUSE), IDPB_MMPLAYERPAUSE, FALSE);
|
---|
| 853 | controlPlaying(hwnd, PLAY_FIRST, 0);
|
---|
| 854 | break;
|
---|
| 855 | case IDPB_MMPLAYERSTOP:
|
---|
| 856 | paintHilitedControl(WinWindowFromID(hwnd, IDPB_MMPLAYERPLAY), IDPB_MMPLAYERPLAY, FALSE);
|
---|
| 857 | paintHilitedControl(WinWindowFromID(hwnd, IDPB_MMPLAYERPAUSE), IDPB_MMPLAYERPAUSE, FALSE);
|
---|
| 858 | controlPlaying(hwnd, STOP_TRACK, 0);
|
---|
| 859 | break;
|
---|
| 860 | case IDPB_MMPLAYERPAUSE:
|
---|
| 861 | paintHilitedControl(WinWindowFromID(hwnd, IDPB_MMPLAYERPLAY), IDPB_MMPLAYERPLAY, FALSE);
|
---|
| 862 | controlPlaying(hwnd, PAUSE_TRACK, 0);
|
---|
| 863 | break;
|
---|
| 864 | /* Popup menu over time control */
|
---|
| 865 | case ID_MENUITEMELAPSED:
|
---|
| 866 | iWhichDisplay=DISPLAY_TIMEELAPSED;
|
---|
| 867 | setPlayTimeText(hwnd);
|
---|
| 868 | break;
|
---|
| 869 | case ID_MENUITEMREMAINING:
|
---|
| 870 | iWhichDisplay=DISPLAY_TIMEREMAINING;
|
---|
| 871 | setPlayTimeText(hwnd);
|
---|
| 872 | break;
|
---|
| 873 | case ID_MENUITEMID3:
|
---|
| 874 | iWhichDisplay=DISPLAY_TIMEID3;
|
---|
| 875 | ulDisplayTimer=0;
|
---|
| 876 | setPlayTimeText(hwnd);
|
---|
| 877 | break;
|
---|
| 878 | case ID_MENUITEMMASTERVOLUME:
|
---|
| 879 | {
|
---|
| 880 | HOBJECT hObject;
|
---|
| 881 | /* User selected master volume item from sys menu */
|
---|
| 882 | if((hObject=WinQueryObject("<MMPM2_MMVOLUME>"))!=NULLHANDLE) {
|
---|
| 883 | WinOpenObject(hObject,OPEN_DEFAULT,TRUE);
|
---|
| 884 | }
|
---|
| 885 | break;
|
---|
| 886 | }
|
---|
| 887 | default:
|
---|
| 888 | break;
|
---|
| 889 | }/* switch() */
|
---|
| 890 |
|
---|
| 891 | return (MRESULT)FALSE;
|
---|
| 892 | }/* case */
|
---|
| 893 |
|
---|
| 894 | /*****************************************************/
|
---|
| 895 | /* Draw the sliders. */
|
---|
| 896 | /*****************************************************/
|
---|
| 897 | case WM_DRAWITEM:
|
---|
| 898 | switch(SHORT1FROMMP(mp1))
|
---|
| 899 | {
|
---|
| 900 | case IDSL_MMPLAYERPOSBAR:
|
---|
| 901 | case IDSL_MMPLAYERVOLUME:
|
---|
| 902 | return drawSlider(hwnd, msg, mp1, mp2, SHORT1FROMMP(mp1));
|
---|
| 903 | default:
|
---|
| 904 | break;
|
---|
[104] | 905 | }
|
---|
[2] | 906 | break;
|
---|
| 907 |
|
---|
| 908 | /*****************************************************/
|
---|
| 909 | /* Control messages */
|
---|
| 910 | /*****************************************************/
|
---|
| 911 | case WM_CONTROL:
|
---|
| 912 | {
|
---|
| 913 | SWP swp;
|
---|
| 914 | char chrCommand[50];
|
---|
| 915 | char retMsg[20];
|
---|
[104] | 916 |
|
---|
[2] | 917 | switch(SHORT2FROMMP(mp1))
|
---|
| 918 | {
|
---|
| 919 | case BN_PAINT:
|
---|
| 920 | /* Paint the custom controls (buttons, sliders ) */
|
---|
| 921 | WinQueryWindowPos(hwnd,&swp);
|
---|
| 922 | if(swp.fl & SWP_MINIMIZE)
|
---|
| 923 | break;
|
---|
| 924 | return paintControls(hwnd, msg, mp1, mp2);
|
---|
| 925 | /*****************************************************/
|
---|
| 926 | /* Handle position and volume changes. */
|
---|
| 927 | /*****************************************************/
|
---|
| 928 | case SLN_SLIDERTRACK:
|
---|
| 929 | {
|
---|
| 930 | switch(SHORT1FROMMP(mp1))
|
---|
| 931 | {
|
---|
| 932 | case IDSL_MMPLAYERVOLUME:
|
---|
| 933 | {
|
---|
| 934 | ULONG ulValue;
|
---|
| 935 |
|
---|
| 936 | ulValue=LONGFROMMP(mp2);
|
---|
| 937 | ulVolume=ulValue;
|
---|
| 938 | sprintf(chrCommand,"SET wave%ld AUDIO VOLUME %ld WAIT", ulPid, ulVolume);
|
---|
| 939 | mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
| 940 | break;
|
---|
| 941 | }
|
---|
| 942 | case IDSL_MMPLAYERPOSBAR:
|
---|
| 943 | {
|
---|
| 944 | static long lLastPos=0;
|
---|
| 945 | long lPos=LONGFROMMP(mp2);
|
---|
[104] | 946 |
|
---|
[2] | 947 | bPosDragging=TRUE;
|
---|
| 948 | lPos*=ulTotalLength/100;
|
---|
| 949 | if(lPos/1000!=lLastPos) {
|
---|
| 950 | /* Prevent flickering */
|
---|
[108] | 951 | sprintf(chrCommand, "%li:%02li", lPos/1000/60, (lPos/1000)%60);
|
---|
[2] | 952 | WinSetWindowText(WinWindowFromID(hwnd, IDST_MMPLAYERPLAYTIME), chrCommand);
|
---|
| 953 | lLastPos=lPos/1000;
|
---|
| 954 | }
|
---|
| 955 | break;
|
---|
| 956 | }
|
---|
| 957 | default:
|
---|
| 958 | break;
|
---|
| 959 | }/* switch */
|
---|
| 960 | return (MRESULT) 0;
|
---|
| 961 | break;
|
---|
| 962 | }
|
---|
| 963 | case SLN_CHANGE:
|
---|
| 964 | {
|
---|
| 965 | switch(SHORT1FROMMP(mp1))
|
---|
| 966 | {
|
---|
| 967 | case IDSL_MMPLAYERVOLUME:
|
---|
| 968 | {
|
---|
| 969 | ULONG ulValue;
|
---|
[104] | 970 |
|
---|
[2] | 971 | ulValue=LONGFROMMP(mp2);
|
---|
| 972 | ulVolume=ulValue;
|
---|
| 973 | sprintf(chrCommand,"SET wave%ld AUDIO VOLUME %ld WAIT", ulPid, ulVolume);
|
---|
| 974 | mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
| 975 | break;
|
---|
| 976 | }
|
---|
| 977 | case IDSL_MMPLAYERPOSBAR:
|
---|
| 978 | {
|
---|
| 979 | long lPos=LONGFROMMP(mp2);
|
---|
| 980 |
|
---|
| 981 | bPosDragging=FALSE;
|
---|
[104] | 982 | lPos*=1000;
|
---|
[2] | 983 | lPos*=ulTotalLength/100;
|
---|
| 984 | lPos/=1000;// Use only full seconds
|
---|
| 985 |
|
---|
| 986 | /* Set time display first */
|
---|
| 987 | seekAudioFile(lPos);
|
---|
| 988 | /* restart timer */
|
---|
[104] | 989 | WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, IDTIMER_PLAY, PLAYTIMER_DELAY);
|
---|
[2] | 990 | ulPos=lPos/1000;
|
---|
| 991 | break;
|
---|
| 992 | }
|
---|
| 993 | default:
|
---|
| 994 | break;
|
---|
| 995 | }/* switch */
|
---|
| 996 | return (MRESULT)TRUE;
|
---|
| 997 | }
|
---|
| 998 | default:
|
---|
| 999 | break;
|
---|
| 1000 | }/* switch */
|
---|
| 1001 | break;
|
---|
| 1002 | }/* WM_CONTROL */
|
---|
| 1003 | default:
|
---|
| 1004 | break;
|
---|
| 1005 | }/* switch */
|
---|
[104] | 1006 |
|
---|
[2] | 1007 | return WinDefDlgProc( hwnd, msg, mp1, mp2);
|
---|
| 1008 | }
|
---|
| 1009 |
|
---|
| 1010 | BOOL cwGetStringFromEA( char * chrFileName, PSZ pKey, char * chrBuffer, ULONG ulBuffSize)
|
---|
| 1011 | {
|
---|
| 1012 | LONG rc; /* Ret code */
|
---|
| 1013 | UCHAR geabuff[300]; /* buffer for GEA */
|
---|
| 1014 | PVOID fealist; /* fealist buffer */
|
---|
| 1015 | EAOP2 eaop; /* eaop structure */
|
---|
| 1016 | PGEA2 pgea; /* pgea structure */
|
---|
| 1017 | PFEA2 pfea; /* pfea structure */
|
---|
| 1018 | HFILE handle; /* file handle */
|
---|
| 1019 | ULONG act; /* open action */
|
---|
| 1020 | ULONG ulSize;
|
---|
| 1021 | USHORT *ptrUs;
|
---|
| 1022 |
|
---|
| 1023 | if((fealist=malloc(0x00010000L /* Add some space */
|
---|
[108] | 1024 | ))==NULL)
|
---|
[2] | 1025 | return FALSE;
|
---|
[104] | 1026 |
|
---|
[2] | 1027 | ulSize=sizeof(chrFileName);
|
---|
[104] | 1028 |
|
---|
[2] | 1029 | if ((rc = DosOpen(chrFileName, &handle, &act,
|
---|
| 1030 | 0L, 0, OPEN_ACTION_OPEN_IF_EXISTS,
|
---|
| 1031 | OPEN_ACCESS_READONLY + OPEN_SHARE_DENYREADWRITE +
|
---|
| 1032 | OPEN_FLAGS_FAIL_ON_ERROR + OPEN_FLAGS_WRITE_THROUGH,NULL))!=NO_ERROR) {
|
---|
| 1033 | free(fealist); /* Free the memory */
|
---|
| 1034 | return FALSE;
|
---|
| 1035 | } /* get the file status info */
|
---|
| 1036 |
|
---|
| 1037 | /* FEA and GEA lists */
|
---|
| 1038 | eaop.fpGEA2List = (PGEA2LIST)geabuff;
|
---|
| 1039 | eaop.fpFEA2List = (PFEA2LIST)fealist;
|
---|
| 1040 | eaop.oError = 0; /* no error occurred yet */
|
---|
| 1041 | pgea = &eaop.fpGEA2List->list[0]; /* point to first GEA */
|
---|
| 1042 | eaop.fpGEA2List->cbList = sizeof(ULONG) + sizeof(GEA2) +
|
---|
| 1043 | strlen(pKey);
|
---|
| 1044 | eaop.fpFEA2List->cbList = (ULONG)0xffff;
|
---|
| 1045 |
|
---|
| 1046 | /* fill in the EA name length */
|
---|
| 1047 | pgea->cbName = (BYTE)strlen(pKey);
|
---|
| 1048 | strcpy(pgea->szName, pKey); /* fill in the name */
|
---|
| 1049 | pgea->oNextEntryOffset = 0; /* fill in the next offset */
|
---|
| 1050 | /* read the extended attribute*/
|
---|
| 1051 | rc = DosQueryFileInfo(handle, 3, (PSZ)&eaop, sizeof(EAOP2));
|
---|
| 1052 | DosClose(handle); /* close the file */
|
---|
| 1053 | if (eaop.fpFEA2List->cbList <= sizeof(ULONG))
|
---|
| 1054 | rc = ERROR_EAS_NOT_SUPPORTED; /* this is error also */
|
---|
| 1055 |
|
---|
| 1056 | if (rc) { /* failure? */
|
---|
| 1057 | free(fealist); /* Free the memory */
|
---|
| 1058 | return FALSE;
|
---|
| 1059 | }
|
---|
| 1060 |
|
---|
| 1061 | pfea = &(eaop.fpFEA2List->list[0]); /* point to the first FEA */
|
---|
| 1062 |
|
---|
| 1063 | ptrUs=(USHORT*)((PSZ)pfea->szName+(pfea->cbName+1));
|
---|
| 1064 | if(*ptrUs!=0xfffd) {
|
---|
| 1065 | /* Not an ASCII EA */
|
---|
| 1066 | free(fealist); /* Free the memory */
|
---|
| 1067 | return FALSE;
|
---|
| 1068 | }
|
---|
| 1069 | ptrUs++; /* Move to length */
|
---|
| 1070 | ulSize=(ULONG)*ptrUs;
|
---|
| 1071 |
|
---|
| 1072 | ptrUs++; /* Move to value */
|
---|
| 1073 | if(ulSize==0) {
|
---|
| 1074 | /* Not an ASCII EA */
|
---|
| 1075 | free(fealist); /* Free the memory */
|
---|
| 1076 | return FALSE;
|
---|
| 1077 | }
|
---|
| 1078 |
|
---|
| 1079 | memset(chrBuffer,0,ulBuffSize);
|
---|
| 1080 | memcpy(chrBuffer, (char*)ptrUs, (ulSize>=ulBuffSize ? ulBuffSize-1 : ulSize));
|
---|
| 1081 | free(fealist); /* Free the memory */
|
---|
| 1082 | return TRUE;
|
---|
| 1083 | }
|
---|
| 1084 |
|
---|
| 1085 | int readVolumeFromIni(char * iniFile, char* chrApp, char *chrKey, int iDefault)
|
---|
| 1086 | {
|
---|
| 1087 | return IniRestoreInt(iniFile, chrApp, chrKey, iDefault);
|
---|
| 1088 | }
|
---|
| 1089 |
|
---|
| 1090 | BOOL writeVolumeToIni(char * iniFile, char* chrApp, char *chrKey, ULONG ulVolume)
|
---|
| 1091 | {
|
---|
[104] | 1092 |
|
---|
[2] | 1093 | return IniSaveInt(iniFile, chrApp, chrKey, ulVolume);
|
---|
| 1094 | }
|
---|
| 1095 |
|
---|
| 1096 | int readDisplayTypeFromIni(char * iniFile, char* chrApp, char *chrKey, int iDefault)
|
---|
| 1097 | {
|
---|
| 1098 | return IniRestoreInt(iniFile, chrApp, chrKey, iDefault);
|
---|
| 1099 | }
|
---|
| 1100 |
|
---|
| 1101 | BOOL writeDisplayTypeToIni(char * iniFile, char* chrApp, char *chrKey, int iDisplay)
|
---|
| 1102 | {
|
---|
| 1103 | return IniSaveInt(iniFile, chrApp, chrKey, iDisplay);
|
---|
| 1104 | }
|
---|
| 1105 |
|
---|
| 1106 | ULONG mmIdentifyFile(char* chrFile)
|
---|
| 1107 | {
|
---|
[193] | 1108 | MMIOINFO mmioInfo = {0};
|
---|
| 1109 | MMFORMATINFO mmFormatInfo = {0};
|
---|
[2] | 1110 | FOURCC fourCC;
|
---|
[193] | 1111 | INT rc;
|
---|
[2] | 1112 |
|
---|
[193] | 1113 | rc=mmioIdentifyFile(chrFile, &mmioInfo, &mmFormatInfo, &fourCC, 0,0);
|
---|
| 1114 | if(rc!=MMIO_SUCCESS)
|
---|
[2] | 1115 | {
|
---|
[193] | 1116 | #ifdef _PMPRINTF_
|
---|
| 1117 | DebugHereIAm();
|
---|
| 1118 | #endif
|
---|
[104] | 1119 | return 0;
|
---|
[2] | 1120 | }
|
---|
[193] | 1121 | #ifdef _PMPRINTF_
|
---|
| 1122 | Pmpf(("MediaType %u", mmFormatInfo.ulMediaType));
|
---|
| 1123 | #endif
|
---|
[218] | 1124 | if(mmFormatInfo.ulMediaType==MMIO_MEDIATYPE_MIDI){
|
---|
| 1125 | bIsMidi = TRUE;
|
---|
[2] | 1126 | return 1; /* Midi */
|
---|
[218] | 1127 | }
|
---|
[2] | 1128 | /* Any other audio file */
|
---|
[218] | 1129 | bIsMidi = FALSE;
|
---|
[2] | 1130 | return 2;
|
---|
| 1131 | }
|
---|
| 1132 |
|
---|
| 1133 | int main (int argc, char *argv[])
|
---|
| 1134 | {
|
---|
| 1135 | HAB hab;
|
---|
| 1136 | HMQ hmq;
|
---|
| 1137 | char text[CCHMAXPATH];
|
---|
| 1138 | char title[CCHMAXPATH];
|
---|
| 1139 | short a;
|
---|
| 1140 | ULONG rc;
|
---|
| 1141 |
|
---|
| 1142 | /* Create a copy of the args */
|
---|
| 1143 | /* argv[0]: progname
|
---|
| 1144 | * argv[1]: audio file
|
---|
| 1145 | */
|
---|
| 1146 |
|
---|
| 1147 | numArgs=argc;
|
---|
| 1148 |
|
---|
| 1149 | strcpy(text,"");
|
---|
| 1150 | for(a=0;a<argc;a++)
|
---|
| 1151 | {
|
---|
| 1152 | params[a]=argv[a];
|
---|
| 1153 | }
|
---|
| 1154 |
|
---|
| 1155 | hab=WinInitialize(0);
|
---|
| 1156 | if(hab) {
|
---|
| 1157 | hmq=WinCreateMsgQueue(hab,0);
|
---|
[104] | 1158 | if(hmq) {
|
---|
| 1159 | /* Check if user started prog by hand */
|
---|
[2] | 1160 | if(argc!=NUMPARAMS) {/* Not the right num of params */
|
---|
| 1161 | pmUsage();
|
---|
| 1162 | }
|
---|
| 1163 | else {
|
---|
| 1164 | PTIB ptib;
|
---|
| 1165 | PPIB ppib;
|
---|
| 1166 |
|
---|
| 1167 | /* Save source name */
|
---|
| 1168 | strcpy(chrSourceName, params[1]);
|
---|
| 1169 | //strcpy(chrSourceName, "H:\\cwmm\\classes\\mm-progs\\MMPlayer\\01 Vicious Circle - Propaganda - 1234.WAV");
|
---|
| 1170 | if((chrPtrName=strrchr(chrSourceName, '\\'))!=NULLHANDLE)
|
---|
| 1171 | ++chrPtrName;
|
---|
| 1172 |
|
---|
[193] | 1173 | rc=mmIdentifyFile(chrSourceName);
|
---|
| 1174 | if(rc==0)
|
---|
[2] | 1175 | {
|
---|
[193] | 1176 | #ifdef _PMPRINTF_
|
---|
| 1177 | DebugHereIAm();
|
---|
| 1178 | #endif
|
---|
| 1179 | /* FIXME: Identify error !!!*/
|
---|
[104] | 1180 |
|
---|
[2] | 1181 | };
|
---|
[193] | 1182 | #ifdef _PMPRINTF_
|
---|
| 1183 | Pmpf(("rc %u", rc));
|
---|
| 1184 | #endif
|
---|
[2] | 1185 | if(rc==1)
|
---|
[193] | 1186 | {
|
---|
| 1187 | /* It's a MIDI file */
|
---|
[2] | 1188 | bIsMidi=TRUE;
|
---|
| 1189 | }
|
---|
| 1190 | else
|
---|
| 1191 | bIsMidi=FALSE;
|
---|
| 1192 |
|
---|
| 1193 | /* Class name. We need it to distinguish MIDI and audio files */
|
---|
| 1194 | if(argc==3)
|
---|
| 1195 | strcpy(chrClassName, params[1]);
|
---|
| 1196 |
|
---|
[104] | 1197 | /* Get our ressource dll */
|
---|
[2] | 1198 | // RESSOURCEHANDLE=0;
|
---|
| 1199 | RESSOURCEHANDLE=queryResModuleHandle(argv[0]);
|
---|
| 1200 | /* Get data from INI file */
|
---|
| 1201 | HlpBuildMMProgIniFileName(argv[0], chrIniFile, sizeof(chrIniFile));
|
---|
| 1202 | ulVolume=readVolumeFromIni(chrIniFile, INI_MMPLAYER_APP, INI_VOLUME_KEY, DEFAULT_VOLUME);
|
---|
| 1203 | iWhichDisplay=readDisplayTypeFromIni(chrIniFile, INI_MMPLAYER_APP, INI_DISPLAY_KEY, 0);
|
---|
| 1204 |
|
---|
| 1205 | /* Load pointer for slider */
|
---|
| 1206 | hptrArrowWE=WinLoadPointer(HWND_DESKTOP, BMP_RESSOURCEHANDLE /*_queryResModuleHandle()*/, IDPTR_ARROWWE);
|
---|
| 1207 | /* Register the slider window class */
|
---|
| 1208 | WinRegisterClass(WinQueryAnchorBlock(HWND_DESKTOP), SLIDER_CLASS, privateSliderProc,0, SLADDBYTES);
|
---|
| 1209 |
|
---|
[104] | 1210 | _loadBmps();
|
---|
[2] | 1211 | DosGetInfoBlocks(&ptib, &ppib);
|
---|
| 1212 | ulPid=ppib->pib_ulpid;
|
---|
| 1213 | _beginthread(playThreadFunc,NULL,8192*16, NULLHANDLE); //Fehlerbehandlung fehlt
|
---|
| 1214 |
|
---|
[104] | 1215 | if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, decodeStatusDialogProc,
|
---|
[2] | 1216 | RESSOURCEHANDLE, IDDLG_MMPLAYER, 0) == DID_ERROR )
|
---|
| 1217 | {
|
---|
| 1218 | /*
|
---|
[104] | 1219 | Text:
|
---|
| 1220 | Title: "Installation problem"
|
---|
| 1221 | */
|
---|
[2] | 1222 | messageBox( text, IDSTR_CONVERTDIALOGERROR , sizeof(text),
|
---|
| 1223 | title, IDSTR_INSTALLERRORTITLE , sizeof(title),
|
---|
| 1224 | RESSOURCEHANDLE, HWND_DESKTOP, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE);
|
---|
| 1225 | freeResHandle();
|
---|
| 1226 | WinDestroyMsgQueue( hmq );
|
---|
| 1227 | WinTerminate( hab );
|
---|
| 1228 | DosBeep(100,600);
|
---|
| 1229 | return( 1 );
|
---|
| 1230 | }
|
---|
| 1231 | }
|
---|
| 1232 | freeResHandle();
|
---|
| 1233 | WinDestroyMsgQueue(hmq);
|
---|
| 1234 | }
|
---|
| 1235 | WinTerminate(hab);
|
---|
| 1236 | }
|
---|
| 1237 | return 0;
|
---|
| 1238 | }
|
---|
| 1239 |
|
---|