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