home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Multimedia Jumpstart 1.1a / CD_ROM.BIN / develpmt / source / waveconv / riffsup.c < prev    next >
C/C++ Source or Header  |  1992-09-12  |  20KB  |  767 lines

  1. /** RIFFsup.c
  2.  *
  3.      (C) Copyright Microsoft Corp. 1991, 1992.  All rights reserved.
  4.  
  5.      You have a royalty-free right to use, modify, reproduce and 
  6.      distribute the Sample Files (and/or any modified version) in 
  7.      any way you find useful, provided that you agree that 
  8.      Microsoft has no warranty obligations or liability for any 
  9.      Sample Application Files which are modified. 
  10.      
  11.      If you did not get this from Microsoft Sources, then it may not be the
  12.      most current version.  This sample code in particular will be updated
  13.      and include more documentation.  
  14.  
  15.      Sources are:
  16.          The MM Sys File Transfer BBS: The phone number is 206 936-4082.
  17.     CompuServe: WINSDK forum, MDK section.
  18.     Anonymous FTP from ftp.uu.net vendor\microsoft\multimedia
  19.  *
  20.  ** */
  21.  
  22.  
  23. //
  24. //  the includes we need
  25. //
  26. #define STRICT
  27. #include <windows.h>
  28. #include <windowsx.h>
  29. #include <mmsystem.h>
  30. #include "mmreg.h"
  31. #include "riffsup.h"
  32.  
  33.  
  34. #if (_MSC_VER < 700)
  35. //
  36. //  this silly stuff is to get around a bug in the C6 compiler's optimizer
  37. //
  38. #ifdef GlobalFreePtr
  39. #undef GlobalFreePtr
  40. #define GlobalFreePtr(x)    GlobalFree((HGLOBAL)SELECTOROF(x))
  41. #endif
  42.  
  43. #endif
  44.  
  45. #define MAXSTR      255
  46.  
  47. static char        szBuf[MAXSTR];
  48.  
  49.  
  50.  
  51. LRESULT NEAR PASCAL riffParseINFO(const LPINFOCHUNK lpInfo);
  52.  
  53.  
  54. /** BOOL RIFFAPI riffCopyChunk(HMMIO hmmioSrc, HMMIO hmmioDst, const LPMMCKINFO lpck)
  55.  *
  56.  *  DESCRIPTION:
  57.  *      
  58.  *
  59.  *  ARGUMENTS:
  60.  *      (LPWAVECONVCB lpwc, LPMMCKINFO lpck)
  61.  *
  62.  *  RETURN (BOOL NEAR PASCAL):
  63.  *
  64.  *
  65.  *  NOTES:
  66.  *
  67.  **  */
  68.  
  69. BOOL RIFFAPI riffCopyChunk(HMMIO hmmioSrc, HMMIO hmmioDst, const LPMMCKINFO lpck)
  70. {
  71.     MMCKINFO    ck;
  72.     HPSTR       hpBuf;
  73.  
  74.     //
  75.     //
  76.     //
  77.     hpBuf = (HPSTR)GlobalAllocPtr(GHND, lpck->cksize);
  78.     if (!hpBuf)
  79.         return (FALSE);
  80.  
  81.     ck.ckid   = lpck->ckid;
  82.     ck.cksize = lpck->cksize;
  83.     if (mmioCreateChunk(hmmioDst, &ck, 0))
  84.     goto rscc_Error;
  85.     
  86.     if (mmioRead(hmmioSrc, hpBuf, lpck->cksize) != (LONG)lpck->cksize)
  87.         goto rscc_Error;
  88.  
  89.     if (mmioWrite(hmmioDst, hpBuf, lpck->cksize) != (LONG)lpck->cksize)
  90.         goto rscc_Error;
  91.  
  92.     if (mmioAscend(hmmioDst, &ck, 0))
  93.         goto rscc_Error;
  94.  
  95.     if (hpBuf)
  96.         GlobalFreePtr(hpBuf);
  97.  
  98.     return (TRUE);
  99.  
  100. rscc_Error:
  101.  
  102.     if (hpBuf)
  103.         GlobalFreePtr(hpBuf);
  104.  
  105.     return (FALSE);
  106. } /* RIFFSupCopyChunk() */
  107.  
  108. /** BOOL RIFFAPI riffCopyList(HMMIO hmmioSrc, HMMIO hmmioDst, const LPMMCKINFO lpck)
  109.  *
  110.  *  DESCRIPTION:
  111.  *      
  112.  *
  113.  *  ARGUMENTS:
  114.  *  (HMMIO hmmioSrc, HMMIO hmmioDst, LPMMCKINFO lpck)
  115.  *
  116.  *  RETURN (BOOL NEAR PASCAL):
  117.  *
  118.  *
  119.  *  NOTES:
  120.  *
  121.  ** */
  122.  
  123. BOOL RIFFAPI riffCopyList(HMMIO hmmioSrc, HMMIO hmmioDst, const LPMMCKINFO lpck)
  124. {
  125.     MMCKINFO    ck;
  126.     HPSTR       hpBuf;
  127.     DWORD    dwCopySize;
  128.  
  129.     hpBuf = (HPSTR)GlobalAllocPtr(GHND, lpck->cksize);
  130.     if (!hpBuf)
  131.         return (FALSE);
  132.  
  133.     dwCopySize=lpck->cksize;
  134.     
  135.     // mmio leaves us after LIST ID
  136.     
  137.     ck.ckid   = lpck->ckid;
  138.     ck.cksize = dwCopySize;
  139.     ck.fccType= lpck->fccType;
  140.     
  141.     if (mmioCreateChunk(hmmioDst, &ck, MMIO_CREATELIST))
  142.     goto rscl_Error;
  143.  
  144.     // we already wrote 'LIST' ID, so reduce byte count
  145.     dwCopySize-=sizeof(FOURCC);
  146.  
  147.     if (mmioRead(hmmioSrc, hpBuf, dwCopySize) != (LONG)dwCopySize)
  148.         goto rscl_Error;
  149.  
  150.     if (mmioWrite(hmmioDst, hpBuf, dwCopySize) != (LONG)dwCopySize)
  151.         goto rscl_Error;
  152.  
  153.     if (mmioAscend(hmmioDst, &ck, 0))
  154.         goto rscl_Error;
  155.  
  156.     if (hpBuf)
  157.         GlobalFreePtr(hpBuf);
  158.  
  159.     return (TRUE);
  160.  
  161. rscl_Error:
  162.  
  163.     if (hpBuf)
  164.         GlobalFreePtr(hpBuf);
  165.  
  166.     return (FALSE);
  167. } /* RIFFSupCopyList() */
  168.  
  169.  
  170. /////////////////////////////////////////////////////////////////////////////
  171.  
  172. typedef struct tINFO
  173. {
  174.     char * pFOURCC;
  175.     char * pShort;
  176.     char * pLong;
  177. } INFO;
  178.  
  179. static INFO aINFO[]=
  180. {
  181.  
  182. "IARL",    "Archival Location", "Indicates where the subject of the file is archived.",
  183. "IART",    "Artist", "Lists the artist of the original subject of the file. For example, \"Michaelangelo.\"",
  184. "ICMS",    "Commissioned", "Lists the name of the person or organization that commissioned the subject of the file. For example, \"Pope Julian II.\"",
  185. "ICMT",    "Comments", "Provides general comments about the file or the subject of the file. If the comment is several sentences long, end each sentence with a period. Do not include newline characters.",
  186. "ICOP",    "Copyright", "Records the copyright information for the file. For example, \"Copyright Encyclopedia International 1991.\" If there are multiple copyrights, separate them by a semicolon followed by a space.",
  187. "ICRD",    "Creation date", "Specifies the date the subject of the file was created. List dates in year-month-day format, padding one-digit months and days with a zero on the left. For example, \"1553-05-03\" for May 3, 1553.",
  188. "ICRP",    "Cropped", "Describes whether an image has been cropped and, if so, how it was cropped. For example, \"lower right corner.\"",
  189. "IDIM",    "Dimensions", "Specifies the size of the original subject of the file. For example, \"8.5 in h, 11 in w.\"",
  190. "IDPI",    "Dots Per Inch", "Stores dots per inch setting of the digitizer used to produce the file, such as \"300.\"",
  191. "IENG",    "Engineer", "Stores the name of the engineer who worked on the file. If there are multiple engineers, separate the names by a semicolon and a blank. For example, \"Smith, John; Adams, Joe.\"",
  192. "IGNR",    "Genre", "Describes the original work, such as, \"landscape,\" \"portrait,\" \"still life,\" etc.",
  193. "IKEY",    "Keywords", "Provides a list of keywords that refer to the file or subject of the file. Separate multiple keywords with a semicolon and a blank. For example, \"Seattle; aerial view; scenery.\"",
  194. "ILGT",    "Lightness", "Describes the changes in lightness settings on the digitizer required to produce the file. Note that the format of this information depends on hardware used.",
  195. "IMED",    "Medium", "Describes the original subject of the file, such as, \"computer image,\" \"drawing,\" \"lithograph,\" and so forth.",
  196. "INAM",    "Name", "Stores the title of the subject of the file, such as, \"Seattle From Above.\"",
  197. "IPLT",    "Palette Setting", "Specifies the number of colors requested when digitizing an image, such as \"256.\"",
  198. "IPRD",    "Product", "Specifies the name of the title the file was originally intended for, such as \"Encyclopedia of Pacific Northwest Geography.\"",
  199. "ISBJ",    "Subject", "Describes the contents of the file, such as \"Aerial view of Seattle.\"",
  200. "ISFT",    "Software", "Identifies the name of the software package used to create the file, such as \"Microsoft WaveEdit.\"",
  201. "ISHP",    "Sharpness", "Identifies the changes in sharpness for the digitizer required to produce the file (the format depends on the hardware used).",
  202. "ISRC",    "Source", "Identifies the name of the person or organization who supplied the original subject of the file. For example, \"Trey Research.\"",
  203. "ISRF",    "Source Form", "Identifies the original form of the material that was digitized, such as \"slide,\" \"paper,\" \"map,\" and so forth. This is not necessarily the same as IMED.",
  204. "ITCH",    "Technician", "Identifies the technician who digitized the subject file. For example, \"Smith, John.\"",
  205.  
  206. NULL, NULL, NULL
  207.  
  208. };
  209.  
  210.  
  211. void NEAR PASCAL riffInsertINFO(LPINFOCHUNK lpInfo, const PINFODATA pInfo)
  212. {
  213.     PINFODATA pI;
  214.     
  215.     if(!lpInfo)
  216.     return;
  217.     
  218.     if(!lpInfo->pHead)
  219.     {
  220.     lpInfo->pHead=pInfo;
  221.     return;
  222.     }
  223.     
  224.     pI=lpInfo->pHead;
  225.     while(pI->pnext)
  226.     {
  227.     pI=pI->pnext;
  228.     }
  229.     // insert at end
  230.     pI->pnext=pInfo;
  231.     
  232.     return;
  233. }
  234.  
  235. PINFODATA NEAR PASCAL riffCreateINFO(WORD id, WORD wFlags, DWORD dwInfoOffset, LPCSTR lpText)
  236. {
  237.     PINFODATA pI;
  238.     pI=(PINFODATA)LocalAlloc(LPTR,sizeof(INFODATA));
  239.     if(!pI)
  240.     return NULL;
  241.     
  242.     pI->index=id;
  243.     pI->wFlags=wFlags;
  244.     pI->dwINFOOffset=dwInfoOffset;
  245.     pI->lpText=lpText;
  246.     
  247.     return pI;
  248. }
  249.  
  250. LRESULT RIFFAPI riffInitINFO(INFOCHUNK FAR * FAR * lplpInfo)
  251. {
  252.     LPINFOCHUNK lpInfo;
  253.     WORD    id;
  254.     PINFODATA    pI;
  255.     
  256.     lpInfo=(LPINFOCHUNK)GlobalAllocPtr(GHND, sizeof(INFOCHUNK));
  257.     if(!lpInfo)
  258.     return RIFFERR_NOMEM;
  259.     *lplpInfo=lpInfo;
  260.  
  261.     for (id=0;aINFO[id].pFOURCC;id++)
  262.     {
  263.     pI=riffCreateINFO(id, 0, 0L, NULL);   // create empty INFO
  264.     riffInsertINFO(lpInfo,pI);
  265.     }
  266.     return RIFFERR_NOERROR;
  267. }
  268.  
  269. LRESULT RIFFAPI riffReadINFO(HMMIO hmmio, const LPMMCKINFO lpck, LPINFOCHUNK lpInfo)
  270. {
  271.     DWORD    dwInfoSize;
  272.  
  273.     dwInfoSize=lpck->cksize - sizeof(FOURCC);    // take out 'INFO'
  274.  
  275.     lpInfo->cksize=dwInfoSize;
  276.     lpInfo->lpChunk=GlobalAllocPtr(GHND, dwInfoSize);
  277.     if(!lpInfo->lpChunk)
  278.     return RIFFERR_NOMEM;
  279.     
  280.     if (mmioRead(hmmio, (HPSTR)lpInfo->lpChunk, dwInfoSize) != (LONG)dwInfoSize)
  281.     return RIFFERR_FILEERROR;
  282.     else
  283.         return riffParseINFO(lpInfo);
  284. }
  285.  
  286. PINFODATA NEAR PASCAL riffFindPIINFO(const LPINFOCHUNK lpInfo, FOURCC fcc)
  287. {
  288.     PINFODATA pI;
  289.  
  290.     pI=lpInfo->pHead;
  291.     while(pI)
  292.     {
  293.     if(mmioStringToFOURCC(aINFO[pI->index].pFOURCC,0)==fcc)
  294.         return(pI);
  295.     pI=pI->pnext;
  296.     }
  297.     return NULL;
  298. }
  299.  
  300. void NEAR PASCAL riffModifyINFO(const LPINFOCHUNK lpInfo, PINFODATA pI, WORD wFlags, DWORD dw, LPCSTR lpText)
  301. {
  302.     if(!pI)
  303.     return;
  304.     
  305.     pI->wFlags=wFlags;
  306.     if(!(wFlags&INFOCHUNK_MODIFIED))
  307.     pI->dwINFOOffset=dw;
  308.     
  309.     if(pI->lpText)
  310.     {
  311.     if(lpText)
  312.     {
  313.         if(!lstrcmp(lpText,pI->lpText))
  314.         {
  315.         // they are the same, don't bother changing...
  316.         GlobalFreePtr(lpText);
  317.         }
  318.         else
  319.         {
  320.         GlobalFreePtr(pI->lpText);
  321.         pI->lpText=lpText;
  322.         }
  323.     }
  324.     else if(wFlags&INFOCHUNK_REVERT)
  325.     {
  326.         GlobalFreePtr(pI->lpText);
  327.         pI->lpText=NULL;
  328.     }
  329.     }
  330.     else if(lpText)
  331.     {
  332.     // if no read data, don't bother to check....
  333.     if(!lpInfo->lpChunk && *lpText)
  334.     {
  335.         pI->lpText=lpText;
  336.     }
  337.     else if(lstrcmp(lpText, (LPSTR)lpInfo->lpChunk+pI->dwINFOOffset))
  338.     {     // new text...
  339.         if(*lpText)
  340.         // NOT the same, set...
  341.         pI->lpText=lpText;
  342.         else
  343.         // new is blank, do nothing...
  344.         GlobalFreePtr(lpText);
  345.     }
  346.     else
  347.         // the same, don't bother...
  348.         GlobalFreePtr(lpText);
  349.     }
  350. }
  351.  
  352. WORD NEAR PASCAL riffFindaINFO(FOURCC fcc)
  353. {
  354.     WORD    id;
  355.  
  356.     for (id=0;aINFO[id].pFOURCC;id++)
  357.     {
  358.     if(mmioStringToFOURCC(aINFO[id].pFOURCC,0)==fcc)
  359.         return id;
  360.     }
  361.     return 0xFFFF;
  362. }
  363.  
  364.  
  365.  
  366. LRESULT NEAR PASCAL riffParseINFO(const LPINFOCHUNK lpInfo)
  367. {
  368.     LPSTR   lpBuf;
  369.     DWORD   dwCurInfoOffset;
  370.     PINFODATA pI;
  371.     LPCHUNK lpck;
  372.  
  373.     lpBuf=lpInfo->lpChunk;
  374.     for(dwCurInfoOffset=0;dwCurInfoOffset<lpInfo->cksize;)
  375.     {
  376.     lpck=(LPCHUNK)((LPSTR)(lpBuf+dwCurInfoOffset));
  377.     dwCurInfoOffset+=sizeof(CHUNK);   // dwCurInfoOffset is offset of data
  378.     pI=riffFindPIINFO(lpInfo,lpck->fcc);
  379.     if(!pI)
  380.     {
  381.             UINT    u;
  382.  
  383.         // file contains unknown INFO chunk
  384.         wsprintf(szBuf,"This wave file contains an unknown item in the INFO chunk: '%4.4s'.  Open anyway?",
  385.         (LPCSTR)(lpck));
  386.             u = MessageBox(NULL, szBuf,
  387.                             "riffParseINFO", MB_YESNO | MB_ICONEXCLAMATION | MB_TASKMODAL);
  388.             if (u == IDNO)
  389.         {
  390.         return RIFFERR_BADFILE;
  391.         }
  392.         
  393.         
  394.     }
  395.     else
  396.     {
  397.         // modify entry to show text (data) from file...
  398.         riffModifyINFO(lpInfo, pI, 0, dwCurInfoOffset, NULL);
  399.     }
  400.     dwCurInfoOffset+=lpck->cksize+(lpck->cksize&1);  // skip past data
  401.     }
  402.  
  403.     return RIFFERR_NOERROR;
  404. }
  405.  
  406. LRESULT RIFFAPI riffFreeINFO(INFOCHUNK FAR * FAR * lplpInfo)
  407. {
  408.     PINFODATA    pI;
  409.     PINFODATA    pIT;
  410.     LPINFOCHUNK lpInfo;
  411.     LRESULT     lr;
  412.  
  413.     lr    = RIFFERR_BADPARAM;
  414.  
  415.     if(!lplpInfo)
  416.     goto riff_FI_Error;
  417.     
  418.     lpInfo=*lplpInfo;
  419.     if(!lpInfo)
  420.     goto riff_FI_Error;
  421.     
  422.     if(lpInfo->lpChunk)
  423.     GlobalFreePtr(lpInfo->lpChunk);
  424.  
  425.  
  426.     pI=lpInfo->pHead;
  427.     
  428.     while(pI)
  429.     {
  430.     pIT=pI;
  431.     pI=pI->pnext;
  432.     LocalFree((HANDLE)pIT);
  433.     }
  434.  
  435.     
  436.     //
  437.  
  438.     GlobalFreePtr(lpInfo);
  439.     *lplpInfo=NULL;
  440.     return RIFFERR_NOERROR;
  441.     
  442. riff_FI_Error:    
  443.     return lr;
  444. }
  445.  
  446. static BOOL NEAR PASCAL riffSetupEditBoxINFO(HWND hdlg, const LPINFOCHUNK lpInfo, WORD wFlags)
  447. {
  448.     PINFODATA    pI;
  449.     WORD    iSel;
  450.     HWND    hLB;
  451.     PSTR szFormat = "%-4s%c %-25s";
  452.     
  453.     hLB=GetDlgItem(hdlg, IDD_INFOLIST);
  454.     if(wFlags&INFOCHUNK_MODIFIED)
  455.     {
  456.         iSel = ComboBox_GetCurSel(hLB);
  457.     
  458.     }
  459.     else
  460.         iSel = 0;
  461.  
  462.     ComboBox_ResetContent(hLB);
  463.     
  464.     pI=lpInfo->pHead;
  465.     
  466.     while(pI)
  467.     {
  468.     wsprintf(szBuf,szFormat,
  469.         (LPCSTR)aINFO[pI->index].pFOURCC,
  470.         (pI->dwINFOOffset || ( (pI->lpText) && (pI->lpText[0]) ) ) ?
  471.             '*' : ' ',
  472.         (LPCSTR)aINFO[pI->index].pShort
  473.         );
  474.  
  475.     ComboBox_AddString(hLB, szBuf);
  476.     pI=pI->pnext;
  477.     }
  478.     ComboBox_SetCurSel(hLB, iSel);
  479.  
  480.     if(!(wFlags&INFOCHUNK_MODIFIED))
  481.     {
  482.     // FIRST time only
  483.     pI=lpInfo->pHead;
  484.     if(pI)
  485.         if(pI->lpText)
  486.         // Modified text
  487.         SetDlgItemText(hdlg, IDD_INFOTEXT, (LPCSTR)pI->lpText);
  488.         else if(pI->dwINFOOffset)
  489.         // default text
  490.         SetDlgItemText(hdlg, IDD_INFOTEXT, (LPCSTR)(lpInfo->lpChunk+pI->dwINFOOffset));
  491.         else
  492.         // no text
  493.         SetDlgItemText(hdlg, IDD_INFOTEXT, (LPCSTR)"");
  494.     SetDlgItemText(hdlg, IDD_INFOINFO, (LPCSTR)aINFO[0].pLong);
  495.     }
  496.     return TRUE;
  497. }
  498.  
  499.  
  500. static BOOL Cls_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
  501. {
  502.     LPINFOCHUNK lpInfo;
  503.     HFONT       hFont;
  504.     HWND    hLB;
  505.  
  506.     lpInfo = (LPINFOCHUNK)lParam;
  507.     if(!lpInfo)
  508.         return FALSE;
  509.  
  510.     SetWindowLong(hwnd, DWL_USER, (LONG)lpInfo);
  511.         
  512.     hFont = GetStockFont(ANSI_FIXED_FONT);
  513.  
  514.     hLB=GetDlgItem(hwnd, IDD_INFOLIST);
  515.     SetWindowFont(hLB, hFont, FALSE);
  516.  
  517.     riffSetupEditBoxINFO(hwnd, lpInfo, 0);
  518.  
  519.     return TRUE;
  520. }
  521.  
  522. static void Cls_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
  523. {
  524.     LPINFOCHUNK lpInfo;
  525.     PINFODATA   pI;
  526.     WORD        iSel;
  527.     int         i;
  528.     LPSTR       lpstr;
  529.  
  530.     lpInfo=(LPINFOCHUNK)GetWindowLong(hwnd, DWL_USER);
  531.             
  532.     switch(id)
  533.     {
  534.         case IDOK:
  535.         case IDCANCEL:
  536.             EndDialog(hwnd, (id == IDOK));
  537.             break;
  538.         case IDD_INFOLIST:
  539.             switch(codeNotify)
  540.             {
  541.                 case CBN_SELCHANGE:
  542.  
  543.                     iSel = ComboBox_GetCurSel(GetDlgItem(hwnd, id));
  544.                     SetDlgItemText(hwnd, IDD_INFOINFO, (LPCSTR)aINFO[iSel].pLong);
  545.  
  546.                     pI=lpInfo->pHead;
  547.                     while(pI)
  548.                     {
  549.                         if(pI->index==iSel)
  550.                             break;
  551.                         pI=pI->pnext;
  552.                     }
  553.                     if(pI)
  554.                     {
  555.                         if(pI->lpText)
  556.                             // Modified text
  557.                             SetDlgItemText(hwnd, IDD_INFOTEXT, (LPCSTR)pI->lpText);
  558.                         else if(pI->dwINFOOffset)
  559.                             // default text
  560.                             SetDlgItemText(hwnd, IDD_INFOTEXT, (LPCSTR)(lpInfo->lpChunk+pI->dwINFOOffset));
  561.                         else
  562.                             // no text
  563.                             SetDlgItemText(hwnd, IDD_INFOTEXT, (LPCSTR)"");
  564.                     }
  565.                         else
  566.                             SetDlgItemText(hwnd, IDD_INFOINFO, (LPCSTR)"Can't FIND iSel");
  567.                     break;
  568.             }
  569.  
  570.         case IDD_INFOTEXT:
  571.             switch(codeNotify)
  572.             {
  573.                 case EN_KILLFOCUS:
  574.                     // get text out and give to current id
  575.                     iSel=(WORD)SendDlgItemMessage(hwnd,IDD_INFOLIST,CB_GETCURSEL,0,0L);
  576.                     pI=lpInfo->pHead;
  577.                     while(pI)
  578.                     {
  579.                         if(pI->index==iSel)
  580.                             break;
  581.                         pI=pI->pnext;
  582.                     }
  583.                     if(pI)
  584.                     {
  585.                         i=GetDlgItemText(hwnd, IDD_INFOTEXT, szBuf,sizeof(szBuf));
  586.                         lpstr=(LPSTR)GlobalAllocPtr(GHND,(DWORD)i+1);
  587.                         if(!lpstr)
  588.                             break;
  589.  
  590.                         lstrcpy(lpstr,szBuf);
  591.  
  592.                         riffModifyINFO(lpInfo, pI, INFOCHUNK_MODIFIED, 0, lpstr);
  593.  
  594.                         riffSetupEditBoxINFO(hwnd, lpInfo, INFOCHUNK_MODIFIED);
  595.                     }
  596.                     else
  597.                         SetDlgItemText(hwnd, IDD_INFOINFO, (LPCSTR)"Can't FIND iSel");
  598.                     break;
  599.  
  600.             }
  601.             break;
  602.         case IDD_INFOINFO:
  603.             break;
  604.     }
  605.  
  606. }                           
  607.  
  608. BOOL FAR PASCAL _export DlgProcINFOEdit(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  609. {
  610.     switch (uMsg)
  611.     {
  612.         case WM_INITDIALOG:
  613.             return (BOOL)(UINT)(DWORD)(LRESULT)HANDLE_WM_INITDIALOG(hdlg, wParam, lParam, Cls_OnInitDialog);
  614.  
  615.         case WM_COMMAND:
  616.             HANDLE_WM_COMMAND(hdlg, wParam, lParam, Cls_OnCommand);
  617.             break;
  618.     }
  619.  
  620.     return FALSE;
  621. }
  622.  
  623.  
  624. LRESULT RIFFAPI riffEditINFO(HWND hwnd, LPINFOCHUNK lpInfo, HINSTANCE hInst)
  625. {
  626.     LRESULT     lr;
  627.     DLGPROC    lpfn;
  628. #ifdef DEBUG    
  629.     int        i;
  630. #endif
  631.     
  632.     lr    = RIFFERR_BADPARAM;
  633.  
  634.     if(!lpInfo)
  635.     goto riff_EI_Error;
  636.  
  637.     if (lpfn = (DLGPROC)MakeProcInstance((FARPROC)DlgProcINFOEdit, hInst))
  638.     {
  639. #ifdef DEBUG
  640.     i=
  641. #endif
  642.         DialogBoxParam(hInst, DLG_INFOEDIT, hwnd, lpfn, (LPARAM)(LPVOID)lpInfo);
  643.         FreeProcInstance((FARPROC)lpfn);
  644.     lr=RIFFERR_NOERROR;
  645. #ifdef DEBUG
  646.     if(i==-1)
  647.     {
  648.         MessageBox(hwnd, "INFO Edit Error: DLG_INFOEDIT not found.  Check .RC file.", "RIFF SUP module", MB_OK|MB_ICONEXCLAMATION|MB_TASKMODAL);
  649.         lr=RIFFERR_ERROR;
  650.     }
  651. #endif
  652.     
  653.     }
  654. #ifdef DEBUG
  655.     else
  656.     {
  657.     MessageBox(hwnd, "INFO Edit Error: Can't MakeProcInstace()", "RIFF SUP module", MB_OK|MB_ICONEXCLAMATION|MB_TASKMODAL);
  658.     lr=RIFFERR_ERROR;
  659.     }
  660. #endif
  661.     
  662. riff_EI_Error:    
  663.     return lr;
  664. }
  665.  
  666. LRESULT RIFFAPI riffWriteINFO(HMMIO hmmioDst, LPINFOCHUNK lpInfo)
  667. {
  668.     LRESULT     lr;
  669.     MMCKINFO    ck;
  670.     MMCKINFO    ckINFO;
  671.     PINFODATA    pI;
  672.     LPSTR    lpstr;
  673.     BOOL    fList=FALSE;
  674.  
  675.     lr    = RIFFERR_BADPARAM;
  676.  
  677.     if(!hmmioDst || !lpInfo)
  678.     goto riff_SI_Error;
  679.  
  680.     lr=RIFFERR_FILEERROR;
  681.     
  682.     ckINFO.ckid   = mmioFOURCC('L', 'I', 'S', 'T');
  683.     ckINFO.cksize = 0;  // mmio fill fill it in later
  684.     ckINFO.fccType= mmioFOURCC('I', 'N', 'F', 'O');
  685.     
  686.     pI=lpInfo->pHead;
  687.     
  688.     while(pI)
  689.     {
  690.     if(pI->lpText)
  691.         // Modified text
  692.         lpstr=pI->lpText;
  693.     else if(pI->dwINFOOffset)
  694.         // default text
  695.         lpstr=(lpInfo->lpChunk+pI->dwINFOOffset);
  696.     else
  697.         // no text
  698.         lpstr=NULL;
  699.     if(lpstr)
  700.     {
  701.         if(!fList)
  702.         {
  703.         // only create if needed...
  704.         if (mmioCreateChunk(hmmioDst, &ckINFO, MMIO_CREATELIST))
  705.             goto riff_SI_Error;
  706.         fList=TRUE;
  707.         }
  708.     
  709.         ck.ckid=mmioStringToFOURCC(aINFO[pI->index].pFOURCC,0);
  710.         ck.cksize=lstrlen(lpstr)+1;
  711.         ck.fccType=0;
  712.         if (mmioCreateChunk(hmmioDst, &ck, 0))
  713.         goto riff_SI_Error;
  714.  
  715.         if (mmioWrite(hmmioDst, lpstr, ck.cksize) != (LONG)(ck.cksize))
  716.         goto riff_SI_Error;
  717.  
  718.         if (mmioAscend(hmmioDst, &ck, 0))
  719.         goto riff_SI_Error;
  720.  
  721.     }
  722.     pI=pI->pnext;
  723.     }
  724.     
  725.     if(fList)
  726.     {
  727.     if (mmioAscend(hmmioDst, &ckINFO, 0))
  728.         goto riff_SI_Error;
  729.     }
  730.  
  731.     return RIFFERR_NOERROR;
  732.     
  733. riff_SI_Error:    
  734.     return lr;
  735.     
  736. }
  737.  
  738.  
  739. ///////////////////////////////////////////////////////////////////////////////
  740.  
  741. LRESULT RIFFAPI riffReadDISP(HMMIO hmmio, LPMMCKINFO lpck, DISP FAR * FAR * lpnpDisp)
  742. {
  743.     LRESULT     lr;
  744.     lr    = RIFFERR_ERROR;
  745.    
  746.     return lr;
  747. }
  748.  
  749. LRESULT RIFFAPI riffFreeDISP(DISP FAR * FAR * lpnpDisp)
  750. {
  751.     LRESULT     lr;
  752.     lr    = RIFFERR_ERROR;
  753.     
  754.     return lr;
  755. }
  756.  
  757. LRESULT RIFFAPI riffWriteDISP(HMMIO hmmio, DISP FAR * FAR * lpnpDisp)
  758. {
  759.     LRESULT     lr;
  760.     lr    = RIFFERR_ERROR;
  761.     
  762.     return lr;
  763. }
  764.  
  765.  
  766. /** EOF: RIFFsup.c **/
  767.