📄 复件 testvip.cpp
字号:
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
g_hInst = hInstance; // Store instance handle in our global variable
g_hWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW|WS_EX_APPWINDOW|WS_EX_TOPMOST|WS_EX_WINDOWEDGE, g_szWindowClass, g_szTitle,
WS_VISIBLE|WS_CAPTION|WS_BORDER|WS_SYSMENU, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
NULL, hInstance, NULL);
if (!g_hWnd)
return FALSE;
g_hWndCB = CommandBar_Create(g_hInst, g_hWnd, 1000);
CommandBar_InsertMenubar(g_hWndCB, g_hInst, IDR_MENU1, 0);
CommandBar_Show(g_hWndCB, TRUE);
g_hMenu = CommandBar_GetMenu(g_hWndCB, 0);
CheckMenuRadioItem(g_hMenu, ID_MENUVIDEOPLAY, ID_MENUVIDEOSTOP, ID_MENUVIDEOPLAY,
MF_BYCOMMAND);
ShowWindow(g_hWnd, nCmdShow);
UpdateWindow(g_hWnd);
SetFocus(g_hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND g_hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_PAINT:
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case ID_MENUVIDEOPLAY:
case ID_MENUVIDEOSTOP:
if( g_uiVideoChkItemId == LOWORD(wParam) )
break;
g_uiVideoChkItemId = LOWORD(wParam);
CheckMenuRadioItem(g_hMenu, ID_MENUVIDEOPLAY, ID_MENUVIDEOSTOP, LOWORD(wParam),
MF_BYCOMMAND);
if( LOWORD(wParam) == ID_MENUVIDEOPLAY )
{
g_pVideoPort->StartVideo(&g_vpInfo);
}
else
{
g_pVideoPort->StopVideo();
}
break;
case ID_MENUEXIT:
DestroyWindow(g_hWnd);
break;
case ID_MENUSETTINGS:
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_DIALOGSETTING), g_hWnd, SettingDlgProc);
break;
default:
break;
}
break;
case WM_KEYDOWN:
if( lParam & 0x40000000 )
{
// Ignore the repeat key
break;
}
if( (g_uiVideoChkItemId!=ID_MENUVIDEOPLAY) && (wParam!=VK_ESCAPE) && (wParam!='P') )
break;
switch( wParam )
{
case 'P':
if( g_uiVideoChkItemId == ID_MENUVIDEOSTOP )
{
g_pVideoPort->StartVideo(&g_vpInfo);
g_uiVideoChkItemId = ID_MENUVIDEOPLAY;
}
else
{
g_pVideoPort->StopVideo();
g_uiVideoChkItemId = ID_MENUVIDEOSTOP;
}
CheckMenuRadioItem(g_hMenu, ID_MENUVIDEOPLAY, ID_MENUVIDEOSTOP, g_uiVideoChkItemId,
MF_BYCOMMAND);
break;
case VK_BACK:
if( g_pDDSCurrVPSurf == g_pDDSPrimary )
g_pDDSCurrVPSurf = g_pDDSOverlay;
else
g_pDDSCurrVPSurf = g_pDDSPrimary;
if (g_pVideoPort->Flip((LPDIRECTDRAWSURFACE)g_pDDSCurrVPSurf, DDVPFLIP_VIDEO) != DD_OK)
return InitFail(TEXT("Flip FAILED"));
break;
case VK_LEFT:
if( (LONG)(g_vpInfo.dwOriginX-2) >= 0 )
{
g_vpInfo.dwOriginX -= 2;
g_vpInfo.dwPrescaleWidth += 2;
}
else
break;
goto UpdateVideo;
case VK_RIGHT:
if( (g_vpInfo.dwOriginX+2) < 239 )
{
g_vpInfo.dwOriginX += 2;
g_vpInfo.dwPrescaleWidth -= 2;
}
else
break;
goto UpdateVideo;
case VK_UP:
if( g_vpInfo.dwOriginY > 0 )
g_vpInfo.dwOriginY--;
else
break;
goto UpdateVideo;
case VK_DOWN:
if( g_vpInfo.dwOriginY < 319 )
g_vpInfo.dwOriginY++;
else
break;
goto UpdateVideo;
case 'T':
if( g_vpInfo.dwPrescaleWidth == 240 )
g_vpInfo.dwPrescaleWidth = 120;
else if( g_vpInfo.dwPrescaleWidth == 120 )
g_vpInfo.dwPrescaleWidth = 60;
else
break;
goto UpdateVideo;
case 'M':
if( g_vpInfo.dwPrescaleWidth == 60 )
g_vpInfo.dwPrescaleWidth = 120;
else if( g_vpInfo.dwPrescaleWidth == 120 )
g_vpInfo.dwPrescaleWidth = 240;
else
break;
goto UpdateVideo;
case VK_DELETE:
if( g_vpInfo.dwPrescaleHeight == 240 )
g_vpInfo.dwPrescaleHeight = 120;
else if( g_vpInfo.dwPrescaleHeight == 120 )
g_vpInfo.dwPrescaleHeight = 60;
else if( g_vpInfo.dwPrescaleHeight == 60 )
g_vpInfo.dwPrescaleHeight = 30;
else
break;
goto UpdateVideo;
case 'A':
if( g_vpInfo.dwPrescaleHeight == 30 )
g_vpInfo.dwPrescaleHeight = 60;
else if( g_vpInfo.dwPrescaleHeight == 60 )
g_vpInfo.dwPrescaleHeight = 120;
else if( g_vpInfo.dwPrescaleHeight == 120 )
g_vpInfo.dwPrescaleHeight = 240;
else
break;
UpdateVideo:
if (g_pVideoPort->UpdateVideo(&g_vpInfo) != DD_OK)
return InitFail(TEXT("Update video FAILED"));
break;
case '4':
if( g_vpColorControl.lColorEnable == 0 )
g_vpColorControl.lColorEnable = 1;
else
g_vpColorControl.lColorEnable = 0;
goto SetColors;
case 'Z':
if( (g_vpColorControl.lBrightness-500) >= 0 )
g_vpColorControl.lBrightness -= 500;
goto SetColors;
case '3':
if( (g_vpColorControl.lBrightness+500) <= 10000 )
g_vpColorControl.lBrightness += 500;
goto SetColors;
case '9':
if( (g_vpColorControl.lSaturation-500) >= 0 )
g_vpColorControl.lSaturation -= 500;
goto SetColors;
case 'V':
if( (g_vpColorControl.lSaturation+500) <= 20000 )
g_vpColorControl.lSaturation += 500;
goto SetColors;
case 'X':
if( (g_vpColorControl.lContrast-500) >= 0 )
g_vpColorControl.lContrast -= 500;
goto SetColors;
case '2':
if( (g_vpColorControl.lContrast+500) <= 20000 )
g_vpColorControl.lContrast += 500;
goto SetColors;
case VK_TAB:
if( (g_vpColorControl.lHue-30) >= -180 )
g_vpColorControl.lHue -= 30;
goto SetColors;
case VK_SPACE:
if( (g_vpColorControl.lHue+30) <= 180 )
g_vpColorControl.lHue += 30;
SetColors:
if (g_pVideoPort->SetColorControls(&g_vpColorControl) != DD_OK)
return InitFail(TEXT("Set color controls FAILED"));
break;
case VK_ESCAPE:
DestroyWindow(g_hWnd);
break;
}
break;
case WM_DESTROY:
RETAILMSG(1, (TEXT("WndProc MSG: WM_DESTROY\r\n")));
DestroyWindow(g_hWndCB);
ReleaseObjects();
PostQuitMessage(0);
break;
default:
return DefWindowProc(g_hWnd, message, wParam, lParam);
}
return 0;
}
BOOL CALLBACK SettingDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
// UINT i;
// static UINT uiSaveBright, uiSaveSatur, uiSaveContrast, uiSaveHue;
// UINT uiCurBright, uiCurSatur, uiCurContrast, uiCurHue;
switch( uMsg )
{
case WM_INITDIALOG:
/* SendMessage(GetDlgItem(hDlg, IDC_SLIDERBRIGHTNESS), TBM_SETRANGE, FALSE, MAKELONG(0, 100));
SendMessage(GetDlgItem(hDlg, IDC_SLIDERSATURATION), TBM_SETRANGE, FALSE, MAKELONG(0, 100));
SendMessage(GetDlgItem(hDlg, IDC_SLIDERCONTRAST), TBM_SETRANGE, FALSE, MAKELONG(0, 100));
SendMessage(GetDlgItem(hDlg, IDC_SLIDERHUE), TBM_SETRANGE, FALSE, MAKELONG(0, 100));
SendMessage(GetDlgItem(hDlg, IDC_SLIDERBRIGHTNESS), TBM_SETPOS, FALSE, g_VipHWSetting.uiCurBrightness);
SendMessage(GetDlgItem(hDlg, IDC_SLIDERSATURATION), TBM_SETPOS, FALSE, g_VipHWSetting.uiCurSaturation);
SendMessage(GetDlgItem(hDlg, IDC_SLIDERCONTRAST), TBM_SETPOS, FALSE, g_VipHWSetting.uiCurContrast);
SendMessage(GetDlgItem(hDlg, IDC_SLIDERHUE), TBM_SETPOS, FALSE, g_VipHWSetting.uiCurHue);
for(i=1; i<=99; i++)
{
SendMessage(GetDlgItem(hDlg, IDC_SLIDERBRIGHTNESS), TBM_SETTIC, 0, i);
SendMessage(GetDlgItem(hDlg, IDC_SLIDERSATURATION), TBM_SETTIC, 0, i);
SendMessage(GetDlgItem(hDlg, IDC_SLIDERCONTRAST), TBM_SETTIC, 0, i);
SendMessage(GetDlgItem(hDlg, IDC_SLIDERHUE), TBM_SETTIC, 0, i);
}
uiSaveBright = g_VipHWSetting.uiCurBrightness;
uiSaveSatur = g_VipHWSetting.uiCurSaturation;
uiSaveContrast = g_VipHWSetting.uiCurContrast;
uiSaveHue = g_VipHWSetting.uiCurHue;
*/ break;
case WM_NOTIFY:
/* uiCurBright = SendMessage(GetDlgItem(hDlg, IDC_SLIDERBRIGHTNESS), TBM_GETPOS, 0, 0);
uiCurSatur = SendMessage(GetDlgItem(hDlg, IDC_SLIDERSATURATION), TBM_GETPOS, 0, 0);
uiCurContrast = SendMessage(GetDlgItem(hDlg, IDC_SLIDERCONTRAST), TBM_GETPOS, 0, 0);
uiCurHue = SendMessage(GetDlgItem(hDlg, IDC_SLIDERHUE), TBM_GETPOS, 0, 0);
if( (uiCurBright!=g_VipHWSetting.uiCurBrightness) ||
(uiCurSatur!=g_VipHWSetting.uiCurSaturation) ||
(uiCurContrast!=g_VipHWSetting.uiCurContrast) ||
(uiCurHue!=g_VipHWSetting.uiCurHue) )
{
g_VipHWSetting.uiCurBrightness = uiCurBright;
g_VipHWSetting.uiCurSaturation = uiCurSatur;
g_VipHWSetting.uiCurContrast = uiCurContrast;
g_VipHWSetting.uiCurHue = uiCurHue;
DeviceIoControl(g_hVip, IOCTL_VIP_SET_HWSETTING, &g_VipHWSetting,
sizeof(VIP_HW_SETTINGS), NULL, 0, NULL, NULL);
}
*/ break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDCANCEL:
// g_VipHWSetting.uiCurBrightness = uiSaveBright;
// g_VipHWSetting.uiCurSaturation = uiSaveSatur;
// g_VipHWSetting.uiCurContrast = uiSaveContrast;
// g_VipHWSetting.uiCurHue = uiSaveHue;
case IDOK:
EndDialog(hDlg, TRUE);
break;
default:
break;
}
break;
default:
return FALSE;
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -