📄 dialogs.c
字号:
/* this is the first frame, change the CANCEL */
/* button to CLOSE */
LoadString(ghInstApp, IDS_CAPPAL_CLOSE, ach, sizeof(ach));
SetDlgItemText(hwnd, IDCANCEL, ach);
}
if (!shTimer) {
shTimer = SetTimer(hwnd, CAPPAL_TIMER, CAPTIMER_DELAY, NULL);
if (shTimer == 0) {
//!!!error message here.
MessageBeep(0);
return TRUE;
}
/* button said START, let's set up to */
/* do continuous capture. This involves*/
/* 1 - disabling FRAME button */
/* 2 - turning myself to STOP button */
/* 3 - setting up frame timer */
EnableWindow(GetDlgItem(hwnd, IDD_MakePalSingleFrame), FALSE);
LoadString(ghInstApp, IDS_CAPPAL_STOP, ach, sizeof(ach));
SetDlgItemText(hwnd, IDD_MakePalStart, ach);
} else {
/* button said STOP, turn things around */
/* by: */
/* 1 - killing off timers *
/* 2 - turning back into START button */
/* 3 - re-enabling FRAME button */
// "&Start"
LoadString(ghInstApp, IDS_CAPPAL_START, ach, sizeof(ach));
SetDlgItemText(hwnd, IDD_MakePalStart, ach);
EnableWindow(GetDlgItem(hwnd, IDD_MakePalSingleFrame), TRUE);
KillTimer(hwnd, CAPPAL_TIMER);
shTimer = 0;
}
return TRUE;
break;
case IDD_MakePalSingleFrame:
if (!siNumFrames){
/* this is the first frame, change the CANCEL */
/* button to CLOSE */
LoadString(ghInstApp, IDS_CAPPAL_CLOSE, ach, sizeof(ach));
SetDlgItemText(hwnd, IDCANCEL, ach);
siNumColors = GetDlgItemInt(hwnd, IDD_MakePalColors, (BOOL FAR *)ach, FALSE);
siNumColors = max (2, min (256, siNumColors));
}
// Get the palette for a single frame
capPaletteManual (ghWndCap, TRUE, siNumColors);
siNumFrames++;
LoadString(ghInstApp, IDS_CAPPAL_STATUS, achFormat, sizeof(achFormat));
wsprintf(ach, achFormat, siNumFrames);
SetDlgItemText(hwnd, IDD_MakePalNumFrames, ach);
return TRUE;
break;
case IDD_MakePalColors:
if (HIWORD (lParam) == EN_KILLFOCUS) {
w = GetDlgItemInt (hwnd, wParam, NULL, FALSE);
if ( w < 2) {
MessageBeep (0);
SetDlgItemInt (hwnd, wParam, 2, FALSE);
}
else if (w > 256) {
MessageBeep (0);
SetDlgItemInt (hwnd, wParam, 256, FALSE);
}
}
return TRUE;
break;
default:
return FALSE;
} // switch(wParam) on WM_COMMAND
break;
case WM_TIMER:
if (wParam == CAPPAL_TIMER){
SendMessage(hwnd, WM_COMMAND, IDD_MakePalSingleFrame, 0L);
}
break;
default:
return FALSE;
} // switch(msg)
return FALSE;
}
//
// CapSetUpProc: Capture SetUp Details Dialog Box Procedure
//
int FAR PASCAL CapSetUpProc(HWND hDlg, UINT Message, UINT wParam, LONG lParam)
{
static char achBuffer[21] ;
UINT fValue;
switch (Message) {
case WM_INITDIALOG :
{
// Convert from MicroSecPerFrame to FPS -- that's easier !!
MicroSecToStringRate(achBuffer, gCapParms.dwRequestMicroSecPerFrame);
SetDlgItemText(hDlg, IDD_FrameRateData, achBuffer);
// If time limit isn't enabled, disable the time data part
CheckDlgButton(hDlg, IDD_TimeLimitFlag, (fValue = gCapParms.fLimitEnabled)) ;
EnableWindow(GetDlgItem(hDlg, IDD_SecondsText), fValue) ;
EnableWindow(GetDlgItem(hDlg, IDD_SecondsData), fValue) ;
EnableWindow(GetDlgItem(hDlg, IDD_SecondsArrow), fValue);
SetDlgItemInt(hDlg, IDD_SecondsData, gCapParms.wTimeLimit, FALSE) ;
// disable audio buttons if no audio hardware
{
CAPSTATUS cs;
capGetStatus(ghWndCap, &cs, sizeof(cs));
EnableWindow(GetDlgItem(hDlg, IDD_CapAudioFlag), cs.fAudioHardware);
EnableWindow(GetDlgItem(hDlg, IDD_AudioConfig), cs.fAudioHardware);
CheckDlgButton(hDlg, IDD_CapAudioFlag, gCapParms.fCaptureAudio);
}
/*
* Capture To Memory means allocate as many memory buffers
* as possible.
* Capture To Disk means only allocate enough buffers
* to get us through disk seeks and thermal recalibrations.
*/
// The use of fUsingDOSMemory is now just a means of keeping
// track of whether using lots of buffers. We never actually
// allocate exclusively from memory under 1Meg.
CheckRadioButton(hDlg, IDD_CaptureToDisk, IDD_CaptureToMemory,
(gCapParms.fUsingDOSMemory)? IDD_CaptureToDisk : IDD_CaptureToMemory);
// Find out how many MCI devices can source video
if (CountMCIDevices(MCI_DEVTYPE_VCR) +
CountMCIDevices(MCI_DEVTYPE_VIDEODISC) == 0) {
// if no VCRs or Videodiscs, disable the controls
EnableWindow(GetDlgItem(hDlg, IDD_MCIControlFlag), FALSE);
EnableWindow(GetDlgItem(hDlg, IDD_MCISetup), FALSE);
} else {
EnableWindow(GetDlgItem(hDlg, IDD_MCIControlFlag), TRUE);
// if MCI Control is selected, enable the setup button
CheckDlgButton(hDlg, IDD_MCIControlFlag,
gCapParms.fMCIControl);
EnableWindow(GetDlgItem(hDlg, IDD_MCISetup), gCapParms.fMCIControl);
}
// place the dialog to avoid covering the capture window
SmartWindowPosition(hDlg, ghWndCap);
return TRUE ;
}
case WM_COMMAND :
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
case IDD_TimeLimitFlag :
// If this flag changes, en/dis-able time limit data part
fValue = IsDlgButtonChecked(hDlg, IDD_TimeLimitFlag) ;
EnableWindow(GetDlgItem(hDlg, IDD_SecondsText), fValue) ;
EnableWindow(GetDlgItem(hDlg, IDD_SecondsData), fValue) ;
EnableWindow(GetDlgItem(hDlg, IDD_SecondsArrow), fValue);
return TRUE ;
case IDD_MCIControlFlag :
// If this flag changes, en/dis-able MCI Setup button
fValue = IsDlgButtonChecked(hDlg, IDD_MCIControlFlag) ;
EnableWindow(GetDlgItem(hDlg, IDD_MCISetup), fValue) ;
return TRUE ;
case IDD_CapAudioFlag:
fValue = IsDlgButtonChecked(hDlg, IDD_CapAudioFlag) ;
EnableWindow(GetDlgItem(hDlg, IDD_AudioConfig), fValue) ;
return TRUE ;
case IDD_FrameRateData:
// get the requested frame rate and check it against bounds
if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_KILLFOCUS) {
long l, new_l;
GetDlgItemText(hDlg, IDD_FrameRateData, achBuffer, sizeof(achBuffer));
new_l = l = StringRateToMicroSec(achBuffer);
// note that the MAX rate is SMALL! hence <max, >min
if (l == 0) {
new_l = DEF_CAPTURE_RATE;
} else if (l < MAX_CAPTURE_RATE) {
new_l = MAX_CAPTURE_RATE;
} else if (l > MIN_CAPTURE_RATE) {
new_l = MIN_CAPTURE_RATE;
}
if (l != new_l) {
MicroSecToStringRate(achBuffer, new_l);
SetDlgItemText(hDlg, IDD_FrameRateData, achBuffer);
}
}
break;
case IDD_SecondsData:
{
long l, new_l;
// get requested time limit and check validity
GetDlgItemText(hDlg, IDD_SecondsData, achBuffer, sizeof(achBuffer));
new_l = l = atol(achBuffer);
if (l < 1) {
new_l = 1;
} else if (l > 9999) {
new_l = 9999;
} else {
// make sure there are no non-digit chars
// atol() will ignore trailing non-digit characters
int c = 0;
while (achBuffer[c]) {
if (IsCharAlpha(achBuffer[c]) ||
!IsCharAlphaNumeric(achBuffer[c])) {
// string contains non-digit chars - reset
new_l = 1;
break;
}
c++;
}
}
if (new_l != l) {
wsprintf(achBuffer, "%ld", new_l);
SetDlgItemText(hDlg, IDD_SecondsData, achBuffer);
}
break;
}
// show audio format setup dialog
case IDD_AudioConfig:
// rather than duplicate lots of code from the
// main vidcap winproc, lets just ask it to show the dlg...
SendMessage(ghWndMain, WM_COMMAND,
GET_WM_COMMAND_MPS(IDM_O_AUDIOFORMAT, NULL, 0));
break;
// show MCI step control dialog
case IDD_MCISetup:
DoDialog(hDlg, IDD_MCISETUP, MCISetupProc, 0);
break;
// show video format setup dialog
case IDD_VideoConfig:
// rather than duplicate lots of code from the
// main vidcap winproc, lets just ask it to show the dlg...
SendMessage(ghWndMain, WM_COMMAND,
GET_WM_COMMAND_MPS(IDM_O_VIDEOFORMAT, NULL, 0));
break;
// show the compressor selector dialog
case IDD_CompConfig:
capDlgVideoCompression(ghWndCap);
break;
case IDOK :
{
gCapParms.fCaptureAudio =
IsDlgButtonChecked(hDlg, IDD_CapAudioFlag) ;
gCapParms.fMCIControl =
IsDlgButtonChecked(hDlg, IDD_MCIControlFlag);
gCapParms.fLimitEnabled = IsDlgButtonChecked(hDlg, IDD_TimeLimitFlag) ;
GetDlgItemText(hDlg, IDD_FrameRateData, achBuffer, sizeof(achBuffer));
gCapParms.dwRequestMicroSecPerFrame = StringRateToMicroSec(achBuffer);
if (gCapParms.dwRequestMicroSecPerFrame == 0) {
gCapParms.dwRequestMicroSecPerFrame = DEF_CAPTURE_RATE;
}
GetDlgItemText(hDlg, IDD_SecondsData, achBuffer, sizeof(achBuffer));
if (gCapParms.fLimitEnabled) {
gCapParms.wTimeLimit = (UINT) atol(achBuffer);
}
// fUsingDOSMemory is archaic and is now just a flag reflecting
// the "CaptureToDisk" selection.
//
gCapParms.fUsingDOSMemory =
IsDlgButtonChecked(hDlg, IDD_CaptureToDisk);
EndDialog(hDlg, TRUE) ;
return TRUE ;
}
case IDCANCEL :
EndDialog(hDlg, FALSE) ;
return TRUE ;
}
break ;
case WM_VSCROLL:
// message from one of the arrow spinbuttons
{
UINT id;
id = GetDlgCtrlID(GET_WM_COMMAND_HWND(wParam, lParam));
if (id == IDD_FrameRateArrow) {
// format n.nnn
MilliSecVarArrowEditChange(
GetDlgItem(hDlg, IDD_FrameRateData),
GET_WM_VSCROLL_CODE(wParam, lParam),
1, 100, 1);
} else {
// simple integer format
ArrowEditChange(
GetDlgItem(hDlg, IDD_SecondsData),
GET_WM_VSCROLL_CODE(wParam, lParam),
1, 30000);
}
break;
}
}
return FALSE ;
}
/*
* preferences dialog - sets global options about background colour,
* presence of toolbar, status bar etc
*/
int FAR PASCAL
PrefsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
DWORD indexsz;
switch(message) {
case WM_INITDIALOG:
CheckDlgButton(hDlg, IDD_PrefsStatus, gbStatusBar);
CheckDlgButton(hDlg, IDD_PrefsToolbar, gbToolBar);
CheckDlgButton(hDlg, IDD_PrefsCentre, gbCentre);
CheckDlgButton(hDlg, IDD_PrefsSizeFrame, gbAutoSizeFrame);
CheckRadioButton(hDlg, IDD_PrefsDefBackground, IDD_PrefsBlack, gBackColour);
CheckRadioButton(hDlg, IDD_PrefsSmallIndex, IDD_PrefsBigIndex,
(gCapParms.dwIndexSize == CAP_LARGE_INDEX) ?
IDD_PrefsBigIndex : IDD_PrefsSmallIndex);
CheckRadioButton(hDlg, IDD_PrefsMasterAudio, IDD_PrefsMasterNone,
gCapParms.AVStreamMaster + IDD_PrefsMasterAudio);
return(TRUE);
case WM_COMMAND:
switch(GET_WM_COMMAND_ID(wParam, lParam)) {
case IDCANCEL:
EndDialog(hDlg, FALSE);
return(TRUE);
case IDOK:
gbStatusBar = IsDlgButtonChecked(hDlg, IDD_PrefsStatus);
gbToolBar = IsDlgButtonChecked(hDlg, IDD_PrefsToolbar);
gbCentre = IsDlgButtonChecked(hDlg, IDD_PrefsCentre);
gbAutoSizeFrame = IsDlgButtonChecked(hDlg, IDD_PrefsSizeFrame);
if (IsDlgButtonChecked(hDlg, IDD_PrefsDefBackground)) {
gBackColour = IDD_PrefsDefBackground;
} else if (IsDlgButtonChecked(hDlg, IDD_PrefsLtGrey)) {
gBackColour = IDD_PrefsLtGrey;
} else if (IsDlgButtonChecked(hDlg, IDD_PrefsDkGrey)) {
gBackColour = IDD_PrefsDkGrey;
} else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -