123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846 |
- /****************************************************************************
- *
- * Module Title : vfw_config_dlg.c
- *
- * Description : Configuration Parameters dialog module.
- *
- ****************************************************************************/
- /****************************************************************************
- * Header Files
- ****************************************************************************/
- #include <windows.h>
- #include <stdio.h>
- #include <commctrl.h>
- #include "type_aliases.h"
- #include "vp60_comp_interface.h"
- #include "resource.h" // Must be the version resident in the VCAP dll directory!!!
- #include "vpvfwver.h"
- #include "vp6vfw.h"
- #include "vp60_comp_interface.h"
- #include <commdlg.h>
- //#include <cderr.h>
- extern HINSTANCE hInstance;
- void BuildVersionInfo(char *modname,char *VersionInfo,int *vers)
- {
- // ************************************************************
- // The next bit of code reads version information from resource
- VersionInfo[0]=0;
- char szFullPath[256];
- DWORD dwVerHnd;
- DWORD dwVerInfoSize;
- GetModuleFileName(/*GetModuleHandle(modname)*/hInstance, szFullPath, sizeof(szFullPath));
- dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
- if (dwVerInfoSize)
- {
- // If we were able to get the information, process it:
- HANDLE hMem;
- LPVOID lpvMem;
-
- hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
- lpvMem = GlobalLock(hMem);
- GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpvMem);
- UINT cchVer = 0;
- LPSTR lszVer = NULL;
- strcat(VersionInfo, "\r");
- VerQueryValue(lpvMem,TEXT("\\StringFileInfo\\040904E4\\FileDescription"), (void **) &lszVer, &cchVer);
- strcat(VersionInfo,lszVer);
- strcat(VersionInfo, "\r\r");
- VerQueryValue(lpvMem,TEXT("\\StringFileInfo\\040904E4\\LegalCopyright"), (void **) &lszVer, &cchVer);
- strcat(VersionInfo,lszVer);
- strcat(VersionInfo, "\r");
- strcat(VersionInfo, " Version ");
- VerQueryValue(lpvMem,TEXT("\\StringFileInfo\\040904E4\\ProductVersion"), (void **) &lszVer, &cchVer);
- strcat(VersionInfo,lszVer);
- GlobalUnlock(hMem);
- GlobalFree(hMem);
- }
- }
- BOOL FAR PASCAL Advanced_ParamsDlgProc( HWND hWndDlg,UINT Message,WPARAM wParam,LPARAM lParam );
- BOOL FAR PASCAL General_ParamsDlgProc( HWND hWndDlg,UINT Message,WPARAM wParam,LPARAM lParam );
- BOOL FAR PASCAL Settings_ParamsDlgProc( HWND hWndDlg,UINT Message,WPARAM wParam,LPARAM lParam );
- BOOL FAR PASCAL Main_ParamsDlgProc( HWND hWndDlg,
- UINT Message,
- WPARAM wParam,
- LPARAM lParam)
- {
- COMP_CONFIG_VP6 *compConfig = (COMP_CONFIG_VP6 *)GetWindowLong(hWndDlg,GWL_USERDATA);
- switch(Message)
- {
- case WM_NOTIFY:
- {
- switch(wParam)
- {
- case IDC_TAB1:
- {
- NMHDR *msg = (NMHDR *) lParam;
- switch(msg->code)
- {
- case TCN_SELCHANGE:
- {
- HWND hwndTab = GetDlgItem(hWndDlg, IDC_TAB1);
- int whichTab = TabCtrl_GetCurSel(hwndTab);
- switch(whichTab)
- {
- case 2:
- {
- if(compConfig->PlaceHolder)
- DestroyWindow((HWND) compConfig->PlaceHolder);
- compConfig->PlaceHolder = (INT32) CreateDialogParam(hInstance,"SETTINGS",hWndDlg,Settings_ParamsDlgProc ,(LPARAM) compConfig);
- ShowWindow((HWND) compConfig->PlaceHolder,SW_SHOW);
- return TRUE;
- }
- case 0:
- {
- if(compConfig->PlaceHolder)
- DestroyWindow((HWND) compConfig->PlaceHolder);
- compConfig->PlaceHolder = (INT32) CreateDialogParam(hInstance,"GENERAL",hWndDlg,General_ParamsDlgProc ,(LPARAM) compConfig);
- ShowWindow((HWND) compConfig->PlaceHolder,SW_SHOW);
- return TRUE;
- }
- case 1:
- {
- if(compConfig->PlaceHolder)
- DestroyWindow((HWND) compConfig->PlaceHolder);
- compConfig->PlaceHolder = (INT32) CreateDialogParam(hInstance,"ADVANCED",hWndDlg,Advanced_ParamsDlgProc ,(LPARAM) compConfig);
- ShowWindow((HWND) compConfig->PlaceHolder,SW_SHOW);
- return TRUE;
- }
- }
- break;
- }
- }
- break;
- }
- }
- return (FALSE);
- }
- case WM_CTLCOLORSTATIC:
- {
- HDC hdc = (HDC) wParam;
- HWND hwndStatic = (HWND) lParam;
-
- if ( hwndStatic == GetDlgItem ( hWndDlg, IDC_TITLE ) ||
- hwndStatic == GetDlgItem ( hWndDlg, IDC_FRAME ) )
- {
- return (LRESULT) GetStockObject(WHITE_BRUSH); ;
- }
- }
- break;
- case WM_INITDIALOG:
- {
- HWND hwndTab = GetDlgItem(hWndDlg, IDC_TAB1);
- TC_ITEM tie;
-
- SetWindowLong(hWndDlg, GWL_USERDATA, (unsigned long)lParam);
- compConfig = (COMP_CONFIG_VP6 *) lParam;
- tie.mask = TCIF_TEXT | TCIF_STATE | TCIF_IMAGE;
- tie.iImage = -1;
-
- tie.pszText = "General";
- if (TabCtrl_InsertItem(hwndTab, 0, &tie) == -1)
- return NULL;
-
- tie.pszText = "Advanced";
- if (TabCtrl_InsertItem(hwndTab, 1, &tie) == -1)
- return NULL;
- tie.pszText = "Settings";
- if (TabCtrl_InsertItem(hwndTab, 2, &tie) == -1)
- return NULL;
- char VersionString[2048]={0};
- int vers;
- BuildVersionInfo("VP6VFW.DLL",VersionString,&vers);
- SetDlgItemText( hWndDlg, IDC_TITLE, VersionString);
- compConfig->PlaceHolder = (INT32) CreateDialogParam(hInstance,"GENERAL",hWndDlg,General_ParamsDlgProc ,(LPARAM) compConfig);
- ShowWindow((HWND) compConfig->PlaceHolder,SW_SHOW);
-
- return (TRUE);
- }
-
-
- case WM_CLOSE: /* Close the dialog. */
- /* Closing the Dialog behaves the same as Cancel */
- PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
- return (TRUE);
-
- case WM_COMMAND: /* A control has been activated. */
- switch(LOWORD(wParam))
- {
- /* OK leaves the current settings in force */
- case IDOK:
- EndDialog(hWndDlg, IDOK);
- break;
-
- case IDCANCEL:
- EndDialog(hWndDlg, IDCANCEL);
- break;
-
- default:
- return (FALSE);
-
- }
- return (FALSE);
-
- default:
- return (FALSE);
-
- } /* End of Main Dialog case statement. */
- return FALSE;
- } /* End of WndProc */
- BOOL FAR PASCAL General_ParamsDlgProc( HWND hWndDlg,
- UINT Message,
- WPARAM wParam,
- LPARAM lParam)
- {
- COMP_CONFIG_VP6 *compConfig = (COMP_CONFIG_VP6 *)GetWindowLong(hWndDlg,GWL_USERDATA);
- switch(Message)
- {
- case WM_SETFOCUS:
- Message+=0;
- break;
- case WM_INITDIALOG:
- {
- SetWindowLong(hWndDlg, GWL_USERDATA, (unsigned long)lParam);
- compConfig = (COMP_CONFIG_VP6 *) lParam;
-
- // fill mode box
- SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "Realtime / Live Encoding");
- SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "Good Quality Fast Encoding");
- SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "One Pass - Best Quality");
- SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "Two Pass - First Pass" );
- SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "Two Pass - Second Pass - Good Quality");
- SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "Two Pass - Second Pass - Best Quality");
- // set mode
- SendDlgItemMessage(hWndDlg, IDD_MODE, CB_SETCURSEL, (LPARAM) compConfig->Mode,0);
- // set end usage
- switch(compConfig->EndUsage)
- {
- case 0:
- CheckDlgButton( hWndDlg, IDC_ENDUSAGE1, 1);
- CheckDlgButton( hWndDlg, IDC_ENDUSAGE2, 0);
- break;
- default:
- CheckDlgButton( hWndDlg, IDC_ENDUSAGE2, 1);
- CheckDlgButton( hWndDlg, IDC_ENDUSAGE1, 0);
- break;
- }
- // set material
- switch(compConfig->Interlaced)
- {
- case 1:
- CheckDlgButton( hWndDlg, IDC_MATERIAL1, 1);
- CheckDlgButton( hWndDlg, IDC_MATERIAL2, 0);
- break;
- default:
- CheckDlgButton( hWndDlg, IDC_MATERIAL2, 1);
- CheckDlgButton( hWndDlg, IDC_MATERIAL1, 0);
- break;
- }
- // setup noise reduction slider
- SendDlgItemMessage(hWndDlg, IDC_NOISEREDUCTION_SLIDER, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 6));
- // set noise reduction
- SetDlgItemInt( hWndDlg, IDC_NOISEREDUCTION, compConfig->NoiseSensitivity, FALSE );
- SendDlgItemMessage(hWndDlg, IDC_NOISEREDUCTION_SLIDER, TBM_SETPOS, (WPARAM) TRUE,(LPARAM) compConfig->NoiseSensitivity);
- SendDlgItemMessage(hWndDlg, IDC_NOISEREDUCTION_SLIDER, TBM_SETTICFREQ, (WPARAM) 1,(LPARAM) 1);
- // set auto keyframe
- CheckDlgButton( hWndDlg, IDC_AUTOKEYFRAME_CHECK, (compConfig->AutoKeyFrameEnabled) ? 1 : 0 );
- // set max frames btw keys
- SetDlgItemInt( hWndDlg, IDC_MAXFRAMESBTWKEYS, compConfig->ForceKeyFrameEvery, FALSE );
- return (TRUE);
- }
- case WM_HSCROLL:
- {
- // change edit box to match slider
- SetDlgItemInt( hWndDlg, IDC_NOISEREDUCTION, SendDlgItemMessage(hWndDlg, IDC_NOISEREDUCTION_SLIDER, TBM_GETPOS, 0,0), FALSE );
- return (TRUE);
- }
-
- case WM_DESTROY: //case WM_CLOSE: /* Close the dialog. */
-
- // save everything to our structure
- compConfig->AutoKeyFrameEnabled = SendDlgItemMessage(hWndDlg, IDC_AUTOKEYFRAME_CHECK, BM_GETCHECK, 0, 0);
- compConfig->EndUsage = (END_USAGE) SendDlgItemMessage(hWndDlg, IDC_ENDUSAGE2, BM_GETCHECK, 0, 0);
- compConfig->Interlaced = SendDlgItemMessage(hWndDlg, IDC_MATERIAL1, BM_GETCHECK, 0, 0);
- compConfig->ForceKeyFrameEvery = GetDlgItemInt(hWndDlg, IDC_MAXFRAMESBTWKEYS, NULL, FALSE );
- compConfig->Mode = (MODE) SendDlgItemMessage(hWndDlg, IDD_MODE, CB_GETCURSEL, 0, 0);
- compConfig->NoiseSensitivity = GetDlgItemInt(hWndDlg, IDC_NOISEREDUCTION, NULL, FALSE );
- return (TRUE);
-
- case WM_COMMAND: /* A control has been activated. */
- {
- switch(HIWORD(wParam))
- {
- case EN_KILLFOCUS:
- {
- // error checking
- int value = GetDlgItemInt(hWndDlg, LOWORD(wParam), NULL, FALSE );
- switch(LOWORD(wParam))
- {
- case IDC_NOISEREDUCTION:
- {
- if(value < 0) value = 0;
- if(value > 6) value = 6;
- SendDlgItemMessage(hWndDlg, IDC_NOISEREDUCTION_SLIDER, TBM_SETPOS, (WPARAM) TRUE, value );
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- break;
- case IDC_MAXFRAMESBTWKEYS:
- {
- if(value < 0) value = 0;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- default:
- return (FALSE);
- }
-
- }
- }
- return (FALSE);
- }
-
- default:
- return (FALSE);
-
- } /* End of Main Dialog case statement. */
- return FALSE;
- } /* End of WndProc */
- BOOL FAR PASCAL Advanced_ParamsDlgProc( HWND hWndDlg,
- UINT Message,
- WPARAM wParam,
- LPARAM lParam)
- {
- COMP_CONFIG_VP6 *compConfig = (COMP_CONFIG_VP6 *)GetWindowLong(hWndDlg,GWL_USERDATA);
- switch(Message)
- {
- case WM_INITDIALOG:
- {
-
- SetWindowLong(hWndDlg, GWL_USERDATA, (unsigned long)lParam);
- compConfig = (COMP_CONFIG_VP6 *) lParam;
- if ( compConfig->EndUsage == 1)
- {
- EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_MAXBITRATE), 0);
- EnableWindow(GetDlgItem(hWndDlg, STREAMING_PARAMETERS), 0);
- EnableWindow(GetDlgItem(hWndDlg, PEAK_BITRATE), 0);
- EnableWindow(GetDlgItem(hWndDlg, PREBUFFER), 0);
- EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_PREBUFFER), 0);
- EnableWindow(GetDlgItem(hWndDlg, OPTIMAL_BUFFER), 0);
- EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_OPTIMAL), 0);
- EnableWindow(GetDlgItem(hWndDlg, MAX_BUFFER), 0);
- EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_MAXBUFFER), 0);
- }
- if(compConfig->Mode < 4)
- {
- EnableWindow(GetDlgItem(hWndDlg, TWO_PASS_SECTION_DATARATE), 0);
- EnableWindow(GetDlgItem(hWndDlg, VARIABILITY), 0);
- EnableWindow(GetDlgItem(hWndDlg, IDC_DATARATEVARIABILITY), 0);
- EnableWindow(GetDlgItem(hWndDlg, MIN_SECTION), 0);
- EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_MINBANDWIDTH), 0);
- EnableWindow(GetDlgItem(hWndDlg, MAX_SECTION), 0);
- EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_MAXBANDWIDTH), 0);
- }
- // set buffer stats
- SetDlgItemInt( hWndDlg, IDC_EDIT_PREBUFFER, compConfig->StartingBufferLevel, FALSE );
- SetDlgItemInt( hWndDlg, IDC_EDIT_OPTIMAL, compConfig->OptimalBufferLevel, FALSE );
- SetDlgItemInt( hWndDlg, IDC_EDIT_MAXBUFFER, compConfig->MaximumBufferSize, FALSE );
- // setup vbr slider
- SendDlgItemMessage(hWndDlg, IDC_DATARATEVARIABILITY_SLIDER, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 100));
- SendDlgItemMessage(hWndDlg, IDC_DATARATEVARIABILITY_SLIDER, TBM_SETTICFREQ, (WPARAM) 10,(LPARAM) 10);
- // set vbr settings
- SendDlgItemMessage(hWndDlg, IDC_DATARATEVARIABILITY_SLIDER, TBM_SETPOS, (WPARAM) TRUE,(LPARAM) compConfig->TwoPassVBRBias);
- SetDlgItemInt( hWndDlg, IDC_DATARATEVARIABILITY, compConfig->TwoPassVBRBias, FALSE );
- SetDlgItemInt( hWndDlg, IDC_EDIT_MINBANDWIDTH, compConfig->TwoPassVBRMinSection, FALSE );
- SetDlgItemInt( hWndDlg, IDC_EDIT_MAXBANDWIDTH, compConfig->TwoPassVBRMaxSection, FALSE );
- SetDlgItemInt( hWndDlg, IDC_EDIT_MAXBITRATE, compConfig->MaxAllowedDatarate, FALSE );
- // datarate control options
- SetDlgItemInt( hWndDlg, IDC_EDIT_UNDERSHOOT, compConfig->UnderShootPct, FALSE );
- // set adjust quantizer control
- CheckDlgButton( hWndDlg, IDC_ADJUSTQ_CHECK, (compConfig->FixedQ) ? 0 : 1 );
- SetDlgItemInt( hWndDlg, IDC_EDIT_MINQUALITY, compConfig->BestAllowedQ, FALSE );
- SetDlgItemInt( hWndDlg, IDC_EDIT_MAXQUALITY, compConfig->Quality, FALSE );
- // allowing dropped frames
- CheckDlgButton( hWndDlg, IDC_ALLOW_DROPPED_FRAMES_CHECK, (compConfig->AllowDF) ? 1 : 0 );
- SetDlgItemInt( hWndDlg, IDC_EDIT_TEMPORAL_DOWN, compConfig->DropFramesWaterMark, FALSE );
- // allowing spatial resampling
- CheckDlgButton( hWndDlg, IDC_SCALE_CHECK, (compConfig->AllowSpatialResampling) ? 1 : 0 );
- SetDlgItemInt( hWndDlg, IDC_EDIT_SPATIAL_DOWN, compConfig->ResampleDownWaterMark, FALSE );
- SetDlgItemInt( hWndDlg, IDC_EDIT_SPATIAL_UP, compConfig->ResampleUpWaterMark, FALSE );
-
-
- return (TRUE);
- }
-
-
- case WM_DESTROY: //case WM_CLOSE: /* Close the dialog. */
-
- // save everything to our structure
- compConfig->StartingBufferLevel = GetDlgItemInt(hWndDlg, IDC_EDIT_PREBUFFER, NULL, FALSE );
- compConfig->OptimalBufferLevel = GetDlgItemInt(hWndDlg, IDC_EDIT_OPTIMAL, NULL, FALSE );
- compConfig->MaximumBufferSize = GetDlgItemInt(hWndDlg, IDC_EDIT_MAXBUFFER, NULL, FALSE );
- compConfig->TwoPassVBRBias = GetDlgItemInt(hWndDlg, IDC_DATARATEVARIABILITY, NULL, FALSE );
- compConfig->TwoPassVBRMinSection = GetDlgItemInt(hWndDlg, IDC_EDIT_MINBANDWIDTH, NULL, FALSE );
- compConfig->TwoPassVBRMaxSection = GetDlgItemInt(hWndDlg, IDC_EDIT_MAXBANDWIDTH, NULL, FALSE );
- compConfig->MaxAllowedDatarate = GetDlgItemInt(hWndDlg, IDC_EDIT_MAXBITRATE, NULL, FALSE );
- compConfig->UnderShootPct = GetDlgItemInt(hWndDlg, IDC_EDIT_UNDERSHOOT, NULL, FALSE );
- compConfig->FixedQ = !SendDlgItemMessage(hWndDlg, IDC_ADJUSTQ_CHECK, BM_GETCHECK, 0, 0);
- compConfig->BestAllowedQ = GetDlgItemInt(hWndDlg, IDC_EDIT_MINQUALITY, NULL, FALSE );
- compConfig->Quality = GetDlgItemInt(hWndDlg, IDC_EDIT_MAXQUALITY, NULL, FALSE );
- compConfig->AllowDF = SendDlgItemMessage(hWndDlg, IDC_ALLOW_DROPPED_FRAMES_CHECK, BM_GETCHECK, 0, 0);
- compConfig->DropFramesWaterMark = GetDlgItemInt(hWndDlg, IDC_EDIT_TEMPORAL_DOWN, NULL, FALSE );
- compConfig->AllowSpatialResampling = SendDlgItemMessage(hWndDlg, IDC_SCALE_CHECK, BM_GETCHECK, 0, 0);
- compConfig->ResampleDownWaterMark = GetDlgItemInt(hWndDlg, IDC_EDIT_SPATIAL_DOWN, NULL, FALSE );
- compConfig->ResampleUpWaterMark = GetDlgItemInt(hWndDlg, IDC_EDIT_SPATIAL_UP, NULL, FALSE );
- return (TRUE);
- case WM_HSCROLL:
- {
- // change edit box to match slider
- SetDlgItemInt( hWndDlg, IDC_DATARATEVARIABILITY, SendDlgItemMessage(hWndDlg, IDC_DATARATEVARIABILITY_SLIDER, TBM_GETPOS, 0,0), FALSE );
- return (TRUE);
- }
-
- case WM_COMMAND: /* A control has been activated. */
- {
- switch(HIWORD(wParam))
- {
- case EN_KILLFOCUS:
- {
- // error checking
- int value = GetDlgItemInt(hWndDlg, LOWORD(wParam), NULL, FALSE );
- switch(LOWORD(wParam))
- {
- case IDC_DATARATEVARIABILITY:
- {
- if(value < 0) value = 0;
- if(value > 100 ) value = 100;
- SendDlgItemMessage(hWndDlg, IDC_DATARATEVARIABILITY_SLIDER, TBM_SETPOS, (WPARAM) TRUE, value );
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- // save everything to our structure
- case IDC_EDIT_PREBUFFER:
- {
- if(value < 0) value = 0;
- if(value > 30 ) value = 30;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- case IDC_EDIT_OPTIMAL:
- {
- if(value < 0) value = 0;
- if(value > 30 ) value = 30;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- case IDC_EDIT_MAXBUFFER:
- {
- if(value < 0) value = 0;
- if(value > 30 ) value = 30;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- case IDC_EDIT_MINBANDWIDTH:
- {
- if(value < 0) value = 0;
- if(value > 100 ) value = 100;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- case IDC_EDIT_MAXBANDWIDTH:
- {
- if(value < 100) value = 100;
- if(value > 1000 ) value = 1000;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- case IDC_EDIT_UNDERSHOOT:
- {
- if(value < 50) value = 50;
- if(value > 100 ) value = 100;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- case IDC_EDIT_MINQUALITY:
- {
- if(value < 0) value = 0;
- if(value > 63 ) value = 63;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- case IDC_EDIT_MAXQUALITY:
- {
- if(value < 0) value = 0;
- if(value > 63 ) value = 63;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- case IDC_EDIT_TEMPORAL_DOWN :
- {
- if(value < 0) value = 0;
- if(value > 100 ) value = 100;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- case IDC_EDIT_SPATIAL_DOWN :
- {
- if(value < 0) value = 0;
- if(value > 100 ) value = 100;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- case IDC_EDIT_SPATIAL_UP :
- {
- if(value < 0) value = 0;
- if(value > 100 ) value = 100;
- SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
- break;
- }
- }
- }
- default:
- return (FALSE);
- }
-
- return (FALSE);
- }
-
- default:
- return (FALSE);
-
- } /* End of Main Dialog case statement. */
- return FALSE;
- } /* End of WndProc */
- BOOL FAR PASCAL Settings_ParamsDlgProc( HWND hWndDlg,
- UINT Message,
- WPARAM wParam,
- LPARAM lParam)
- {
- COMP_CONFIG_VP6 *compConfig = (COMP_CONFIG_VP6 *)GetWindowLong(hWndDlg,GWL_USERDATA);
- switch(Message)
- {
- case WM_INITDIALOG:
- {
- SetWindowLong(hWndDlg, GWL_USERDATA, (unsigned long)lParam);
- compConfig = (COMP_CONFIG_VP6 *) lParam;
- if(!memcmp(compConfig->SettingsFile,compConfig->RootDirectory,strlen(compConfig->RootDirectory)))
- {
- strcpy(compConfig->SettingsFile,compConfig->SettingsFile+strlen(compConfig->RootDirectory));
- }
- if(!memcmp(compConfig->SettingsFile+strlen(compConfig->SettingsFile)-4,".vps",4))
- {
- compConfig->SettingsFile[strlen(compConfig->SettingsFile)-4]=0;
- }
- SetDlgItemText(hWndDlg,IDC_FIRSTPASS,compConfig->FirstPassFile);
- SetDlgItemText(hWndDlg,IDC_SETTINGSFILE,compConfig->SettingsFile);
- WIN32_FIND_DATA wfd;
- char FileFilter[512];
- strncpy(FileFilter,compConfig->RootDirectory,512);
- strcat(FileFilter,"\\*.vps");
- HANDLE ffh = FindFirstFile(FileFilter,&wfd);
- if( ffh !=INVALID_HANDLE_VALUE)
- {
- do
- {
- wfd.cFileName[strlen(wfd.cFileName)-4]=0;
- SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_ADDSTRING, 0, (LPARAM) (LPCSTR) wfd.cFileName);
- }
- while ( FindNextFile(ffh,&wfd));
- FindClose(ffh);
- }
-
- return (TRUE);
- }
-
- case WM_DESTROY: //case WM_CLOSE: /* Close the dialog. */
-
- // save everything to our structure
- GetDlgItemText(hWndDlg,IDC_FIRSTPASS,compConfig->FirstPassFile,512);
- GetDlgItemText(hWndDlg,IDC_SETTINGSFILE,compConfig->SettingsFile,512);
- if(compConfig->SettingsFile[1] != ':' && compConfig->SettingsFile[1] != '\\')
- {
- char tmp[512];
- strncpy(tmp,compConfig->SettingsFile,512);
- strncpy(compConfig->SettingsFile,compConfig->RootDirectory,512);
- strcat(compConfig->SettingsFile,tmp);
- }
- if(compConfig->SettingsFile[strlen(compConfig->SettingsFile)-4] != '.' )
- {
- strcat(compConfig->SettingsFile,".vps");
- }
- return (TRUE);
-
- case WM_COMMAND: /* A control has been activated. */
- {
- switch(HIWORD(wParam))
- {
- case LBN_SELCHANGE :
- {
- int curSel =SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_GETCURSEL, 0, 0);
- SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_GETTEXT, curSel, (DWORD) compConfig->SettingsFile);
- SetDlgItemText(hWndDlg,IDC_SETTINGSFILE,compConfig->SettingsFile);
- if(compConfig->SettingsFile[1] != ':' && compConfig->SettingsFile[1] != '\\')
- {
- char tmp[512];
- strncpy(tmp,compConfig->SettingsFile,512);
- strncpy(compConfig->SettingsFile,compConfig->RootDirectory,512);
- strcat(compConfig->SettingsFile,"\\");
- strcat(compConfig->SettingsFile,tmp);
- }
- if(compConfig->SettingsFile[strlen(compConfig->SettingsFile)-4] != '.' )
- {
- strcat(compConfig->SettingsFile,".vps");
- }
- FILE *f = fopen(compConfig->SettingsFile,"rb");
- if(f)
- {
- char tmp[512];
- HWND still = (HWND) compConfig->PlaceHolder;
- strncpy(tmp,compConfig->RootDirectory,512);
- fread(compConfig,sizeof COMP_CONFIG_VP6,1,f);
- strncpy(compConfig->RootDirectory,tmp,512);
- fclose(f);
- compConfig->PlaceHolder = (INT32) still;
- }
- }
- case BN_CLICKED:
- switch(LOWORD(wParam))
- {
- case ID_SAVE:
- {
- FILE *f;
- GetDlgItemText(hWndDlg,IDC_SETTINGSFILE,compConfig->SettingsFile,512);
- GetDlgItemText(hWndDlg,IDC_FIRSTPASS,compConfig->FirstPassFile,512);
-
- if(compConfig->SettingsFile[1] != ':' && compConfig->SettingsFile[1] != '\\')
- {
- char tmp[512];
- strncpy(tmp,compConfig->SettingsFile,512);
- strncpy(compConfig->SettingsFile,compConfig->RootDirectory,512);
- strcat(compConfig->SettingsFile,"\\");
- strcat(compConfig->SettingsFile,tmp);
- }
- if(compConfig->SettingsFile[strlen(compConfig->SettingsFile)-4] != '.' )
- {
- strcat(compConfig->SettingsFile,".vps");
- }
- f=fopen(compConfig->SettingsFile,"wb");
- if(f)
- {
- fwrite(compConfig,10+sizeof COMP_CONFIG_VP6,1,f);
- fclose(f);
- }
- int curSel = SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_FINDSTRING, 0, (LPARAM) (LPCSTR) compConfig->SettingsFile );
- if( curSel == LB_ERR)
- {
- WIN32_FIND_DATA wfd;
- int curSel = SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_RESETCONTENT, 0, 0 );
- char FileFilter[512];
- strncpy(FileFilter,compConfig->RootDirectory,512);
- strcat(FileFilter,"\\*.vps");
- HANDLE ffh = FindFirstFile(FileFilter,&wfd);
- if( ffh !=INVALID_HANDLE_VALUE)
- {
- do
- {
- wfd.cFileName[strlen(wfd.cFileName)-4]=0;
- SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_ADDSTRING, 0, (LPARAM) (LPCSTR) wfd.cFileName);
- }
- while ( FindNextFile(ffh,&wfd));
- FindClose(ffh);
- }
- }
-
- return TRUE;
- };
- case ID_DELETE:
- {
- int curSel =SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_GETCURSEL, 0, 0);
- SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_DELETESTRING, curSel, 0);
- DeleteFile(compConfig->SettingsFile);
- return TRUE;
- };
- case IDC_LOAD_FIRSTPASS:
- {
- static TCHAR szFilterLoad[] = TEXT("VP First Pass \0*.vpf\0\0");
- OPENFILENAME ofn;
- TCHAR szTitle[64];
- TCHAR szT[256];
- ofn.lStructSize= sizeof(ofn);
- ofn.hInstance= 0;
- ofn.lpstrFilter= szFilterLoad;
- ofn.lpstrCustomFilter= NULL;
- ofn.nMaxCustFilter= 0;
- ofn.nFilterIndex= 0;
- ofn.lpstrFileTitle= szTitle;
- ofn.nMaxFileTitle= sizeof(szTitle);
- ofn.lpstrInitialDir= compConfig->RootDirectory;
- ofn.lpstrTitle= NULL;
- ofn.nFileOffset= 0;
- ofn.nFileExtension= 0;
- ofn.lpstrDefExt= "vps";
- ofn.lCustData= 0L;
- ofn.lpfnHook= NULL;
- ofn.lpTemplateName= NULL;
- ofn.hwndOwner= hWndDlg;
- ofn.lpstrFile= szT;
- ofn.nMaxFile= sizeof(szT);
- ofn.Flags= 0;
- szTitle[0] = TEXT('\0');
- szT[0] = TEXT('\0');
- if(GetOpenFileName(&ofn))
- {
- strncpy(compConfig->FirstPassFile,ofn.lpstrFile,512);
- SetDlgItemText(hWndDlg,IDC_FIRSTPASS,compConfig->FirstPassFile);
- }
-
- return TRUE;
- }
- case IDC_LOAD_SETTINGS:
- {
- static TCHAR szFilterLoad[] = TEXT("VP Setting Files\0*.vps\0\0");
- OPENFILENAME ofn;
- TCHAR szTitle[64];
- TCHAR szT[256];
- ofn.lStructSize= sizeof(ofn);
- ofn.hInstance= 0;
- ofn.lpstrFilter= szFilterLoad;
- ofn.lpstrCustomFilter= NULL;
- ofn.nMaxCustFilter= 0;
- ofn.nFilterIndex= 0;
- ofn.lpstrFileTitle= szTitle;
- ofn.nMaxFileTitle= sizeof(szTitle);
- ofn.lpstrInitialDir= compConfig->RootDirectory;
- ofn.lpstrTitle= NULL;
- ofn.nFileOffset= 0;
- ofn.nFileExtension= 0;
- ofn.lpstrDefExt= "vps";
- ofn.lCustData= 0L;
- ofn.lpfnHook= NULL;
- ofn.lpTemplateName= NULL;
- ofn.hwndOwner= hWndDlg;
- ofn.lpstrFile= szT;
- ofn.nMaxFile= sizeof(szT);
- ofn.Flags= 0;
- szTitle[0] = TEXT('\0');
- szT[0] = TEXT('\0');
- if(GetOpenFileName(&ofn))
- {
-
- strncpy(compConfig->SettingsFile,ofn.lpstrFile,512);
- FILE *f = fopen(compConfig->SettingsFile,"rb");
- if(f)
- {
- HWND still = (HWND) compConfig->PlaceHolder;
- fread(compConfig,sizeof COMP_CONFIG_VP6,1,f);
- fclose(f);
- compConfig->PlaceHolder = (INT32) still;
- }
- if(!memcmp(compConfig->SettingsFile,compConfig->RootDirectory,strlen(compConfig->RootDirectory)))
- {
- strcpy(compConfig->SettingsFile,compConfig->SettingsFile+strlen(compConfig->RootDirectory));
- }
- if(!memcmp(compConfig->SettingsFile+strlen(compConfig->SettingsFile)-4,".vps",4))
- {
- compConfig->SettingsFile[strlen(compConfig->SettingsFile)-4]=0;
- }
- SetDlgItemText(hWndDlg,IDC_SETTINGSFILE,compConfig->SettingsFile);
- }
-
- return TRUE;
- }
- }
- break;
- default:
- break;
- }
- }
- default:
- return (FALSE);
-
- } /* End of Main Dialog case statement. */
- return FALSE;
- } /* End of WndProc */
|