📄 airguard_c.cpp
字号:
SendMessage(g_hwndRadioManual, BM_SETCHECK, TRUE, 0L);
//......................
g_hwndRadioZoom = CreateWindowEx(0, "button", NULL,
BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP,
260, BASELINE, 15, 15,
hWnd, (HMENU)ID_RADIOZOOM, g_hInst, NULL);
tlinf.uId = ( UINT)g_hwndRadioZoom;
tlinf.lpszText = "变焦";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
g_hwndRadioFocus = CreateWindowEx(0, "button", NULL,
BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE,
285, BASELINE, 15, 15,
hWnd, (HMENU)ID_RADIOFOCUS, g_hInst, NULL);
tlinf.uId = ( UINT)g_hwndRadioFocus;
tlinf.lpszText = "焦距";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
g_hwndRadioAperture = CreateWindowEx(0, "button", NULL,
BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE,
310, BASELINE, 15, 15,
hWnd, (HMENU)ID_RADIOAPERTURE, g_hInst, NULL);
tlinf.uId = ( UINT)g_hwndRadioAperture;
tlinf.lpszText = "光圈";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
SendMessage(g_hwndRadioZoom, BM_SETCHECK, TRUE, 0L);
//-------------------------------------------------------
g_hwndVideo = CreateWindowEx(WS_EX_STATICEDGE, "VideoWindow", 0,
WS_CHILD | WS_VISIBLE, 145, 25, 640, 480,
hWnd, NULL, g_hInst, 0);
if (!g_hwndVideo)
MessageBox(NULL, "Create Video Window error", "error", MB_OK);
g_hwndEditChimneyInfo = CreateWindowEx(WS_EX_STATICEDGE, "edit", NULL,
WS_VISIBLE | WS_CHILD | ES_LEFT | ES_MULTILINE | WS_HSCROLL | ES_READONLY,
20, 240, 100, 120,
hWnd, (HMENU)ID_EDITBLACKNESS, g_hInst, NULL);
g_hwndEditBlackness = CreateWindowEx(WS_EX_STATICEDGE, "edit", NULL,
WS_VISIBLE | WS_CHILD | ES_LEFT | ES_READONLY | ES_MULTILINE,
20, 400, 100, 20,
hWnd, (HMENU)ID_EDITBLACKNESS, g_hInst, NULL);
g_hwndEditSysState = CreateWindowEx(WS_EX_STATICEDGE, "edit", NULL,
WS_VISIBLE | WS_CHILD | ES_LEFT | ES_READONLY | ES_MULTILINE,
20, 480, 100, 20,
hWnd, (HMENU)ID_EDITBLACKNESS, g_hInst, NULL);
g_hwndLogoWindow = CreateWindowEx(NULL, "LogoWindow", 0,
WS_CHILD | WS_VISIBLE,
800, 30, 100, 130,
hWnd, NULL, g_hInst, 0);
if (!g_hwndVideo)
MessageBox(NULL, "Create Video Window error", "error", MB_OK);
g_TrackbarIllumination = CreateTrackbar(
hWnd, // handle of dialog box (parent window)
0, // minimum value in trackbar range
10, // maximum value in trackbar range
0, // minimum value in trackbar selection
10, // maximum value in trackbar selection
800, 240,
100, 20,
ID_TRACKBAR_CAMNUM);
g_BtnSetPreset = CreateWindowEx(0, "button", "预置...",
BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 800, 310, 100, 25,
hWnd, (HMENU)ID_BTNSETPRESET, g_hInst, NULL);
g_BtnGotoPreset = CreateWindowEx(0, "button", "转到...",
BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 800, 340, 100, 25,
hWnd, (HMENU)ID_BTNGOTO, g_hInst, NULL);
g_BtnNextChimney = CreateWindowEx(0, "button", "下一个",
BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 800, 380, 100, 25,
hWnd, (HMENU)ID_BTNNEXTCHIMNEY, g_hInst, NULL);
g_hwndCheckBoxBeep = CreateWindowEx(0, "button", NULL,
BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP,
800, 480, 20, 20,
hWnd, (HMENU)ID_CHECKBOXSOUND , g_hInst, NULL);
char lpszMessage[100];
for (int i = 0; i <= 3; i++)
for (int j =0; j <= 3; j++){
sprintf(lpszMessage, "%d", (i * 4 +j));
if((i == 0) && (j == 0))
g_BtnCamNum[i * 4 + j] = CreateWindowEx(0, "button", lpszMessage,
BS_PUSHLIKE | BS_AUTORADIOBUTTON | WS_GROUP | WS_CHILD | WS_VISIBLE, 810 + j * 20, 540 + i * 20, 20, 20,
hWnd, (HMENU)(ID_BTNCAMNUM_0 + i * 4 + j), g_hInst, NULL);
else
g_BtnCamNum[i * 4 + j] = CreateWindowEx(0, "button", lpszMessage,
BS_PUSHLIKE | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 810 + j * 20, 540 + i * 20, 20, 20,
hWnd, (HMENU)(ID_BTNCAMNUM_0 + i * 4 + j), g_hInst, NULL);
}
g_mySysState.bIsAmplified_JIMU = 1;
return 1;
}
// Thread function for display welcome message.
DWORD WINAPI ThreadStartupFunc(LPVOID lpvThreadParam)
{
MSG msg;
HACCEL hAccelTable;
HWND hwndStartup;
hwndStartup = CreateWindowEx(0,"StartupWindow", NULL,
WS_VISIBLE | WS_POPUP, 200, 150, 407, 284, NULL, NULL, g_hInst, NULL);
hAccelTable = LoadAccelerators(g_hInst, (LPCTSTR)IDC_AIRGUARD_C);
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}
// Callback function for the "Start up Window" which is create to display welcome message.
LRESULT CALLBACK StartupWndProc(HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDc;
static CMyBitmap BmpStartup;
switch (wMessage)
{
case WM_CREATE:
hDc = GetDC(hWnd);
if (!BmpStartup.Init(g_hInst, hDc, IDB_BITMAP22))
MessageBox(NULL, "Load Resource error", "message", MB_OK);
ReleaseDC(hWnd, hDc);
SetTimer(hWnd, 1, 3000, NULL);
InvalidateRgn(hWnd, NULL, 1);
UpdateWindow(hWnd);
break;
case WM_TIMER:
PostQuitMessage(0);
break;
case WM_PAINT:
hDc = BeginPaint( hWnd, &ps);
BmpStartup.Show(hDc, 0, 0);
EndPaint( hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, wMessage, wParam, lParam);
}
return 0;
}
// Callback function for the "Start up Window" which is create to display welcome message.
LRESULT CALLBACK LogoWndProc(HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDc;
static CMyBitmap myLogo;
int nOrgBkMode;
static LOGFONT lf;
static HFONT hOrgFont, hFont;
switch (wMessage)
{
case WM_CREATE:
hDc = GetDC(hWnd);
if (!myLogo.Init(g_hInst, hDc, IDB_BITMAP23))
MessageBox(NULL, "Load Resource error", "message", MB_OK);
ReleaseDC(hWnd, hDc);
break;
case WM_PAINT:
hDc = BeginPaint( hWnd, &ps);
myLogo.Show(hDc, 0, 0);
//-------------------------------------------------------
// Create Logical Font...
//
ZeroMemory((PVOID)&lf, sizeof(LOGFONT));
lf.lfHeight = 15;
lf.lfEscapement = 0;
lf.lfWeight = FW_EXTRALIGHT;
lf.lfCharSet = OEM_CHARSET;
lf.lfPitchAndFamily = FF_MODERN;
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
hFont = CreateFontIndirect(&lf);
hOrgFont = (HFONT)SelectObject(hDc, hFont);
nOrgBkMode = SetBkMode(hDc, TRANSPARENT);
TextOut(hDc, 20, 110, "中国环保", 8);
SetBkMode(hDc, nOrgBkMode);
SelectObject(hDc, hOrgFont);
DeleteObject(hFont);
EndPaint( hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, wMessage, wParam, lParam);
}
return 0;
}
HWND WINAPI CreateTrackbar(
HWND hwndDlg, // handle of dialog box (parent window)
UINT iMin, // minimum value in trackbar range
UINT iMax, // maximum value in trackbar range
UINT iSelMin, // minimum value in trackbar selection
UINT iSelMax, // maximum value in trackbar selection
UINT xPos,
UINT yPos,
UINT iWidth,
UINT iHeight,
int iCtlID)
{
//InitCommonControls(); // loads common control's DLL
HWND hwndTrack = CreateWindowEx(
0, // no extended styles
TRACKBAR_CLASS, // class name
"Trackbar Control", // title (caption)
WS_CHILD | WS_VISIBLE |
TBS_AUTOTICKS | TBS_ENABLESELRANGE, // style
xPos, yPos, // position
iWidth, iHeight, // size
hwndDlg, // parent window
(HMENU)iCtlID, // control identifier
g_hInst, // instance
NULL // no WM_CREATE parameter
);
SendMessage(hwndTrack, TBM_SETRANGE,
(WPARAM) TRUE, // redraw flag
(LPARAM) MAKELONG(iMin, iMax)); // min. & max. positions
SendMessage(hwndTrack, TBM_SETPAGESIZE,
0, (LPARAM) 4); // new page size
SendMessage(hwndTrack, TBM_SETSEL,
(WPARAM) FALSE, // redraw flag
(LPARAM) MAKELONG(iSelMin, iSelMax));
SendMessage(hwndTrack, TBM_SETPOS,
(WPARAM) TRUE, // redraw flag
(LPARAM) iSelMax);
//SetFocus(hwndTrack);
return hwndTrack;
}
void MainWindow_OnPaint(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
RECT rect;
hdc = BeginPaint(hWnd, &ps);
HBRUSH hOrgBrush, hBrush;
int iHeight;
static LOGFONT lf;
static HFONT hOrgFont, hFont;
//-------------------------------------------------------
// Create Logical Font...
//
ZeroMemory((PVOID)&lf, sizeof(LOGFONT));
lf.lfHeight = 15;
lf.lfEscapement = 0;
lf.lfWeight = FW_EXTRALIGHT;
lf.lfCharSet = OEM_CHARSET;
lf.lfPitchAndFamily = FF_MODERN;
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
hFont = CreateFontIndirect(&lf);
//--------------------------------------------------------
// Draw Standard Blackness Bar
int piColors[6], piEachRectButtom[6];
rect.left = 45;
rect.top = 35;
rect.right = 95;
rect.bottom = 55;
piColors[0] = 0;
piColors[1] = 51;
piColors[2] = 102;
piColors[3] = 153;
piColors[4] = 204;
piColors[5] = 255;
iHeight = rect.bottom - rect.top;
for(int i = 0; i < 6; i++){
hBrush = CreateSolidBrush(RGB((piColors[i] * g_myCamera.m_iIllumination / 100),
(piColors[i] * g_myCamera.m_iIllumination / 100), (piColors[i] * g_myCamera.m_iIllumination / 100)));
hOrgBrush = (HBRUSH)SelectObject(hdc, hBrush);
Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
piEachRectButtom[5 - i] = rect.top + 5;
rect.top += iHeight;
rect.bottom += iHeight;
SelectObject(hdc, hOrgBrush);
DeleteObject(hBrush);
}
//---------------------------------------------------------------
// Draw text.
// Query date and time.
SYSTEMTIME st;
GetSystemTime(&st);
char lpszDate[20], lpszTime[20];
sprintf(lpszDate, "%d.%d.%d", st.wYear, st.wMonth, st.wDay);
sprintf(lpszTime, "%d:%d:%d", st.wHour, st.wMinute, st.wSecond);
//---------------------------------------------------------------
// Draw a white shadow.
HPEN hPen = CreatePen(PS_SOLID, 1, RGB(255, 255, 255));
int nOrgBkMode = SetBkMode(hdc, TRANSPARENT);
hOrgFont = (HFONT)SelectObject(hdc, hFont);
HPEN hOrgPen = (HPEN)SelectObject(hdc, hPen);
DWORD dwOrgTextColor = SetTextColor(hdc, RGB(255, 255, 255));
POINT pt;
MoveToEx(hdc, 295, BASELINE + 20, &pt);
LineTo(hdc, 305, BASELINE + 30);
LineTo(hdc, 460, BASELINE + 30);
LineTo(hdc, 470, BASELINE + 20);
MoveToEx(hdc, 6, 1, &pt);
LineTo(hdc, 906, 1);
MoveToEx(hdc, 6, 180, &pt);
LineTo(hdc, 136, 180);
MoveToEx(hdc, 796, 180, &pt);
LineTo(hdc, 906, 180);
MoveToEx(hdc, 6, BASELINE - 60, &pt);
LineTo(hdc, 906, BASELINE - 60);
TextOut(hdc, 30, BASELINE + 20, "操作方式", 8);
//TextOut(hdc, 235, BASELINE + 20, "选择", 6);
//TextOut(hdc, 480, BASELINE + 20, "调整", 6);
TextOut(hdc, 350, BASELINE + 40, "镜头控制", 8);
char lpszBuffer[10];
for (i = 0; i <= 5; i++){
sprintf(lpszBuffer, "%d", i);
TextOut(hdc, 20, piEachRectButtom[i], lpszBuffer, strlen(lpszBuffer));
}
TextOut(hdc, 20, 380, "烟尘黑度", 8);
TextOut(hdc, 20, 220, "烟囱概况", 8);
TextOut(hdc, 20, 460, "系统状态", 8);
TextOut(hdc, 800, 220, "光照指示", 8);
TextOut(hdc, 800, 260, " 0 5 10", 15);
TextOut(hdc, 825, 484, "声音提示", 8);
//------------------------------------------------------
// Draw black text.
SelectObject(hdc, hOrgPen);
SetTextColor(hdc, dwOrgTextColor);
MoveToEx(hdc, 294, BASELINE + 19, &pt);
LineTo(hdc, 304, BASELINE + 29);
LineTo(hdc, 459, BASELINE + 29);
LineTo(hdc, 469, BASELINE + 19);
MoveToEx(hdc, 5, 0, &pt);
LineTo(hdc, 905, 0);
MoveToEx(hdc, 5, 179, &pt);
LineTo(hdc, 135, 179);
MoveToEx(hdc, 795, 179, &pt);
LineTo(hdc, 905, 179);
MoveToEx(hdc, 5, BASELINE - 61, &pt);
LineTo(hdc, 905, BASELINE - 61);
TextOut(hdc, 29, BASELINE + 19, "操作方式", 8);
//TextOut(hdc, 234, BASELINE + 19, "选择", 6);
//TextOut(hdc, 479, BASELINE + 19, "调整", 6);
TextOut(hdc, 349, BASELINE + 39, "镜头控制", 8);
for (i = 0; i <= 5; i++){
sprintf(lpszBuffer, "%d", i);
TextOut(hdc, 19, piEachRectButtom[i]-1, lpszBuffer, strlen(lpszBuffer));
}
TextOut(hdc, 19, 379, "烟尘黑度", 8);
TextOut(hdc, 19, 219, "烟囱概况", 8);
TextOut(hdc, 19, 459, "系统状态", 8);
TextOut(hdc, 799, 219, "光照指示", 8);
TextOut(hdc, 824, 483, "声音提示", 8);
TextOut(hdc, 799, 259, " 0 5 10", 15);
//--------------------------------------------------------
// Clean
SelectObject(hdc, hOrgFont);
SetBkMode(hdc, nOrgBkMode);
DeleteObject(hPen);
DeleteObject(hFont);
EndPaint(hWnd, &ps);
return;
}
bool MainWindow_OnACK(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
int wmId = LOWORD(wParam);
int wmEvent = HIWORD(wParam);
switch (wmId)
{
case ID_UPBUTTON:
switch(wmEvent){
case ACK_BN_DOWN:
g_myCamera.TiltUp();
break;
case ACK_BN_UP:
g_myCamera.StopTiltUp();
break;
}
break;
case ID_LEFTBUTTON:
switch(wmEvent){
case ACK_BN_DOWN:
g_myCamera.PanLeft();
break;
case ACK_BN_UP:
g_myCamera.StopPanLeft();
break;
}
break;
case ID_DOWNBUTTON:
switch(wmEvent){
case ACK_BN_DOWN:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -