Index: /branches/v2.9_Lars/mediafolder/c/mediafldr/mediafolder.cpp
===================================================================
--- /branches/v2.9_Lars/mediafolder/c/mediafldr/mediafolder.cpp	(revision 123)
+++ /branches/v2.9_Lars/mediafolder/c/mediafldr/mediafolder.cpp	(revision 124)
@@ -1,5 +1,5 @@
 /*
  * This file is (C) Chris Wohlgemuth 2002
- * 
+ *
  * It's part of the Media-Folder distribution
  */
@@ -69,5 +69,5 @@
   switch(ulAction)
     {
-    case PLAY_FIRST:  
+    case PLAY_FIRST:
       /* Send a message to the object window created by the folder play thread */
       WinPostMsg(thisPtr->mfData->hwndPlayObject,WM_APPTERMINATENOTIFY, 0,MPFROMLONG(PLAY_FIRST));
@@ -146,5 +146,5 @@
               thisPtr->cwSeekAudioFile(LONGFROMMP(mp1));
               /* restart timer */
-              //    WinStartTimer(WinQueryAnchorBlock(hwnd), WinWindowFromID(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY);  
+              //    WinStartTimer(WinQueryAnchorBlock(hwnd), WinWindowFromID(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY);
               thisPtr->ulPos=LONGFROMMP(mp1)/1000;
             }
@@ -192,6 +192,6 @@
       if(hwnd) {
         thisPtr->mfData->hwndPlayObject=hwnd;
+        WinSetWindowULong(hwnd, QWL_USER,(ULONG)tPt);
         WinSubclassWindow(hwnd,&playObjectProc);
-        WinSetWindowULong(hwnd, QWL_USER,(ULONG)tPt);
         /* Window created. */
         while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
@@ -225,5 +225,5 @@
     return;
 
-  thisPtr=(CWMediaFolder*)threadParms->thisPtr;   
+  thisPtr=(CWMediaFolder*)threadParms->thisPtr;
 
   if(!somIsObj(thisPtr))
@@ -247,5 +247,5 @@
   if(!((WPFileSystem*)thisPtr->wpObjM3UFile)->wpQueryRealName(chrFileName, &ulSize, TRUE))
     return;
-  
+
   /* Get name of folder */
   ulSize=CCHMAXPATH;
@@ -256,5 +256,5 @@
   if(hab) {
     hmq=WinCreateMsgQueue(hab,0);
-    if(hmq) {      
+    if(hmq) {
       RXSTRING arg[2];                    /* argument string for REXX  */
       RXSTRING rexxretval;                /* return value from REXX    */
@@ -266,8 +266,8 @@
       /* We could provide a buffer for the interpreter to use instead. */
       rexxretval.strlength = 0L;          /* initialize return to empty*/
-      
+
       MAKERXSTRING(arg[0], chrFileName, strlen(chrFileName));/* create input argument     */
-      MAKERXSTRING(arg[1], chrFolderName, strlen(chrFolderName));/* create input argument     */              
-      
+      MAKERXSTRING(arg[1], chrFolderName, strlen(chrFolderName));/* create input argument     */
+
       TRY_LOUD(RX_START) {
         /* Here we call the interpreter.  We don't really need to use    */
@@ -285,15 +285,15 @@
                      (PSHORT)     &rexxrc,       /* Rexx program output   */
                      (PRXSTRING)  &rexxretval ); /* Rexx program output   */
-        
+
         if(rc) {
-          sprintf(chrFileName,"Error in the Rexx skript %s\n\n Get more information with 'help REX%04d'.\n", 
+          sprintf(chrFileName,"Error in the Rexx skript %s\n\n Get more information with 'help REX%04d'.\n",
                   "", rc*-1);
           WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrFileName, "", 1234, MB_OK|MB_MOVEABLE|MB_ERROR);
         }
-        DosFreeMem(rexxretval.strptr);          /* Release storage given to us by REXX.  */      
+        DosFreeMem(rexxretval.strptr);          /* Release storage given to us by REXX.  */
       }
       CATCH(RX_START)
         {}END_CATCH;
-               
+
         WinDestroyMsgQueue(hmq);
     }
@@ -301,5 +301,5 @@
   }
   //  thisPtr->fContentsChanged=FALSE;
-  thisPtr->wpFreeMem((PBYTE)chrFileName); 
+  thisPtr->wpFreeMem((PBYTE)chrFileName);
   thisPtr->wpFreeMem((PBYTE)threadParms);
 }
@@ -372,5 +372,5 @@
 
         WinSetWindowPos(hwndFrame, NULLHANDLE, swp2.x, swp2.y, swp2.cx,swp2.cy,SWP_SIZE|SWP_MOVE);
-        /* 
+        /*
            By changing the to contents view we trick the WPS to show the 'Details view' menu item in
            the view menu of the folders system menu. In that sub menu the WPS always inserts all known
@@ -379,5 +379,5 @@
            The system knows nothing about the 'compact view' and all the handling is done by us.
            As a side effect the folder position information for the details
-           view isn't changed when the folder is closed in 'Compact view'. 
+           view isn't changed when the folder is closed in 'Compact view'.
            */
         wpMenuItemSelected(hwndFrame, 0x2cc);
@@ -419,5 +419,5 @@
                             ",", chrBuf, sizeof(chrBuf));
       chrBuf[sizeof(chrBuf)-1]=0;
-      
+
       if(mfData->ulTotalTime<=3600) {
         getMessage( text, IDSTR_STATUSTIME1, sizeof(text), queryResModuleHandle(), HWND_DESKTOP);
@@ -432,8 +432,8 @@
         sprintf(time, text, mfData->ulTotalTime/(3600*24),
                 (mfData->ulTotalTime%(3600*24))/3600,  (mfData->ulTotalTime%3600)/60, mfData->ulTotalTime%60);
-      }      
+      }
       if(mfData->ulSize<=0xffffffff) {
         getMessage( text2, IDSTR_STATUSTIME4, sizeof(text2), queryResModuleHandle(),HWND_DESKTOP);
-        sprintf(text, text2, 
+        sprintf(text, text2,
                 mfData->ulNumTracks, mfData->ulSize/1000000 ,chrBuf, (mfData->ulSize%1000000)/1000,
                 chrBuf,  mfData->ulSize%1000,
@@ -488,5 +488,5 @@
   getMessage(pageName, IDSTRSETTING_TOOLBAR, sizeof(pageName), queryResModuleHandle(), hwndNotebook);
   pageinfo.pszName = pageName;
-  
+
   //Insert the page into the settings notebook
   return wpInsertSettingsPage(hwndNotebook,&pageinfo);
@@ -497,5 +497,5 @@
   PMINIRECORDCORE mrc;
   WPObject * contentObject;
-  
+
   /* See if we have an audio file played with doubleclick */
   mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST),
@@ -551,5 +551,5 @@
   /* Get new ID for wave device */
   if(cwRequestMutex(hmtxFileName, 100000)==ERROR_TIMEOUT)
-    return FALSE;  
+    return FALSE;
 
   iWaveDev++;
@@ -565,8 +565,8 @@
       WPObject *wpObject;
       PMINIRECORDCORE pmrc;
-      
+
 #if 0
       /* There's already a file playing using doubleclick */
-      if(mmGetOtherPlayingAudioFile( this, hwndContainer, &wpObject, &pmrc)) 
+      if(mmGetOtherPlayingAudioFile( this, hwndContainer, &wpObject, &pmrc))
         return 0;
 #endif
@@ -605,6 +605,6 @@
         else
           return 0;/* Error */
-        
-        if( contentObject->somIsA(cwAudioClass) || 
+
+        if( contentObject->somIsA(cwAudioClass) ||
            /*contentObject->somIsA(mmAudioClass) ||*/
            contentObject->somIsA(mmMIDIClass)) {
@@ -643,5 +643,5 @@
                                     MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
 
-    if((int)mrc==-1) { 
+    if((int)mrc==-1) {
       /* Wrong parameter -> user deleted the shadow. */
       /* Stop wave, remove in use emphasis. */
@@ -650,7 +650,7 @@
     }
     //  HlpWriteToTrapLog("Next mrc is %x\n", mrc);
- 
+
     notFound=TRUE;
-    while(notFound && mrc && (int)mrc!=-1){ 
+    while(notFound && mrc && (int)mrc!=-1){
       contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
       if(somIsObj(contentObject)) {
@@ -664,5 +664,5 @@
       else
         return 0;/* Error */
-      
+
       if(contentObject->somIsA(cwAudioClass) ||
          /* contentObject->somIsA(mmAudioClass) || */
@@ -701,5 +701,5 @@
         /* Select the object */
         WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(pmrc),
-                   MPFROM2SHORT(TRUE, CRA_SELECTED));  
+                   MPFROM2SHORT(TRUE, CRA_SELECTED));
 
         return cwPlayAudioFile(hwndFrame, PLAY_FIRST);/* Not yet playing, so start the first one. */
@@ -709,5 +709,5 @@
         return cwPlayAudioFile(hwndFrame, PLAY_FIRST);/* Not yet playing, so start the first one. */
     }
- 
+
     /* Check the current time. If we are at the very beginning of the track skip to the previous track
        otherwise skip to the beginning of the current track. */
@@ -727,5 +727,5 @@
     /* Find an audio file */
     notFound=TRUE;
-    while(notFound && mrc && (int)mrc!=-1){ 
+    while(notFound && mrc && (int)mrc!=-1){
       contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
       if(somIsObj(contentObject)) {
@@ -741,5 +741,5 @@
 
       /* Check if it's an audio file thus playable */
-      if(contentObject->somIsA(cwAudioClass) || 
+      if(contentObject->somIsA(cwAudioClass) ||
          /*   contentObject->somIsA(mmAudioClass) || */
          contentObject->somIsA(mmMIDIClass)) {
@@ -755,5 +755,5 @@
     if(!mrc)
       return 0;
-    
+
     break;
   default:
@@ -771,10 +771,10 @@
   else /*if(contentObject->somIsA(cwAudioClass) || contentObject->somIsA(mmAudioClass))*/
     strncpy(chrDevice,"WAVEAUDIO", sizeof(chrDevice));
-  
+
   chrDevice[sizeof(chrDevice)-1]=0;
 
   hwndNotify=playControlDialogFromFrameHWND(hwndFrame);//WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE);
 
-  /* Start audio file */  
+  /* Start audio file */
   sprintf(chrCommand,"open \"%s\"  type %s alias wave%d SHAREABLE wait",name, chrDevice, iWavePriv);
   rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwndNotify, 0);
@@ -789,5 +789,5 @@
     rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
     return 0;
-  }      
+  }
 
   sprintf(chrCommand,"SETPOSITIONADVISE wave%d ON EVERY 1000 notify", iWavePriv);
@@ -829,8 +829,8 @@
   }
 
-  /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave. 
+  /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave.
      Don't know why. */
 
-  //WinStartTimer(WinQueryAnchorBlock(hwndFrame), WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDTIMER_PLAY, PLAYTIMER_DELAY);  
+  //WinStartTimer(WinQueryAnchorBlock(hwndFrame), WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDTIMER_PLAY, PLAYTIMER_DELAY);
   WinStartTimer(WinQueryAnchorBlock(hwndFrame), playControlDialogFromFrameHWND(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY);
 
@@ -849,5 +849,5 @@
   /* Select the object */
   WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc),
-             MPFROM2SHORT(TRUE, CRA_SELECTED));  
+             MPFROM2SHORT(TRUE, CRA_SELECTED));
 
   iWave=iWavePriv;
@@ -872,5 +872,5 @@
   BOOL bFound=FALSE;
 
-  /** Get a random number in the appropriate range                    */  
+  /** Get a random number in the appropriate range                    */
   DosGetDateTime((PDATETIME)&DT);      /* Get the time               */
   seed = DT.hours*60 + DT.minutes;     /* convert to hundreths       */
@@ -885,5 +885,5 @@
 
 #ifdef RANDOM_DEBUG
-    HlpWriteToTrapLog("\n     Zufall: %d       %d\n", zufall, mfData->pRandomArray[zufall]);  
+    HlpWriteToTrapLog("\n     Zufall: %d       %d\n", zufall, mfData->pRandomArray[zufall]);
 #endif
     /* Get a random number in the appropriate range */
@@ -891,5 +891,5 @@
       mfData->pRandomArray[zufall]=1;
 #ifdef RANDOM_DEBUG
-      HlpWriteToTrapLog("2     Zufall: %d       %d\n", zufall, mfData->pRandomArray[zufall]);  
+      HlpWriteToTrapLog("2     Zufall: %d       %d\n", zufall, mfData->pRandomArray[zufall]);
 #endif
       return zufall;
@@ -900,5 +900,5 @@
     if (zufall == start && !bFound) {
 #ifdef RANDOM_DEBUG
-      HlpWriteToTrapLog("Error     Zufall: %d       %d\n", zufall, mfData->pRandomArray[zufall]);  
+      HlpWriteToTrapLog("Error     Zufall: %d       %d\n", zufall, mfData->pRandomArray[zufall]);
 #endif
       return -1;
@@ -944,5 +944,5 @@
   /* Check if we currently play the last track. */
   if((mfData->iNumPlayed>=mfData->iNumToPlay) && mfData->pRandomArray) {
-    cwStopAudioFile(hwndFrame);/* Reset playing vars and remove in use emphasis */        
+    cwStopAudioFile(hwndFrame);/* Reset playing vars and remove in use emphasis */
     if(!(ulFlags&FLAG_REPEAT))
       return 0;
@@ -959,5 +959,5 @@
   /* Get new ID for wave device */
   if(cwRequestMutex(hmtxFileName, 100000)==ERROR_TIMEOUT)
-    return FALSE;  
+    return FALSE;
   iWaveDev++;
   if(iWaveDev==1000)
@@ -1009,5 +1009,5 @@
   /* Find an audio file */
   notFound=TRUE;
-  while(notFound){ 
+  while(notFound){
     /* Find track to play */
     if((iTrack=_getRandomTrack(mfData))==-1) {
@@ -1022,5 +1022,5 @@
   HlpWriteToTrapLog("%s: _getRandomTrack returned: %d.\n", __FUNCTION__, iTrack);
 #endif
-    
+
     for(a=0,mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD,NULL,
                                             MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
@@ -1039,5 +1039,5 @@
 #endif
 
-    if(!mrc) 
+    if(!mrc)
       {
 #ifdef RANDOM_DEBUG
@@ -1053,5 +1053,5 @@
 
     /* Check if it's an audio file thus playable */
-    if(contentObject->somIsA(cwAudioClass) || 
+    if(contentObject->somIsA(cwAudioClass) ||
        /*       contentObject->somIsA(mmAudioClass) ||*/
        contentObject->somIsA(mmMIDIClass)) {
@@ -1083,10 +1083,10 @@
   else /*if(contentObject->somIsA(cwAudioClass) || contentObject->somIsA(mmAudioClass))*/
     strncpy(chrDevice,"WAVEAUDIO", sizeof(chrDevice));
-  
+
   chrDevice[sizeof(chrDevice)-1]=0;
 
   hwndNotify=playControlDialogFromFrameHWND(hwndFrame);//WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE);
 
-  /* Start audio file */  
+  /* Start audio file */
   sprintf(chrCommand,"open \"%s\"  type %s alias wave%d SHAREABLE wait",name, chrDevice, iWavePriv);
   rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwndNotify, 0);
@@ -1100,5 +1100,5 @@
     rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
     return 0;
-  }      
+  }
 
   sprintf(chrCommand,"SETPOSITIONADVISE wave%d ON EVERY 1000 notify", iWavePriv);
@@ -1140,8 +1140,8 @@
     return 0;
   }
-  /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave. 
+  /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave.
      Don't know why. */
-  //  WinStartTimer(WinQueryAnchorBlock(hwndFrame), WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDTIMER_PLAY, PLAYTIMER_DELAY);  
-  WinStartTimer(WinQueryAnchorBlock(hwndFrame), playControlDialogFromFrameHWND(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY);  
+  //  WinStartTimer(WinQueryAnchorBlock(hwndFrame), WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDTIMER_PLAY, PLAYTIMER_DELAY);
+  WinStartTimer(WinQueryAnchorBlock(hwndFrame), playControlDialogFromFrameHWND(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY);
 
   /* Set emphasis by adding the object to the inuse list */
@@ -1158,5 +1158,5 @@
   /* Select the object */
   WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc),
-             MPFROM2SHORT(TRUE, CRA_SELECTED));  
+             MPFROM2SHORT(TRUE, CRA_SELECTED));
 
   iWave=iWavePriv;
@@ -1187,11 +1187,11 @@
         mfData->iNumPlayed=0;
       }
-      
+
       sprintf(chrCommand,"stop wave%d wait", iWave);
       rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
-      
+
       sprintf(chrCommand,"close wave%d wait", iWave);
       rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
-      
+
       _resetDisplay(this);
         //_resetDisplay(topControlFromFrameHWND(hwndFrame));
@@ -1207,12 +1207,12 @@
               myViewItem.bIsInUseList=FALSE;
         };
-      
+
       //HlpWriteToTrapLog("\n1 line %d.\n");
-      
+
       /* Deselect the object */
       if(WinIsWindow(WinQueryAnchorBlock(hwndFrame), hwndContainer))
         WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrcPlaying),
-                   MPFROM2SHORT(FALSE, CRA_SELECTED));  
-      
+                   MPFROM2SHORT(FALSE, CRA_SELECTED));
+
       iWave=0;
       currentObject=NULLHANDLE;
@@ -1234,5 +1234,5 @@
 #endif
           WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc),
-                     MPFROM2SHORT(FALSE, CRA_SELECTED));        
+                     MPFROM2SHORT(FALSE, CRA_SELECTED));
         }
 #if 0
@@ -1258,5 +1258,5 @@
                   ulPos=0;
                   WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc),
-                             MPFROM2SHORT(FALSE, CRA_SELECTED));  
+                             MPFROM2SHORT(FALSE, CRA_SELECTED));
 
                 };
@@ -1273,5 +1273,5 @@
                         __FUNCTION__, __FILE__, __LINE__);
     } END_CATCH;
-    
+
     return TRUE;
 }
@@ -1323,10 +1323,10 @@
   if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     /* Problem with MCI. Clean up. The Timer will be stopped in the method */
-    cwStopAudioFile(hwndFrame); 
+    cwStopAudioFile(hwndFrame);
   }
   else {
     if(!stricmp(retMsg, "stopped")) {
       /* Audio file played. Start next */
-      cwPlayAudioFile(hwndFrame, PLAY_NEXT); 
+      cwPlayAudioFile(hwndFrame, PLAY_NEXT);
     }
     showPlayTimeDisplay(this, TRUE);/* Ensure display is visible */
