home *** CD-ROM | disk | FTP | other *** search
- #include "audiofolder.hh"
- #include "audiofolderhelp.h"
-
- #include <stdio.h>
-
-
- HMODULE queryModuleHandle(void);
- ULONG launchWriter(PSZ parameter, PSZ folderPath,HWND hwnd,PSZ wrapperExe);
- PSZ buildAudioWriteParam(CWAudioFolder* thisPtr, PSZ trackname);
- MRESULT EXPENTRY writeStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) ;
-
- extern BOOL setupDone;
- extern BOOL bGrabberFirst;
- extern ATOM atomStartWrite;
-
- extern char chrCDRecord[CCHMAXPATH];/* Path to cdrecord */
- extern char chrCDROptions[CCHMAXPATH];
- extern LONG lCDROptions;
-
-
-
-
-
-
- MRESULT EXPENTRY writeObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
- {
- CWAudioFolder * thisPtr;
- SHORT a;
- SIZEL sizel;
- ULONG ulFlags;
- HWND hwndLB;
- char text[CCHMAXPATH];
- char parameter[CCHMAXPATH*2];
- char folderName[CCHMAXPATH];
- HWND hwndTemp;
- ULONG ulSize;
- ULONG rc;
- char statusText[100];
- ULONG ulDrive;
-
- switch (msg)
- {
- case WM_APPTERMINATENOTIFY:
- /* The last track is written. The wrapper program has ended */
- rc=MBID_YES;
- if(LONGFROMMP(mp2)!=0) {
- if(!WinLoadString(WinQueryAnchorBlock(hwnd),queryModuleHandle(),IDSTR_WRITEERRORTEXT,sizeof(text),text))
- sprintf(text,"CDRecord/2 returned a Non-zero resultcode. The written track is probably corrupted. \
- Do you want to continue writing?");
- if(!WinLoadString(WinQueryAnchorBlock(hwnd),queryModuleHandle(),IDSTR_WRITEERRORTITLE, sizeof(statusText),
- statusText))
- sprintf(statusText,"CD writing error!");
- rc=WinMessageBox( HWND_DESKTOP, hwnd, text, statusText, 0UL, MB_YESNO | MB_ICONEXCLAMATION|MB_MOVEABLE );
- }
- thisPtr=(CWAudioFolder*) WinQueryWindowULong(hwnd,QWL_USER);
- if(thisPtr && rc==MBID_YES) {
- /* Continue writing */
- hwndLB=thisPtr->hwndWriteLB;/* Get write track listbox hwnd */
- if(thisPtr->cwQueryWriteEnabled() && WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),hwndLB)) {
- /* User hasn't canceled the write */
- thisPtr->bWrite++;
- if(thisPtr->bWrite < thisPtr->aWrite) {
- /* Get first trackname */
- if(!WinSendMsg(hwndLB,LM_QUERYITEMTEXT,MPFROM2SHORT((SHORT)thisPtr->bWrite,(SHORT)CCHMAXPATH),&text)) {
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- }
- /* Get folder name */
- ulSize=sizeof(folderName);
- thisPtr->wpQueryRealName(folderName,&ulSize,TRUE);
-
- /*********** Build commandline ******************/
- /* Build writer param line */
- sprintf(parameter,"%s",buildAudioWriteParam(thisPtr,text));
-
- /* Update status window */
- sprintf(statusText,"Writing track %d of %d ",thisPtr->bWrite+1,thisPtr->aWrite);
- WinSetWindowText(WinWindowFromID(thisPtr->hwndWriteStatus,IDST_WRITESTATUS),statusText);
-
- /* Check for CD-Size here */
-
- launchWriter(parameter,folderName,hwnd,"cdr2lnch.exe");
- /* end of writer start */
-
- return (MRESULT)TRUE;
- }/* if(thisPtr->bWrite < thisPtr->aWrite) */
- }/* thisPtr->cwQueryGrabEnabled() */
- }/* end of if(thisPtr) */
- if(thisPtr) {
- /* Destroy write status window */
- WinDestroyWindow(thisPtr->hwndWriteStatus);
- thisPtr->hwndWriteStatus=NULL;
-
- /* Enable windows in write dialog */
- thisPtr->cwEnableWriteControls(TRUE);
-
- /* Enable windows in selection dialog */
- thisPtr->cwEnableSelectControls(TRUE);
- }
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
-
- default:
- if(msg == atomStartWrite) {
- /* Start write message */
- thisPtr=(CWAudioFolder*)PVOIDFROMMP(mp1);
- WinSetWindowULong(hwnd,QWL_USER,(ULONG)thisPtr);/* Save object ptr */
- if(!thisPtr) {
- /* Error: quit */
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- }
-
- hwndLB=thisPtr->hwndWriteLB;
- if(!WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),hwndLB)) {
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- }
-
- /* Get num tracks to write */
- thisPtr->aWrite=(int)LONGFROMMR(WinSendMsg(hwndLB,LM_QUERYITEMCOUNT,0,0));
- if(!thisPtr->aWrite) {/* We have no tracks */
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- }
- thisPtr->bWrite=0;
-
- /* Get first trackname */
- if(!WinSendMsg(hwndLB,LM_QUERYITEMTEXT,MPFROM2SHORT((SHORT)thisPtr->bWrite,(SHORT)CCHMAXPATH),&text)) {
- WinPostMsg(hwnd,WM_QUIT,(MPARAM)0,(MPARAM)0);
- return 0;
- }
- thisPtr->cwEnableWrite(TRUE);
-
- /* Get folder name */
- ulSize=sizeof(folderName);
- thisPtr->wpQueryRealName(folderName,&ulSize,TRUE);
-
- /*********** Build commandline ******************/
- /* Build grabber param line */
- sprintf(parameter,"%s",buildAudioWriteParam(thisPtr,text));
-
- /*************** Start the writer here ****************/
- /* Build status window */
- thisPtr->hwndWriteStatus=WinLoadDlg(HWND_DESKTOP,HWND_DESKTOP,
- writeStatusDialogProc,queryModuleHandle(),IDDLG_WRITESTATUS,thisPtr);
-
- // sprintf(text,"hwndWriteStatus=%x",thisPtr->hwndWriteStatus);
- // WinMessageBox( HWND_DESKTOP, hwnd, text, "Debug", 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
-
- sprintf(statusText,"Writing track %d of %d ",thisPtr->bWrite+1,thisPtr->aWrite);
- WinSetWindowText(WinWindowFromID(thisPtr->hwndWriteStatus,IDST_WRITESTATUS),statusText);
-
- /* Check for CD-Size here */
-
- launchWriter(parameter,folderName,hwnd,"cdr2lnch.exe");
- /* end of writer start */
- return 0;
- }
- break;
- }
- return WinDefWindowProc( hwnd, msg, mp1, mp2);
- }
-
-
- /* This thread handles the writing */
- void _Optlink writeThreadFunc (void *arg)
- {
- HWND hwndWrite;
- HAB hab;
- HMQ hmq;
- QMSG qmsg;
-
- CWAudioFolder * thisPtr;
-
- thisPtr=(CWAudioFolder*)arg;
- thisPtr->wpLockObject();
-
- hab=WinInitialize(0);
- if(hab) {
- hmq=WinCreateMsgQueue(hab,0);
- if(hmq) {
- hwndWrite=WinCreateWindow(HWND_OBJECT,WC_STATIC,"myWriteObj",0,0,0,0,0,NULL,HWND_BOTTOM,12345,NULL,NULL);
- if(hwndWrite) {
- WinSubclassWindow(hwndWrite,&writeObjectProc);
- /* write window created. Start writing */
- WinPostMsg(hwndWrite,atomStartWrite,MPFROMP(thisPtr),0);
- while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
- WinDispatchMsg(hab,&qmsg);
- WinDestroyWindow(hwndWrite);
- }
- WinDestroyMsgQueue(hmq);
- }
- WinTerminate(hab);
- }
- thisPtr->wpUnlockObject();
- thisPtr->tidWrite=0;
- WinPostMsg(WinQueryWindow(thisPtr->hwndWriteLB,QW_PARENT),WM_CLOSE,0,0);
- thisPtr->hwndWriteLB=NULL;
-
- //DosBeep(100,2000);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-