📄 vidcap.c
字号:
}
// restore old help context
SetCurrentHelpContext(oldhelpid);
if (hFilter) {
UnlockResource(hFilter);
}
}
return(0);
}
/*
* query the user for a filename, and then save the captured video
* to that file
*/
LONG FAR PASCAL
cmdSaveVideoAs(HWND hWnd)
{
OPENFILENAME ofn ;
char achFileName[_MAX_PATH];
UINT wError ;
HANDLE hFilter;
int oldhelpid;
// Get the current capture file name and
// then get the substitute file name to save video in
if (wError = capFileGetCaptureFile(ghWndCap, achFileName, sizeof(achFileName))) {
_fmemset(&ofn, 0, sizeof(OPENFILENAME)) ;
ofn.lStructSize = sizeof(OPENFILENAME) ;
ofn.hwndOwner = hWnd ;
//load filters from resource stringtable
hFilter = FindResource(ghInstApp, MAKEINTRESOURCE(ID_FILTER_AVI), RT_RCDATA);
if ((hFilter = LoadResource(ghInstApp, hFilter)) == NULL) {
ofn.lpstrFilter = NULL;
} else {
ofn.lpstrFilter = LockResource(hFilter);
}
ofn.nFilterIndex = 0 ;
ofn.lpstrFile = achFileName ;
ofn.nMaxFile = sizeof(achFileName) ;
ofn.lpstrFileTitle = NULL ;
ofn.lpstrTitle = tmpString(IDS_TITLE_SAVEAS);
ofn.nMaxFileTitle = 0 ;
ofn.lpstrInitialDir = NULL ;
ofn.Flags =
OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST ;
// set help context
oldhelpid = SetCurrentHelpContext(IDA_SAVECAPFILE);
if (GetSaveFileName(&ofn)) {
// If the user has hit OK then set save file name
capFileSaveAs(ghWndCap, achFileName) ;
}
SetCurrentHelpContext(oldhelpid);
if (hFilter) {
UnlockResource(hFilter);
}
}
return(0);
}
/*
* Put up a dialog to allow the user to select a palette file and then
* load that palette
*/
LONG FAR PASCAL
cmdLoadPalette(HWND hWnd)
{
OPENFILENAME ofn ;
char achFileName[_MAX_PATH];
HANDLE hFilter;
int oldhelpid;
achFileName[0] = 0;
_fmemset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
//load filters from resource stringtable
hFilter = FindResource(ghInstApp, MAKEINTRESOURCE(ID_FILTER_PALETTE), RT_RCDATA);
if ((hFilter = LoadResource(ghInstApp, hFilter)) == NULL) {
ofn.lpstrFilter = NULL;
} else {
ofn.lpstrFilter = LockResource(hFilter);
}
ofn.nFilterIndex = 1;
ofn.lpstrFile = achFileName;
ofn.nMaxFile = sizeof(achFileName);
ofn.lpstrFileTitle = NULL;
ofn.lpstrTitle = tmpString(IDS_TITLE_LOADPALETTE);
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags =
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
// set help context id
oldhelpid = SetCurrentHelpContext(IDA_LOADPAL);
if (GetOpenFileName(&ofn)) {
// If the user has hit OK then load palette
capPaletteOpen(ghWndCap, achFileName);
}
SetCurrentHelpContext(oldhelpid);
if (hFilter) {
UnlockResource(hFilter);
}
return(0);
}
/*
* query the user for a filename, and then save the current palette
* to that file
*/
LONG FAR PASCAL
cmdSavePalette(HWND hWnd)
{
OPENFILENAME ofn ;
char achFileName[_MAX_PATH];
HANDLE hFilter;
int oldhelpid;
achFileName[0] = 0;
_fmemset(&ofn, 0, sizeof(OPENFILENAME)) ;
ofn.lStructSize = sizeof(OPENFILENAME) ;
ofn.hwndOwner = hWnd ;
//load filters from resource stringtable
hFilter = FindResource(ghInstApp, MAKEINTRESOURCE(ID_FILTER_PALETTE), RT_RCDATA);
if ((hFilter = LoadResource(ghInstApp, hFilter)) == NULL) {
ofn.lpstrFilter = NULL;
} else {
ofn.lpstrFilter = LockResource(hFilter);
}
ofn.nFilterIndex = 1;
ofn.lpstrFile = achFileName;
ofn.nMaxFile = sizeof(achFileName);
ofn.lpstrFileTitle = NULL;
ofn.lpstrTitle = tmpString(IDS_TITLE_SAVEPALETTE);
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags =
OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
// set help context for F1 key
oldhelpid = SetCurrentHelpContext(IDA_SAVEPAL);
if (GetSaveFileName(&ofn)) {
// If the user has hit OK then set save file name
capPaletteSave(ghWndCap, achFileName);
}
SetCurrentHelpContext(oldhelpid);
if (hFilter) {
UnlockResource(hFilter);
}
return(0);
}
/*
* query the user for a filename, and then save the current frame
* to that file
*/
LONG FAR PASCAL
cmdSaveDIB(HWND hWnd)
{
OPENFILENAME ofn ;
char achFileName[_MAX_PATH];
HANDLE hFilter;
int oldhelpid;
achFileName[0] = 0;
_fmemset(&ofn, 0, sizeof(OPENFILENAME)) ;
ofn.lStructSize = sizeof(OPENFILENAME) ;
ofn.hwndOwner = hWnd ;
//load filters from resource stringtable
hFilter = FindResource(ghInstApp, MAKEINTRESOURCE(ID_FILTER_DIB), RT_RCDATA);
if ((hFilter = LoadResource(ghInstApp, hFilter)) == NULL) {
ofn.lpstrFilter = NULL;
} else {
ofn.lpstrFilter = LockResource(hFilter);
}
ofn.nFilterIndex = 1;
ofn.lpstrFile = achFileName;
ofn.nMaxFile = sizeof(achFileName);
ofn.lpstrFileTitle = NULL;
ofn.lpstrTitle = tmpString(IDS_TITLE_SAVEDIB);
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags =
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
// set help context for F1 handling
oldhelpid = SetCurrentHelpContext(IDA_SAVEDIB);
if (GetSaveFileName(&ofn)) {
// If the user has hit OK then set save file name
capFileSaveDIB(ghWndCap, achFileName);
}
SetCurrentHelpContext(oldhelpid);
if (hFilter) {
UnlockResource(hFilter);
}
return(0);
}
//
// MenuProc: Processes All Menu-based Operations
//
long FAR PASCAL MenuProc(HWND hWnd, UINT wParam, LONG lParam)
{
////////////////////////////////////////////////////////////////////////
// hWnd: Application main window handle
// hMenu: Application menu handle
// wParam: Menu option
// lParam: Additional info for any menu option
////////////////////////////////////////////////////////////////////////
BOOL fResult ;
DWORD dwSize ;
int oldhelpid;
HMENU hMenu = GetMenu(hWnd) ;
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
case IDC_TOOLBAR:
return toolbarCommand(hWnd, GET_WM_COMMAND_CMD(wParam, lParam), ghWndToolBar);
/* --- file --- */
case IDM_F_SETCAPTUREFILE:
return cmdSetCaptureFile(hWnd);
case IDM_F_SAVEVIDEOAS:
return cmdSaveVideoAs(hWnd);
break;
case IDM_F_ALLOCATESPACE:
if (DoDialog(hWnd, IDD_AllocCapFileSpace, AllocCapFileProc, 0)) {
// ensure repaint after dismissing dialog before
// possibly lengthy operation
UpdateWindow(ghWndMain);
// If user has hit OK then alloc requested capture file space
if (! capFileAlloc(ghWndCap, (long) gwCapFileSize * ONEMEG)) {
MessageBoxID(IDS_ERR_CANT_PREALLOC,
MB_OK | MB_ICONEXCLAMATION) ;
}
}
break ;
case IDM_F_EXIT:
DestroyWindow(hWnd) ;
break;
case IDM_F_LOADPALETTE:
return cmdLoadPalette(hWnd);
case IDM_F_SAVEPALETTE:
return cmdSavePalette(hWnd);
case IDM_F_SAVEFRAME:
return cmdSaveDIB(hWnd);
case IDM_F_EDITVIDEO:
{
char achCmdLine[256];
UINT u;
BOOL f = TRUE; /* assume the best */
HCURSOR hOldCursor;
/* build up the command line "AviEdit -n filename" */
if (lstrlen(gachCaptureFile) > 0) {
lstrcpy(achCmdLine,"VIDEdit -n ");
lstrcat(achCmdLine, gachCaptureFile);
hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
u = WinExec(achCmdLine, SW_SHOWNORMAL);
if (u < 32){
/* report error on forking VidEdit */
MessageBoxID(IDS_ERR_VIDEDIT, MB_OK|MB_ICONEXCLAMATION);
f = FALSE;
}
SetCursor(hOldCursor);
}
return f;
}
/* --- edit --- */
case IDM_E_COPY:
capEditCopy(ghWndCap) ;
break;
case IDM_E_PASTEPALETTE:
capPalettePaste(ghWndCap) ;
break;
case IDM_E_PREFS:
{
if (DoDialog(hWnd, IDD_Prefs, PrefsDlgProc, 0)) {
// write prefs to profile
// force new brush
vidframeSetBrush(ghWndFrame, gBackColour);
// re-do layout
vidcapLayout(hWnd);
}
}
break;
/* --- options --- */
case IDM_O_PREVIEW:
// Toggle Preview
capGetStatus(ghWndCap, &gCapStatus, sizeof(CAPSTATUS)) ;
vidcapSetLive(!gCapStatus.fLiveWindow) ;
break;
case IDM_O_OVERLAY:
// Toggle Overlay
capGetStatus(ghWndCap, &gCapStatus, sizeof(CAPSTATUS)) ;
vidcapSetOverlay(!gCapStatus.fOverlayWindow);
break ;
case IDM_O_AUDIOFORMAT:
#ifdef USE_ACM
{
ACMFORMATCHOOSE cfmt;
static BOOL fDialogUp = FALSE;
if (fDialogUp)
return FALSE;
fDialogUp = TRUE;
// Ask the ACM what the largest wave format is.....
acmMetrics(NULL,
ACM_METRIC_MAX_SIZE_FORMAT,
&dwSize);
// Get the current audio format
dwSize = max (dwSize, capGetAudioFormatSize (ghWndCap));
if (glpwfex = (LPWAVEFORMATEX) GlobalAllocPtr(GHND, dwSize)) {
capGetAudioFormat(ghWndCap, glpwfex, (WORD)dwSize) ;
_fmemset (&cfmt, 0, sizeof (ACMFORMATCHOOSE));
cfmt.cbStruct = sizeof (ACMFORMATCHOOSE);
cfmt.fdwStyle = ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT;
cfmt.fdwEnum = ACM_FORMATENUMF_HARDWARE |
ACM_FORMATENUMF_INPUT;
cfmt.hwndOwner = hWnd;
cfmt.pwfx = glpwfex;
cfmt.cbwfx = dwSize;
//oldhelpid = SetCurrentHelpContext(IDA_AUDIOSETUP);
if (!acmFormatChoose(&cfmt)) {
capSetAudioFormat(ghWndCap, glpwfex, (WORD)glpwfex->cbSize +
sizeof (WAVEFORMATEX)) ;
mmWriteProfileBinary(gachAppTitle, "WaveFormatBinary",
(LPVOID) glpwfex, glpwfex->cbSize +
sizeof (WAVEFORMATEX));
}
//SetCurrentHelpContext(oldhelpid);
GlobalFreePtr(glpwfex) ;
}
fDialogUp = FALSE;
}
#else
{
// Get current audio format and then find required format
dwSize = capGetAudioFormatSize (ghWndCap);
glpwfex = (LPWAVEFORMATEX) GlobalAllocPtr(GHND, dwSize) ;
capGetAudioFormat(ghWndCap, glpwfex, (WORD)dwSize) ;
if (DoDialog(hWnd, IDD_AudioFormat, AudioFormatProc, 0)) {
// If the user has hit OK, set the new audio format
capSetAudioFormat(ghWndCap, glpwfex, (WORD)dwSize) ;
mmWriteProfileBinary(gachAppTitle, "WaveFormatBinary",
(LPVOID) glpwfex, dwSize);
}
GlobalFreePtr(glpwfex) ;
}
#endif
break ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -