"Fossies" - the Fresh Open Source Software Archive

Member "faac-1_30/common/Cfaac/EncDialog.cpp" (16 Oct 2019, 32221 Bytes) of package /linux/misc/faac-1_30.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "EncDialog.cpp" see the Fossies "Dox" file reference documentation.

    1 /*
    2 CFAAC - set of classes to import/export .aac/.mp4 files
    3 Copyright (C) 2004 Antonio Foranna
    4 
    5 This program is free software; you can redistribute it and/or modify
    6 it under the terms of the GNU General Public License as published by
    7 the Free Software Foundation.
    8     
    9 This program is distributed in the hope that it will be useful,
   10 but WITHOUT ANY WARRANTY; without even the implied warranty of
   11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12 GNU General Public License for more details.
   13         
   14 You should have received a copy of the GNU General Public License
   15 along with this program; if not, write to the Free Software
   16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   17             
   18 The author can be contacted at:
   19 ntnfrn_email-temp@yahoo.it
   20 */
   21 
   22 #include <windows.h>
   23 #include <shlobj.h>     // Browse
   24 #include <shellapi.h>   // ShellExecute
   25 #include <Commdlg.h>
   26 #include "resource.h"
   27 #include "Defines.h"    // my defines
   28 #include "CTag.h"
   29 #include "Cfaac.h"
   30 #include "EncDialog.h"
   31 
   32 #include <commctrl.h>
   33 #include <id3v2tag.h>
   34 #include <..\..\common\id3lib\win32\config.h> // ID3LIB_FULLNAME
   35 
   36 // *********************************************************************************************
   37 
   38 #ifdef USE_OUTPUT_FOLDER
   39 extern char config_AACoutdir[MAX_PATH];
   40 #endif
   41 
   42 extern HINSTANCE hInstance;
   43 extern HBITMAP hBmBrowse;
   44 
   45 // *********************************************************************************************
   46 
   47 /*
   48 DWORD PackCfg(MY_ENC_CFG *cfg)
   49 {
   50 DWORD dwOptions=0;
   51 
   52     if(cfg->AutoCfg)
   53         dwOptions=1<<31;
   54     dwOptions|=(DWORD)cfg->EncCfg.mpegVersion<<30;
   55     dwOptions|=(DWORD)cfg->EncCfg.aacObjectType<<28;
   56     dwOptions|=(DWORD)cfg->EncCfg.allowMidside<<27;
   57     dwOptions|=(DWORD)cfg->EncCfg.useTns<<26;
   58     dwOptions|=(DWORD)cfg->EncCfg.useLfe<<25;
   59     dwOptions|=(DWORD)cfg->EncCfg.outputFormat<<24;
   60     if(cfg->UseQuality)
   61         dwOptions|=(((DWORD)cfg->EncCfg.quantqual>>1)&0xff)<<16; // [2,512]
   62     else
   63         dwOptions|=(((DWORD)cfg->EncCfg.bitRate>>1)&0xff)<<16; // [2,512]
   64     if(cfg->UseQuality)
   65         dwOptions|=1<<15;
   66     dwOptions|=((DWORD)cfg->EncCfg.bandWidth>>1)&&0x7fff; // [0,65536]
   67 
   68     return dwOptions;
   69 }
   70 // -----------------------------------------------------------------------------------------------
   71 
   72 void UnpackCfg(MY_ENC_CFG *cfg, DWORD dwOptions)
   73 {
   74     cfg->AutoCfg=dwOptions>>31;
   75     cfg->EncCfg.mpegVersion=(dwOptions>>30)&1;
   76     cfg->EncCfg.aacObjectType=(dwOptions>>28)&3;
   77     cfg->EncCfg.allowMidside=(dwOptions>>27)&1;
   78     cfg->EncCfg.useTns=(dwOptions>>26)&1;
   79     cfg->EncCfg.useLfe=(dwOptions>>25)&1;
   80     cfg->EncCfg.outputFormat=(dwOptions>>24)&1;
   81     cfg->EncCfg.bitRate=((dwOptions>>16)&0xff)<<1;
   82     cfg->UseQuality=(dwOptions>>15)&1;
   83     cfg->EncCfg.bandWidth=(dwOptions&0x7fff)<<1;
   84 }*/
   85 // -----------------------------------------------------------------------------------------------
   86 
   87 #define INIT_CB(hWnd,nID,list,FillList,IdSelected) \
   88 { \
   89     if(FillList) \
   90         for(int i=0; list[i]; i++) \
   91             SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)list[i]); \
   92     SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
   93 }
   94 // -----------------------------------------------------------------------------------------------
   95 
   96 #define INIT_CB_GENRES(hWnd,nID,ID3Genres,IdSelected) \
   97 { \
   98     for(int i=0; i<(sizeof(ID3Genres)/sizeof(ID3Genres[0])); i++) \
   99         SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)ID3Genres[i].name); \
  100     SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
  101 }
  102 // -----------------------------------------------------------------------------------------------
  103 
  104 #define DISABLE_LTP \
  105 { \
  106     if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \
  107        IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \
  108     { \
  109         CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); \
  110         CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); \
  111     } \
  112     EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \
  113 }
  114 // -----------------------------------------------------------------------------------------------
  115 
  116 //        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
  117 //        EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled);
  118 #define DISABLE_CTRLS_ENC(Enabled) \
  119 { \
  120     CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !Enabled); \
  121     EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled); \
  122     EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled); \
  123     EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_RAW), Enabled); \
  124     EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_ADTS), Enabled); \
  125     EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_ALLOWMIDSIDE), Enabled); \
  126     EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USETNS), Enabled); \
  127     EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled); \
  128     EnableWindow(GetDlgItem(hWndDlg, IDC_CB_QUALITY), Enabled); \
  129     EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled); \
  130     EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled); \
  131     EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_QUALITY), Enabled); \
  132     EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_BITRATE), Enabled); \
  133     EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
  134     EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
  135     EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
  136     if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4)) \
  137         EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
  138     else \
  139         DISABLE_LTP \
  140 }
  141 // -----------------------------------------------------------------------------------------------
  142 
  143 #define ENABLE_TAG(Enabled) \
  144 { \
  145     EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTIST), Enabled); \
  146     EnableWindow(GetDlgItem(hWndDlg, IDC_E_TITLE), Enabled); \
  147     EnableWindow(GetDlgItem(hWndDlg, IDC_E_ALBUM), Enabled); \
  148     EnableWindow(GetDlgItem(hWndDlg, IDC_E_YEAR), Enabled); \
  149     EnableWindow(GetDlgItem(hWndDlg, IDC_CB_GENRE), Enabled); \
  150     EnableWindow(GetDlgItem(hWndDlg, IDC_E_WRITER), Enabled); \
  151     EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMMENT), Enabled); \
  152     EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \
  153     EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_COMPILATION), Enabled); \
  154     EnableWindow(GetDlgItem(hWndDlg, IDC_E_TRACK), Enabled); \
  155     EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \
  156     EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \
  157     EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \
  158     EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTFILE), Enabled); \
  159     EnableWindow(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), Enabled); \
  160 }
  161 // -----------------------------------------------------------------------------------------------
  162 
  163 #define ENABLE_AACTAGS(Enabled) \
  164 { \
  165     EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \
  166     EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_COMPILATION), Enabled); \
  167     EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \
  168     EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \
  169     EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \
  170 }
  171 // -----------------------------------------------------------------------------------------------
  172 
  173 #ifdef USE_OUTPUT_FOLDER
  174 static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
  175 {
  176     if (uMsg == BFFM_INITIALIZED)
  177     {
  178         SetWindowText(hwnd,"Select folder");
  179         SendMessage(hwnd,BFFM_SETSELECTION,(WPARAM)TRUE,(LPARAM)lpData);
  180     }
  181     return 0;
  182 }
  183 #else
  184     #ifdef USE_IMPORT_TAG
  185     static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
  186     {
  187         if (uMsg == BFFM_INITIALIZED)
  188         {
  189             SetWindowText(hwnd,"Select folder");
  190             SendMessage(hwnd,BFFM_SETSELECTION,(WPARAM)TRUE,(LPARAM)lpData);
  191         }
  192         return 0;
  193     }
  194     #endif
  195 #endif
  196 
  197 // -----------------------------------------------------------------------------------------------
  198 
  199 BOOL DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
  200 {
  201     switch(Message)
  202     {
  203     case WM_INITDIALOG:
  204         {
  205         char buf[512];
  206         char *faac_id_string, *faac_copyright_string;
  207 
  208         sprintf(buf,
  209                     APP_NAME " plugin " APP_VER " by Antonio Foranna\n\n"
  210                     "Libraries used:\n"
  211                     "\tlibfaac v%s\n"
  212                     "\tFAAD2 v" FAAD2_VERSION "\n"
  213                     "\t" MPEG4IP_PACKAGE " v" MPEG4IP_VERSION "\n"
  214                     "\t" ID3LIB_FULLNAME "\n\n"
  215                     "This code is given with FAAC package and does not contain executables.\n"
  216                     "This program is free software and can be distributed/modifyed under the terms of the GNU General Public License.\n"
  217                     "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.\n\n"
  218                     "Compiled on %s\n",
  219                 (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version",
  220                     __DATE__
  221                     );
  222             SetDlgItemText(hWndDlg, IDC_L_ABOUT, buf);
  223         }
  224         break;
  225     case WM_COMMAND:
  226         switch(LOWORD(wParam))
  227         {
  228         case IDOK:
  229             EndDialog(hWndDlg, TRUE);
  230             break;
  231         case IDCANCEL:
  232             // Ignore data values entered into the controls and dismiss the dialog window returning FALSE
  233             EndDialog(hWndDlg, FALSE);
  234             break;
  235         case IDC_AUDIOCODING:
  236             ShellExecute(hWndDlg, NULL, "http://www.audiocoding.com", NULL, NULL, SW_SHOW);
  237             break;
  238         case IDC_MPEG4IP:
  239             ShellExecute(hWndDlg, NULL, "http://www.mpeg4ip.net", NULL, NULL, SW_SHOW);
  240             break;
  241         case IDC_ID3:
  242             ShellExecute(hWndDlg, NULL, "http://id3lib.sourceforge.net", NULL, NULL, SW_SHOW);
  243             break;
  244         case IDC_EMAIL:
  245             ShellExecute(hWndDlg, NULL, "mailto:ntnfrn_email-temp@yahoo.it", NULL, NULL, SW_SHOW);
  246             break;
  247         }
  248         break;
  249     default: 
  250         return FALSE;
  251     }
  252 
  253     return TRUE;
  254 }
  255 // -----------------------------------------------------------------------------------------------
  256 
  257 // ripped from id3v2tag.c
  258 ID3GENRES ID3Genres[]=
  259 {
  260     123,    "Acapella",
  261     34,     "Acid",
  262     74,     "Acid Jazz",
  263     73,     "Acid Punk",
  264     99,     "Acoustic",
  265     20,     "Alternative",
  266     40,     "AlternRock",
  267     26,     "Ambient",
  268     90,     "Avantgarde",
  269     116,    "Ballad",
  270     41,     "Bass",
  271     85,     "Bebob",
  272     96,     "Big Band",
  273     89,     "Bluegrass",
  274     0,      "Blues",
  275     107,    "Booty Bass",
  276     65,     "Cabaret",
  277     88,     "Celtic",
  278     104,    "Chamber Music",
  279     102,    "Chanson",
  280     97,     "Chorus",
  281     61,     "Christian Rap",
  282     1,      "Classic Rock",
  283     32,     "Classical",
  284     112,    "Club",
  285     57,     "Comedy",
  286     2,      "Country",
  287     58,     "Cult",
  288     3,      "Dance",
  289     125,    "Dance Hall",
  290     50,     "Darkwave",
  291     254,    "Data",
  292     22,     "Death Metal",
  293     4,      "Disco",
  294     55,     "Dream",
  295     122,    "Drum Solo",
  296     120,    "Duet",
  297     98,     "Easy Listening",
  298     52,     "Electronic",
  299     48,     "Ethnic",
  300     124,    "Euro-House",
  301     25,     "Euro-Techno",
  302     54,     "Eurodance",
  303     84,     "Fast Fusion",
  304     80,     "Folk",
  305     81,     "Folk-Rock",
  306     115,    "Folklore",
  307     119,    "Freestyle",
  308     5,      "Funk",
  309     30,     "Fusion",
  310     36,     "Game",
  311     59,     "Gangsta",
  312     38,     "Gospel",
  313     49,     "Gothic",
  314     91,     "Gothic Rock",
  315     6,      "Grunge",
  316     79,     "Hard Rock",
  317     7,      "Hip-Hop",
  318     35,     "House",
  319     100,    "Humour",
  320     19,     "Industrial",
  321     33,     "Instrumental",
  322     46,     "Instrumental Pop",
  323     47,     "Instrumental Rock",
  324     8,      "Jazz",
  325     29,     "Jazz+Funk",
  326     63,     "Jungle",
  327     86,     "Latin",
  328     71,     "Lo-Fi",
  329     45,     "Meditative",
  330     9,      "Metal",
  331     77,     "Musical",
  332     82,     "National Folk",
  333     64,     "Native American",
  334     10,     "New Age",
  335     66,     "New Wave",
  336     39,     "Noise",
  337     255,    "Not Set",
  338     11,     "Oldies",
  339     103,    "Opera",
  340     12,     "Other",
  341     75,     "Polka",
  342     13,     "Pop",
  343     62,     "Pop/Funk",
  344     53,     "Pop-Folk",
  345     109,    "Porn Groove",
  346     117,    "Power Ballad",
  347     23,     "Pranks",
  348     108,    "Primus",
  349     92,     "Progressive Rock",
  350     67,     "Psychadelic",
  351     93,     "Psychedelic Rock",
  352     43,     "Punk",
  353     121,    "Punk Rock",
  354     14,     "R&B",
  355     15,     "Rap",
  356     68,     "Rave",
  357     16,     "Reggae",
  358     76,     "Retro",
  359     87,     "Revival",
  360     118,    "Rhythmic Soul",
  361     17,     "Rock",
  362     78,     "Rock & Roll",
  363     114,    "Samba",
  364     110,    "Satire",
  365     69,     "Showtunes",
  366     21,     "Ska",
  367     111,    "Slow Jam",
  368     95,     "Slow Rock",
  369     105,    "Sonata",
  370     42,     "Soul",
  371     37,     "Sound Clip",
  372     24,     "Soundtrack",
  373     56,     "Southern Rock",
  374     44,     "Space",
  375     101,    "Speech",
  376     83,     "Swing",
  377     94,     "Symphonic Rock",
  378     106,    "Symphony",
  379     113,    "Tango",
  380     18,     "Techno",
  381     51,     "Techno-Industrial",
  382     60,     "Top 40",
  383     70,     "Trailer",
  384     31,     "Trance",
  385     72,     "Tribal",
  386     27,     "Trip-Hop",
  387     28,     "Vocal"
  388 };
  389 
  390 BOOL CALLBACK DIALOGMsgProcEnc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
  391 {
  392     switch(Message)
  393     {
  394     case WM_INITDIALOG:
  395         {
  396         char buf[50];
  397         char FillList=wParam||lParam ? 1 : 0;
  398         char *Quality[]={"Default (100)","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","200","300","400","500",0};
  399         char *BitRate[]={"Auto","8","16","18","20","24","32","40","48","56","64","80","96","112","128","160","192","224","256","320","384",0};
  400         char *BandWidth[]={"Auto","Full","4000","8000","11025","16000","22050","24000","32000","44100","48000",0};
  401         char *Ext[]={".aac",".mp4",".m4a",".m4b",0};
  402         CMyEncCfg cfg(false);
  403             
  404 //          sprintf(Quality[0]+8,"%3d",3);
  405 
  406             SetWindowPos(GetDlgItem(hWndDlg,IDC_CHK_TAG),GetDlgItem(hWndDlg,IDC_GRP_TAG),0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
  407 
  408             INIT_CB(hWndDlg,IDC_CB_QUALITY,Quality,FillList,0);
  409             INIT_CB(hWndDlg,IDC_CB_BITRATE,BitRate,FillList,0);
  410             INIT_CB(hWndDlg,IDC_CB_BANDWIDTH,BandWidth,FillList,0);
  411             INIT_CB(hWndDlg,IDC_CB_EXT,Ext,FillList,0);
  412 
  413             INIT_CB_GENRES(hWndDlg,IDC_CB_GENRE,ID3Genres,0);
  414 
  415             SendMessage(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
  416 #ifdef USE_OUTPUT_FOLDER            
  417             SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
  418             if(!cfg.OutDir || !*cfg.OutDir)
  419             {
  420                 GetCurrentDirectory(MAX_PATH,config_AACoutdir);
  421                 FREE_ARRAY(cfg.OutDir);
  422                 cfg.OutDir=strdup(config_AACoutdir);
  423             }
  424             else
  425                 strcpy(config_AACoutdir,cfg.OutDir);
  426             SetDlgItemText(hWndDlg, IDC_E_BROWSE, cfg.OutDir);
  427 #else
  428             ShowWindow(GetDlgItem(hWndDlg, IDC_BTN_BROWSE),SW_HIDE);
  429             ShowWindow(GetDlgItem(hWndDlg, IDC_E_BROWSE),SW_HIDE);
  430             ShowWindow(GetDlgItem(hWndDlg, IDC_L_BROWSE),SW_HIDE);
  431 #endif
  432             CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,FALSE);
  433             CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,FALSE);
  434             if(cfg.EncCfg.mpegVersion==MPEG4)
  435                 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
  436             else
  437                 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
  438             
  439             CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,FALSE);
  440             CheckDlgButton(hWndDlg,IDC_RADIO_LOW,FALSE);
  441             CheckDlgButton(hWndDlg,IDC_RADIO_SSR,FALSE);
  442             CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE);
  443             switch(cfg.EncCfg.aacObjectType)
  444             {
  445             case MAIN:
  446                 CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
  447                 break;
  448             case LOW:
  449                 CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
  450                 break;
  451             case SSR:
  452                 CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
  453                 break;
  454             case LTP:
  455                 CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
  456                 DISABLE_LTP
  457                 break;
  458             }
  459             
  460             CheckDlgButton(hWndDlg,IDC_RADIO_RAW,FALSE);
  461             CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,FALSE);
  462             switch(cfg.EncCfg.outputFormat)
  463             {
  464             case RAW:
  465                 CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);
  466                 break;
  467             case ADTS:
  468                 CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
  469                 break;
  470             }
  471             
  472             CheckDlgButton(hWndDlg, IDC_CHK_ALLOWMIDSIDE, cfg.EncCfg.allowMidside);
  473             CheckDlgButton(hWndDlg, IDC_CHK_USETNS, cfg.EncCfg.useTns);
  474             CheckDlgButton(hWndDlg, IDC_CHK_USELFE, cfg.EncCfg.useLfe);
  475 
  476             if(cfg.UseQuality)
  477                 CheckDlgButton(hWndDlg,IDC_RADIO_QUALITY,TRUE);
  478             else
  479                 CheckDlgButton(hWndDlg,IDC_RADIO_BITRATE,TRUE);
  480 
  481             switch(cfg.EncCfg.quantqual)
  482             {
  483             case 100:
  484                 SendMessage(GetDlgItem(hWndDlg, IDC_CB_QUALITY), CB_SETCURSEL, 0, 0);
  485                 break;
  486             default:
  487                 if(cfg.EncCfg.quantqual<10)
  488                     cfg.EncCfg.quantqual=10;
  489                 if(cfg.EncCfg.quantqual>500)
  490                     cfg.EncCfg.quantqual=500;
  491                 sprintf(buf,"%lu",cfg.EncCfg.quantqual);
  492                 SetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf);
  493                 break;
  494             }
  495             switch(cfg.EncCfg.bitRate)
  496             {
  497             case 0:
  498                 SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 0, 0);
  499                 break;
  500             default:
  501                 sprintf(buf,"%lu",cfg.EncCfg.bitRate);
  502                 SetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf);
  503                 break;
  504             }
  505             switch(cfg.EncCfg.bandWidth)
  506             {
  507             case 0:
  508                 SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0);
  509                 break;
  510             case 0xffffffff:
  511                 SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 1, 0);
  512                 break;
  513             default:
  514                 sprintf(buf,"%lu",cfg.EncCfg.bandWidth);
  515                 SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf);
  516                 break;
  517             }
  518             
  519             SendMessage(GetDlgItem(hWndDlg, IDC_CB_EXT), CB_SETCURSEL, cfg.SaveMP4, 0);
  520 
  521             if(wParam|lParam)
  522             {
  523                 CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, cfg.AutoCfg);
  524                 DISABLE_CTRLS_ENC(!cfg.AutoCfg);
  525             }
  526 #ifdef USE_IMPORT_TAG
  527             CheckDlgButton(hWndDlg,IDC_CHK_IMPORTTAG, cfg.TagImport);
  528             cfg.TagImport=IsDlgButtonChecked(hWndDlg,IDC_CHK_IMPORTTAG) ? 1 : 0;
  529             ShowWindow(GetDlgItem(hWndDlg, IDC_CHK_IMPORTTAG),SW_SHOW);
  530     #ifdef USE_PATHEXT
  531             SetDlgItemText(hWndDlg, IDC_E_SOURCEPATH, cfg.TagSrcPath);
  532             SetDlgItemText(hWndDlg, IDC_E_SOURCEEXT, cfg.TagSrcExt);
  533             SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSEIMPORT), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
  534             ShowWindow(GetDlgItem(hWndDlg, IDC_E_SOURCEEXT),SW_SHOW);
  535             ShowWindow(GetDlgItem(hWndDlg, IDC_E_SOURCEPATH),SW_SHOW);
  536             ShowWindow(GetDlgItem(hWndDlg, IDC_BTN_BROWSEIMPORT),SW_SHOW);
  537     #endif
  538 #endif
  539             CheckDlgButton(hWndDlg,IDC_CHK_TAG, cfg.TagOn);
  540             ENABLE_TAG(cfg.TagOn && !cfg.TagImport);
  541             ENABLE_AACTAGS(cfg.TagOn && !cfg.TagImport && cfg.SaveMP4);
  542             SetDlgItemText(hWndDlg, IDC_E_ARTIST, cfg.Tag.artist);
  543             SetDlgItemText(hWndDlg, IDC_E_TITLE, cfg.Tag.title);
  544             SetDlgItemText(hWndDlg, IDC_E_ALBUM, cfg.Tag.album);
  545             SetDlgItemText(hWndDlg, IDC_E_YEAR, cfg.Tag.year);
  546             SetDlgItemText(hWndDlg, IDC_CB_GENRE, cfg.Tag.genre);
  547             SetDlgItemText(hWndDlg, IDC_E_WRITER, cfg.Tag.writer);
  548             SetDlgItemText(hWndDlg, IDC_E_COMMENT, cfg.Tag.comment);
  549             SetDlgItemText(hWndDlg, IDC_E_ARTFILE, cfg.Tag.artFilename);
  550             SetDlgItemInt(hWndDlg, IDC_E_TRACK, cfg.Tag.trackno, FALSE);
  551             SetDlgItemInt(hWndDlg, IDC_E_NTRACKS, cfg.Tag.ntracks, FALSE);
  552             SetDlgItemInt(hWndDlg, IDC_E_DISK, cfg.Tag.discno, FALSE);
  553             SetDlgItemInt(hWndDlg, IDC_E_NDISKS, cfg.Tag.ndiscs, FALSE);
  554             SetDlgItemInt(hWndDlg, IDC_E_COMPILATION, cfg.Tag.compilation, FALSE);
  555             CheckDlgButton(hWndDlg, IDC_CHK_COMPILATION, cfg.Tag.compilation);
  556         }
  557         break; // End of WM_INITDIALOG                                 
  558         
  559     case WM_CLOSE:
  560         // Closing the Dialog behaves the same as Cancel               
  561         PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
  562         break; // End of WM_CLOSE                                      
  563         
  564     case WM_COMMAND:
  565         switch(LOWORD(wParam))
  566         {
  567         case IDOK:
  568             {
  569 //          HANDLE hCfg=(HANDLE)lParam;
  570             char buf[50];
  571             CMyEncCfg cfg;
  572 
  573                 cfg.AutoCfg=IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG) ? TRUE : FALSE;
  574                 if(!cfg.AutoCfg)
  575                 {
  576                     cfg.EncCfg.mpegVersion=IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4) ? MPEG4 : MPEG2;
  577                     if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
  578                         cfg.EncCfg.aacObjectType=MAIN;
  579                     if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
  580                         cfg.EncCfg.aacObjectType=LOW;
  581                     if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
  582                         cfg.EncCfg.aacObjectType=SSR;
  583                     if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
  584                         cfg.EncCfg.aacObjectType=LTP;
  585                     cfg.EncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_CHK_ALLOWMIDSIDE);
  586                     cfg.EncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_CHK_USETNS);
  587                     cfg.EncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_CHK_USELFE);
  588                     
  589                     GetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf, 50);
  590                     switch(*buf)
  591                     {
  592                     case 'A': // Auto
  593                         cfg.EncCfg.bitRate=0;
  594                         break;
  595                     default:
  596                         cfg.EncCfg.bitRate=GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
  597                     }
  598                     GetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf, 50);
  599                     switch(*buf)
  600                     {
  601                     case 'A': // Auto
  602                         cfg.EncCfg.bandWidth=0;
  603                         break;
  604                     case 'F': // Full
  605                         cfg.EncCfg.bandWidth=0xffffffff;
  606                         break;
  607                     default:
  608                         cfg.EncCfg.bandWidth=GetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, 0, FALSE);
  609                     }
  610                     cfg.UseQuality=IsDlgButtonChecked(hWndDlg,IDC_RADIO_QUALITY) ? TRUE : FALSE;
  611                     GetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf, 50);
  612                     switch(*buf)
  613                     {
  614                     case 'D': // Default
  615                         cfg.EncCfg.quantqual=100;
  616                         break;
  617                     default:
  618                         cfg.EncCfg.quantqual=GetDlgItemInt(hWndDlg, IDC_CB_QUALITY, 0, FALSE);
  619                     }
  620                 }
  621 
  622                 cfg.EncCfg.outputFormat=IsDlgButtonChecked(hWndDlg,IDC_RADIO_RAW) ? RAW : ADTS;
  623 #ifdef USE_OUTPUT_FOLDER
  624                 GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir, MAX_PATH);
  625                 FREE_ARRAY(cfg.OutDir);
  626                 cfg.OutDir=strdup(config_AACoutdir);
  627 #endif
  628                 cfg.SaveMP4=(BYTE)SendMessage(GetDlgItem(hWndDlg, IDC_CB_EXT), CB_GETCURSEL, 0, 0);
  629 
  630                 cfg.TagOn=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG) ? 1 : 0;
  631             char buffer[MAX_PATH];
  632 #ifdef USE_IMPORT_TAG
  633                 cfg.TagImport=IsDlgButtonChecked(hWndDlg,IDC_CHK_IMPORTTAG) ? 1 : 0;
  634     #ifdef USE_PATHEXT
  635                 GetDlgItemText(hWndDlg, IDC_E_SOURCEPATH, buffer, MAX_PATH);
  636                 cfg.TagSrcPath=strdup(buffer);
  637                 GetDlgItemText(hWndDlg, IDC_E_SOURCEEXT, buffer, MAX_PATH);
  638                 cfg.TagSrcExt=strdup(buffer);
  639     #endif
  640 #endif
  641                 GetDlgItemText(hWndDlg, IDC_E_ARTIST, buffer, MAX_PATH);
  642                 cfg.Tag.artist=strdup(buffer);
  643                 GetDlgItemText(hWndDlg, IDC_E_TITLE, buffer, MAX_PATH);
  644                 cfg.Tag.title=strdup(buffer);
  645                 GetDlgItemText(hWndDlg, IDC_E_ALBUM, buffer, MAX_PATH);
  646                 cfg.Tag.album=strdup(buffer);
  647                 GetDlgItemText(hWndDlg, IDC_E_YEAR, buffer, MAX_PATH);
  648                 cfg.Tag.year=strdup(buffer);
  649                 GetDlgItemText(hWndDlg, IDC_CB_GENRE, buffer, MAX_PATH);
  650                 cfg.Tag.genre=strdup(buffer);
  651                 GetDlgItemText(hWndDlg, IDC_E_WRITER, buffer, MAX_PATH);
  652                 cfg.Tag.writer=strdup(buffer);
  653                 GetDlgItemText(hWndDlg, IDC_E_COMMENT, buffer, MAX_PATH);
  654                 cfg.Tag.comment=strdup(buffer);
  655                 GetDlgItemText(hWndDlg, IDC_E_ARTFILE, buffer, MAX_PATH);
  656                 cfg.Tag.artFilename=strdup(buffer);
  657                 cfg.Tag.trackno=GetDlgItemInt(hWndDlg, IDC_E_TRACK, 0, FALSE);
  658                 cfg.Tag.ntracks=GetDlgItemInt(hWndDlg, IDC_E_NTRACKS, 0, FALSE);
  659                 cfg.Tag.discno=GetDlgItemInt(hWndDlg, IDC_E_DISK, 0, FALSE);
  660                 cfg.Tag.ndiscs=GetDlgItemInt(hWndDlg, IDC_E_NDISKS, 0, FALSE);
  661                 cfg.Tag.compilation=(BYTE)GetDlgItemInt(hWndDlg, IDC_E_COMPILATION, 0, FALSE);
  662                 cfg.Tag.compilation=IsDlgButtonChecked(hWndDlg, IDC_CHK_COMPILATION) ? 1 : 0;
  663                 EndDialog(hWndDlg, TRUE);//(DWORD)hCfg);
  664             }
  665             break;
  666             
  667         case IDCANCEL:
  668             // Ignore data values entered into the controls        
  669             // and dismiss the dialog window returning FALSE
  670             EndDialog(hWndDlg, FALSE);
  671             break;
  672 
  673         case IDC_BTN_ABOUT:
  674             DialogBox((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_ABOUT), (HWND)hWndDlg, (DLGPROC)DialogMsgProcAbout);
  675             break;
  676 
  677         case IDC_BTN_LICENSE:
  678             {
  679             char *license =
  680                 "\nPlease note that the use of this software may require the payment of patent royalties.\n"
  681                 "You need to consider this issue before you start building derivative works.\n"
  682                 "We are not warranting or indemnifying you in any way for patent royalities!\n"
  683                 "YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN ACTIONS!\n"
  684                 "\n"
  685                 "FAAC is based on the ISO MPEG-4 reference code. For this code base the\n"
  686                 "following license applies:\n"
  687                 "\n"
  688 /*              "This software module was originally developed by\n"
  689                 "\n"
  690                 "FirstName LastName (CompanyName)\n"
  691                 "\n"
  692                 "and edited by\n"
  693                 "\n"
  694                 "FirstName LastName (CompanyName)\n"
  695                 "FirstName LastName (CompanyName)\n"
  696                 "\n"
  697 */              "in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard\n"
  698                 "ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an\n"
  699                 "implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools\n"
  700                 "as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives\n"
  701                 "users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this\n"
  702                 "software module or modifications thereof for use in hardware or\n"
  703                 "software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio\n"
  704                 "standards. Those intending to use this software module in hardware or\n"
  705                 "software products are advised that this use may infringe existing\n"
  706                 "patents. The original developer of this software module and his/her\n"
  707                 "company, the subsequent editors and their companies, and ISO/IEC have\n"
  708                 "no liability for use of this software module or modifications thereof\n"
  709                 "in an implementation. Copyright is not released for non MPEG-2\n"
  710                 "NBC/MPEG-4 Audio conforming products. The original developer retains\n"
  711                 "full right to use the code for his/her own purpose, assign or donate\n"
  712                 "the code to a third party and to inhibit third party from using the\n"
  713                 "code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This\n"
  714                 "copyright notice must be included in all copies or derivative works.\n"
  715                 "\n"
  716                 "Copyright (c) 1997.\n"
  717                 "\n"
  718                 "For the changes made for the FAAC project the GNU Lesser General Public\n"
  719                 "License (LGPL), version 2 1991 applies:\n"
  720                 "\n"
  721                 "FAAC - Freeware Advanced Audio Coder\n"
  722                 "Copyright (C) 2001-2004 The individual contributors\n"
  723                 "\n"
  724                 "This library is free software; you can redistribute it and/or modify it under the terms of\n"
  725                 "the GNU Lesser General Public License as published by the Free Software Foundation;\n"
  726                 "either version 2.1 of the License, or (at your option) any later version.\n"
  727                 "\n"
  728                 "This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n"
  729                 "without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
  730                 "See the GNU Lesser General Public License for more details.\n"
  731                 "\n"
  732                 "You should have received a copy of the GNU Lesser General Public\n"
  733                 "License along with this library; if not, write to the Free Software\n"
  734                 "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n";
  735 
  736                 MessageBox(hWndDlg,license,"FAAC libray License",MB_OK|MB_ICONINFORMATION);
  737             }
  738             break;
  739 
  740 #ifdef USE_OUTPUT_FOLDER
  741         case IDC_BTN_BROWSE:
  742             {
  743             BROWSEINFO bi;
  744             ITEMIDLIST *idlist;
  745 
  746                 GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir, MAX_PATH);
  747                 bi.hwndOwner = hWndDlg;
  748                 bi.pidlRoot = 0;
  749                 bi.pszDisplayName = config_AACoutdir;
  750                 bi.lpszTitle = "Select a directory for aac/mp4 file output:";
  751                 bi.ulFlags = BIF_RETURNONLYFSDIRS;
  752                 bi.lpfn = BrowseCallbackProc;
  753                 bi.lParam = (LPARAM)config_AACoutdir;
  754                 
  755                 idlist = SHBrowseForFolder(&bi);
  756                 if(idlist)
  757                 {
  758                     SHGetPathFromIDList(idlist, config_AACoutdir);
  759                     SetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir);
  760                 }
  761             }
  762             break;
  763 #endif          
  764         case IDC_BTN_ARTFILE:
  765             {
  766             OPENFILENAME ofn;
  767             char ArtFilename[MAX_PATH]="";
  768 
  769                 GetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename, MAX_PATH);
  770                 ofn.lStructSize         = sizeof(OPENFILENAME);
  771                 ofn.hwndOwner           = (HWND)hWndDlg;
  772                 ofn.lpstrFilter         = "Cover art files (*.gif,*jpg,*.png)\0*.gif;*.jpg;*.png\0";
  773                 ofn.lpstrCustomFilter   = NULL;
  774                 ofn.nFilterIndex        = 1;
  775                 ofn.lpstrFile           = ArtFilename;
  776                 ofn.nMaxFile            = MAX_PATH; //sizeof ArtFilename;
  777                 ofn.lpstrFileTitle      = NULL;
  778                 ofn.nMaxFileTitle       = 0;
  779                 ofn.lpstrInitialDir     = NULL;
  780                 ofn.lpstrTitle          = "Select cover art file";
  781                 ofn.Flags               = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING;
  782                 ofn.lpstrDefExt         = NULL;//"jpg";
  783                 ofn.hInstance           = hInstance;
  784 
  785                 if(GetOpenFileName(&ofn))
  786                     SetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename);
  787             }
  788             break;
  789 
  790 #ifdef USE_IMPORT_TAG
  791         case IDC_BTN_BROWSEIMPORT:
  792             {
  793             char path[MAX_PATH];
  794             BROWSEINFO bi;
  795             ITEMIDLIST *idlist;
  796 
  797                 GetDlgItemText(hWndDlg, IDC_E_SOURCEPATH, path, MAX_PATH);
  798                 bi.hwndOwner = hWndDlg;
  799                 bi.pidlRoot = 0;
  800                 bi.pszDisplayName = path;
  801                 bi.lpszTitle = "Select the folder where source files are stored:";
  802                 bi.ulFlags = BIF_RETURNONLYFSDIRS;
  803                 bi.lpfn = BrowseCallbackProc;
  804                 bi.lParam = (LPARAM)path;
  805                 
  806                 idlist=SHBrowseForFolder(&bi);
  807                 if(idlist)
  808                 {
  809                     SHGetPathFromIDList(idlist, path);
  810                     SetDlgItemText(hWndDlg, IDC_E_SOURCEPATH, path);
  811                 }
  812             }
  813             break;
  814 #endif          
  815         case IDC_RADIO_MPEG4:
  816             EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
  817             break;
  818             
  819         case IDC_RADIO_MPEG2:
  820             EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
  821             DISABLE_LTP
  822             break;
  823 
  824         case IDC_CHK_AUTOCFG:
  825             {
  826             BYTE Enabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG);
  827                 DISABLE_CTRLS_ENC(!Enabled);
  828                 if(!Enabled)
  829                     SendMessage(hWndDlg, WM_INITDIALOG, 0L, 0L);
  830                 else
  831                 {
  832                     SetDlgItemInt(hWndDlg, IDC_CB_QUALITY, DEF_QUALITY, FALSE);
  833                     SetDlgItemInt(hWndDlg, IDC_CB_BITRATE, DEF_BITRATE, FALSE);
  834                     SetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, DEF_BANDWIDTH, FALSE);
  835 
  836                     CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,FALSE);
  837                     CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,FALSE);
  838                     if(DEF_MPEGVER==MPEG4)
  839                         CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
  840                     else
  841                         CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
  842                     
  843                     CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,FALSE);
  844                     CheckDlgButton(hWndDlg,IDC_RADIO_LOW,FALSE);
  845                     CheckDlgButton(hWndDlg,IDC_RADIO_SSR,FALSE);
  846                     CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE);
  847                     switch(DEF_PROFILE)
  848                     {
  849                     case MAIN:
  850                         CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
  851                         break;
  852                     case LOW:
  853                         CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
  854                         break;
  855                     case SSR:
  856                         CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
  857                         break;
  858                     case LTP:
  859                         CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
  860                         DISABLE_LTP
  861                         break;
  862                     }
  863                     
  864                     CheckDlgButton(hWndDlg,IDC_RADIO_RAW,FALSE);
  865                     CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,FALSE);
  866                     switch(DEF_HEADER)
  867                     {
  868                     case RAW:
  869                         CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);
  870                         break;
  871                     case ADTS:
  872                         CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
  873                         break;
  874                     }
  875                     
  876                     CheckDlgButton(hWndDlg, IDC_CHK_ALLOWMIDSIDE, DEF_MIDSIDE);
  877                     CheckDlgButton(hWndDlg, IDC_CHK_USETNS, DEF_TNS);
  878                     CheckDlgButton(hWndDlg, IDC_CHK_USELFE, DEF_LFE);
  879 
  880                     if(DEF_USEQUALTY)
  881                         CheckDlgButton(hWndDlg,IDC_RADIO_QUALITY,true);
  882                     else
  883                         CheckDlgButton(hWndDlg,IDC_RADIO_BITRATE,true);
  884 
  885                     if(DEF_QUALITY<10)
  886                         SetDlgItemInt(hWndDlg, IDC_CB_QUALITY, 10, FALSE);
  887                     else
  888                         if(DEF_QUALITY>500)
  889                             SetDlgItemInt(hWndDlg, IDC_CB_QUALITY, 500, FALSE);
  890                         else
  891                             SetDlgItemInt(hWndDlg, IDC_CB_QUALITY, DEF_QUALITY, FALSE);
  892 
  893                     switch(DEF_BITRATE)
  894                     {
  895                     case 0:
  896                         SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 0, 0);
  897 //                      SetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 128, FALSE);
  898                         break;
  899                     default:
  900                         SetDlgItemInt(hWndDlg, IDC_CB_BITRATE, DEF_BITRATE, FALSE);
  901                         break;
  902                     }
  903                     switch(DEF_BANDWIDTH)
  904                     {
  905                     case 0:
  906                         SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0);
  907                         break;
  908                     case 0xffffffff:
  909                         SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 1, 0);
  910                         break;
  911                     default:
  912                         SetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, DEF_BANDWIDTH, FALSE);
  913                         break;
  914                     }
  915                     
  916                     SendMessage(GetDlgItem(hWndDlg, IDC_CB_EXT), CB_SETCURSEL, DEF_WRITEMP4, 0);
  917 //                  DISABLE_CTRLS_ENC(!Enabled);
  918                 }
  919             }
  920             break;
  921 
  922         case IDC_CHK_TAG:
  923         case IDC_CB_EXT:
  924             {
  925             char TagImport=IsDlgButtonChecked(hWndDlg,IDC_CHK_IMPORTTAG);
  926             char TagEnabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG);
  927                 ENABLE_TAG(TagEnabled && !TagImport);
  928             char Enabled=SendMessage(GetDlgItem(hWndDlg, IDC_CB_EXT), CB_GETCURSEL, 0, 0)!=0;
  929                 ENABLE_AACTAGS(TagEnabled && !TagImport && Enabled);
  930             }
  931             break;
  932 #ifdef USE_IMPORT_TAG
  933         case IDC_CHK_IMPORTTAG:
  934             SendMessage(hWndDlg, WM_COMMAND, IDC_CHK_TAG, 0);
  935             break;
  936 #endif
  937         }
  938         break; // End of WM_COMMAND
  939     default: 
  940         return FALSE;
  941     }
  942     
  943     return TRUE;
  944 } // End of DIALOGSMsgProc