📄 cecamera.cpp
字号:
CBR(SetDlgItemText(hwndDlg, IDC_TITLE, CECAMERA_DEFAULT_TITLE));
CBR(SetDlgItemInt(hwndDlg, IDC_RESOLUTION_WIDTH, CECAMERA_DEFAULT_RESOLUTION_WIDTH, 0));
CBR(SetDlgItemInt(hwndDlg, IDC_RESOLUTION_HEIGHT, CECAMERA_DEFAULT_RESOLUTION_HEIGHT, 0));
CBR(SetDlgItemInt(hwndDlg, IDC_VIDEO_TIME_LIMIT, CECAMERA_DEFAULT_VIDEO_TIME_LIMIT, 0));
// Disable the edit controls since specify using default settings
EnableWindow(GetDlgItem(hwndDlg, IDC_INITIAL_DIR), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT_FILE_NAME), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_TITLE), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RESOLUTION_WIDTH), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_RESOLUTION_HEIGHT), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VIDEO_TIME_LIMIT), FALSE);
// Checks the menu item and makes it a radio item
CBR(CheckMenuRadioItem(GetSubMenu(g_hMainMenu, 0), IDM_MODE_STILL, IDM_MODE_VIDEOWITHAUDIO, IDM_MODE_STILL, MF_BYCOMMAND));
CBR(CheckMenuRadioItem(GetSubMenu(g_hMainMenu, 1), IDM_STILLQUALITY_DEFAULT, IDM_STILLQUALITY_HIGH, IDM_STILLQUALITY_DEFAULT, MF_BYCOMMAND));
CBR(CheckMenuRadioItem(GetSubMenu(g_hMainMenu, 2), IDM_VIDEOTYPES_ALL, IDM_VIDEOTYPES_MESSAGING, IDM_VIDEOTYPES_ALL, MF_BYCOMMAND));
// Set the global variables as default value
g_StillQuality = CECAMERA_DEFAULT_STILL_QUALITY;
g_VideoTypes = CECAMERA_DEFAULT_VIDEO_TYPES;
g_Mode = CECAMERA_DEFAULT_MODE;
Error:
return;
}
// ***************************************************************************
// Function Name: ChangeMode
//
// Purpose: Changes "Mode" parameter of SHCameraCapture()
//
// Arguments:
// WORD wMode - The identifier of the menu item
//
// Return Values: none
//
// Description:
// Changes "Mode" parameter of SHCameraCapture(),
// also checks the specified menu item of "Mode".
VOID ChangeMode(WORD wMode)
{
HRESULT hr;
// Update the menu item "Mode"
CBR(CheckMenuRadioItem(GetSubMenu(g_hMainMenu, 0), IDM_MODE_STILL, IDM_MODE_VIDEOWITHAUDIO, wMode, MF_BYCOMMAND));
// Set the global variables as user specified value
switch (wMode)
{
case IDM_MODE_STILL:
g_Mode = CAMERACAPTURE_MODE_STILL;
break;
case IDM_MODE_VIDEOONLY:
g_Mode = CAMERACAPTURE_MODE_VIDEOONLY;
break;
case IDM_MODE_VIDEOWITHAUDIO:
g_Mode = CAMERACAPTURE_MODE_VIDEOWITHAUDIO;
break;
default:
CBR(FALSE);
break;
}
Error:
return;
}
// ***************************************************************************
// Function Name: ChangeStillQuality
//
// Purpose: Changes "StillQuality" parameter of SHCameraCapture()
//
// Arguments:
// WORD wStillQuality - The identifier of the menu item
//
// Return Values: none
//
// Description:
// Changes "StillQuality" parameter of SHCameraCapture(),
// also checks the specified menu item of "StillQuality".
VOID ChangeStillQuality(WORD wStillQuality)
{
HRESULT hr;
// Update the menu item "StillQuality"
CBR(CheckMenuRadioItem(GetSubMenu(g_hMainMenu, 1), IDM_STILLQUALITY_DEFAULT, IDM_STILLQUALITY_HIGH, wStillQuality, MF_BYCOMMAND));
// Set the global variables as user specified value
switch (wStillQuality)
{
case IDM_STILLQUALITY_DEFAULT:
g_StillQuality = CAMERACAPTURE_STILLQUALITY_DEFAULT;
break;
case IDM_STILLQUALITY_LOW:
g_StillQuality = CAMERACAPTURE_STILLQUALITY_LOW;
break;
case IDM_STILLQUALITY_NORMAL:
g_StillQuality = CAMERACAPTURE_STILLQUALITY_NORMAL;
break;
case IDM_STILLQUALITY_HIGH:
g_StillQuality = CAMERACAPTURE_STILLQUALITY_HIGH;
break;
default:
CBR(FALSE);
break;
}
Error:
return;
}
// ***************************************************************************
// Function Name: ChangeVideoTypes
//
// Purpose: Changes "VideoTypes" parameter of SHCameraCapture()
//
// Arguments:
// WORD wVideoTypes - The identifier of the menu item
//
// Return Values: none
//
// Description:
// Changes "VideoTypes" parameter of SHCameraCapture(),
// also checks the specified menu item of "VideoTypes".
VOID ChangeVideoTypes(WORD wVideoTypes)
{
HRESULT hr;
// Update the menu item "VideoTypes"
CBR(CheckMenuRadioItem(GetSubMenu(g_hMainMenu, 2), IDM_VIDEOTYPES_ALL, IDM_VIDEOTYPES_MESSAGING, wVideoTypes, MF_BYCOMMAND));
// Set the global variables as user specified value
switch (wVideoTypes)
{
case IDM_VIDEOTYPES_ALL:
g_VideoTypes = CAMERACAPTURE_VIDEOTYPE_ALL;
break;
case IDM_VIDEOTYPES_STANDARD:
g_VideoTypes = CAMERACAPTURE_VIDEOTYPE_STANDARD;
break;
case IDM_VIDEOTYPES_MESSAGING:
g_VideoTypes = CAMERACAPTURE_VIDEOTYPE_MESSAGING;
break;
default:
CBR(FALSE);
break;
}
Error:
return;
}
// ***************************************************************************
// Function Name: ChangeOptions
//
// Purpose: Enable/Disable user input of the edit controls
//
// Arguments:
// HWND hwndDlg - Handle to the main dialog
// WORD wOptions - The identifier of the control
//
// Return Values: none
//
// Description:
// Enable/Disable user input of the edit controls for allowing/disallowing
// the user to specify the settings of the Camera API.
VOID ChangeOptions(HWND hwndDlg, WORD wOptions)
{
HRESULT hr;
LONG lCheckState;
BOOL bEnable;
// Get the check state of the check box
lCheckState = SendDlgItemMessage(hwndDlg, wOptions, BM_GETCHECK, 0, 0);
bEnable = (BST_UNCHECKED == lCheckState) ? FALSE : TRUE;
// Enable/Disable user input of the edit controls
switch (wOptions)
{
case IDC_CHECK_INITIAL_DIR:
EnableWindow(GetDlgItem(hwndDlg, IDC_INITIAL_DIR), bEnable);
break;
case IDC_CHECK_DEFAULT_FILE_NAME:
EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT_FILE_NAME), bEnable);
break;
case IDC_CHECK_TITLE:
EnableWindow(GetDlgItem(hwndDlg, IDC_TITLE), bEnable);
break;
case IDC_CHECK_RESOLUTION:
EnableWindow(GetDlgItem(hwndDlg, IDC_RESOLUTION_WIDTH), bEnable);
EnableWindow(GetDlgItem(hwndDlg, IDC_RESOLUTION_HEIGHT), bEnable);
break;
case IDC_CHECK_VIDEO_TIME_LIMIT:
EnableWindow(GetDlgItem(hwndDlg, IDC_VIDEO_TIME_LIMIT), bEnable);
break;
default:
CBR(FALSE);
break;
}
Error:
return;
}
// ***************************************************************************
// Function Name: IsOwned
//
// Purpose: Determine if hwnd is owned by hwndOwner.
//
// Arguments:
// hwndOwner - Handle to the owner window
// hwnd - Handle to the owned window
//
// Return Values:
// TRUE if hwnd is owned by hwndOwner.
// FALSE if hwnd isn't owned by hwndOwner.
BOOL IsOwned(HWND hwndOwner, HWND hwnd)
{
BOOL bOwned = FALSE;
while (NULL != (hwnd = GetWindow(hwnd, GW_OWNER)))
{
if (hwnd == hwndOwner)
{
bOwned = TRUE;
break;
}
}
return bOwned;
}
// ***************************************************************************
// Function Name: EnumLastActiveWindowProc
//
// Purpose: Get the topmost, visible, enabled window who is owned by the
// window which specified by the application-defined value given
// in EnumWindows.
//
// Arguments:
// hwnd - Handle to a top-level window
// lParam - Handle to the window which specified by the application-defined
// value given in EnumWindows
//
// Return Values:
// TRUE continues enumeration. FALSE stops enumeration.
BOOL CALLBACK EnumLastActiveWindowProc(HWND hwnd, LPARAM lParam)
{
BOOL bContinue = TRUE;
HWND hOwner = *((HWND *)lParam);
// Ignore windows which are invisible, disabled or cannot be activated.
if (!IsWindowVisible(hwnd) ||
!IsWindowEnabled(hwnd) ||
(WS_EX_NOACTIVATE & GetWindowExStyle(hwnd)))
{
// Continue enumeration.
goto Exit;
}
// If this is the owner window, there are no owned windows because
// all owned windows are always above its owner in the z-order.
if (hwnd == hOwner)
{
// Not found the owned window. Stop enumeration.
bContinue = FALSE;
goto Exit;
}
// Is this window owned by hwndOwner?
if (IsOwned(hOwner, hwnd))
{
// Found the last owned window. Stop enumeration.
bContinue = FALSE;
*((HWND *)lParam) = hwnd;
goto Exit;
}
Exit:
return bContinue;
}
// ***************************************************************************
// Function Name: GetLastActiveWindow
//
// Purpose: Retrieves the last active window owned by hwndOwner.
// The return value is the same as the hwndOwner parameter
// if hwndOwner does not own any windows.
//
// Arguments:
// hwndOwner - Handle to the owner window
//
// Return Values:
// Handle to the last active window.
HWND GetLastActiveWindow(HWND hwndOwner)
{
HWND hwndLastActive = hwndOwner;
EnumWindows(EnumLastActiveWindowProc, (LPARAM)&hwndLastActive);
return hwndLastActive;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -