📄 airguard_c.cpp
字号:
bmpArrowNotOn.Show(hDc, 0, 0);
else if( wButtonState == 1)
bmpArrowOn.Show(hDc, 0, 0);
else bmpArrowDown.Show(hDc, 0, 0);
EndPaint( hWnd, &ps);
return 0L;
case WM_LBUTTONDOWN:
wButtonState = 2;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
wMyParam = MAKEWPARAM(ID_RIGHTBUTTON, (WORD)ACK_BN_DOWN);
lMyParam = (LPARAM)hWnd;
SendMessage(GetParent(hWnd), WM_ACK, wMyParam, lMyParam);
break;
case WM_LBUTTONUP:
wButtonState = 1;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
wMyParam = MAKEWPARAM(ID_RIGHTBUTTON, (WORD)ACK_BN_UP);
lMyParam = (LPARAM)hWnd;
SendMessage(GetParent(hWnd), WM_ACK, wMyParam, lMyParam);
break;
case WM_MOUSEMOVE:
if ( wButtonState == 0){
wButtonState = 1;
SetTimer( hWnd, 1, 100, NULL);
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
}
break;
case WM_TIMER:
GetCursorPos( &pt);
ScreenToClient( hWnd, &pt);
if( !PtInRegion( hDrawRgn, pt.x, pt.y)){
wButtonState = 0;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow(hWnd);
KillTimer( hWnd, 1);
}
break;
case WM_DESTROY:
DeleteObject( hDrawRgn);
DeleteObject( hWndRgn);
break;
}
return DefWindowProc( hWnd, wMessage, wParam, lParam);
}
// Mesage handler for Pie Button Window.
LRESULT CALLBACK PieButtonWndProc(HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam)
{
static HRGN hWndRgn, hDrawRgn;
static WORD wButtonState = 0;// 0->not in region; 1->On top; 2->Push down
static CMyBitmap bmpArrowNotOn, bmpArrowOn, bmpArrowDown;
POINT pts[4];
PAINTSTRUCT ps;
HDC hDc;
POINT pt;
LPARAM lMyParam;
WPARAM wMyParam;
switch( wMessage)
{
case WM_CREATE:
pts[0].x = 0;
pts[0].y = 0;
pts[1].x = 29;
pts[1].y = 12;
pts[2].x = 0;
pts[2].y = 25;
pts[3].x = 12;
pts[3].y = 4;
hDrawRgn = CreateEllipticRgn( 0, 0, PIE_WIDTH, PIE_HEIGHT);
hWndRgn = CreateEllipticRgn( 0, 0, PIE_WIDTH, PIE_HEIGHT);
SetWindowRgn( hWnd, hWndRgn, true);
hDc = GetDC(hWnd);
bmpArrowNotOn.Init(g_hInst, hDc, IDB_BITMAP13);
bmpArrowOn.Init(g_hInst, hDc, IDB_BITMAP14);
bmpArrowDown.Init(g_hInst, hDc,IDB_BITMAP15);
ReleaseDC(hWnd, hDc);
break;
case WM_PAINT:
hDc = BeginPaint( hWnd, &ps);
if ( wButtonState == 0)
bmpArrowNotOn.Show(hDc, 0, 0);
else if( wButtonState == 1)
bmpArrowOn.Show(hDc, 0, 0);
else bmpArrowDown.Show(hDc, 0, 0);
EndPaint( hWnd, &ps);
return 0L;
case WM_LBUTTONDOWN:
wButtonState = 2;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
wMyParam = MAKEWPARAM(ID_PIEBUTTON, (WORD)ACK_BN_DOWN);
lMyParam = (LPARAM)hWnd;
SendMessage(GetParent(hWnd), WM_ACK, wMyParam, lMyParam);
break;
case WM_LBUTTONUP:
wButtonState = 1;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
wMyParam = MAKEWPARAM(ID_PIEBUTTON, (WORD)ACK_BN_UP);
lMyParam = (LPARAM)hWnd;
SendMessage(GetParent(hWnd), WM_ACK, wMyParam, lMyParam);
break;
case WM_MOUSEMOVE:
if ( wButtonState == 0){
wButtonState = 1;
SetTimer( hWnd, 1, 100, NULL);
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
}
break;
case WM_TIMER:
GetCursorPos( &pt);
ScreenToClient( hWnd, &pt);
if( !PtInRegion( hDrawRgn, pt.x, pt.y)){
wButtonState = 0;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow(hWnd);
KillTimer( hWnd, 1);
}
break;
case WM_DESTROY:
DeleteObject( hDrawRgn);
DeleteObject( hWndRgn);
break;
}
return DefWindowProc( hWnd, wMessage, wParam, lParam);
}
// Mesage handler for Plus Button Window.
LRESULT CALLBACK PlusButtonWndProc(HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam)
{
static HRGN hWndRgn, hDrawRgn;
static WORD wButtonState = 0;// 0->not in region; 1->On top; 2->Push down
static CMyBitmap bmpArrowNotOn, bmpArrowOn, bmpArrowDown;
PAINTSTRUCT ps;
HDC hDc;
POINT pt;
LPARAM lMyParam;
WPARAM wMyParam;
switch( wMessage)
{
case WM_CREATE:
hDrawRgn = CreateEllipticRgn( 0, 0, PLUS_WIDTH, PLUS_HEIGHT);
hWndRgn = CreateEllipticRgn( 0, 0, PLUS_WIDTH, PLUS_HEIGHT);
SetWindowRgn( hWnd, hWndRgn, true);
hDc = GetDC(hWnd);
bmpArrowNotOn.Init(g_hInst, hDc, IDB_BITMAP16);
bmpArrowOn.Init(g_hInst, hDc, IDB_BITMAP17);
bmpArrowDown.Init(g_hInst, hDc,IDB_BITMAP18);
ReleaseDC(hWnd, hDc);
break;
case WM_PAINT:
hDc = BeginPaint( hWnd, &ps);
if ( wButtonState == 0)
bmpArrowNotOn.Show(hDc, 0, 0);
else if( wButtonState == 1)
bmpArrowOn.Show(hDc, 0, 0);
else bmpArrowDown.Show(hDc, 0, 0);
EndPaint( hWnd, &ps);
return 0L;
case WM_LBUTTONDOWN:
wButtonState = 2;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
wMyParam = MAKEWPARAM(ID_PLUSBUTTON, (WORD)ACK_BN_DOWN);
lMyParam = (LPARAM)hWnd;
SendMessage(GetParent(hWnd), WM_ACK, wMyParam, lMyParam);
break;
case WM_LBUTTONUP:
wButtonState = 1;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
wMyParam = MAKEWPARAM(ID_PLUSBUTTON, (WORD)ACK_BN_UP);
lMyParam = (LPARAM)hWnd;
SendMessage(GetParent(hWnd), WM_ACK, wMyParam, lMyParam);
break;
case WM_MOUSEMOVE:
if ( wButtonState == 0){
wButtonState = 1;
SetTimer( hWnd, 1, 100, NULL);
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
}
break;
case WM_TIMER:
GetCursorPos( &pt);
ScreenToClient( hWnd, &pt);
if( !PtInRegion( hDrawRgn, pt.x, pt.y)){
wButtonState = 0;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow(hWnd);
KillTimer( hWnd, 1);
}
break;
case WM_DESTROY:
DeleteObject( hDrawRgn);
DeleteObject( hWndRgn);
break;
}
return DefWindowProc( hWnd, wMessage, wParam, lParam);
}
// Mesage handler for Minus Button Window.
LRESULT CALLBACK MinusButtonWndProc(HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam)
{
static HRGN hWndRgn, hDrawRgn;
static WORD wButtonState = 0;// 0->not in region; 1->On top; 2->Push down
static CMyBitmap bmpArrowNotOn, bmpArrowOn, bmpArrowDown;
PAINTSTRUCT ps;
HDC hDc;
POINT pt;
LPARAM lMyParam;
WPARAM wMyParam;
switch( wMessage)
{
case WM_CREATE:
hDrawRgn = CreateEllipticRgn( 0, 0, MINUS_WIDTH, MINUS_HEIGHT);
hWndRgn = CreateEllipticRgn( 0, 0, MINUS_WIDTH, MINUS_HEIGHT);
SetWindowRgn( hWnd, hWndRgn, true);
hDc = GetDC(hWnd);
bmpArrowNotOn.Init(g_hInst, hDc, IDB_BITMAP19);
bmpArrowOn.Init(g_hInst, hDc, IDB_BITMAP20);
bmpArrowDown.Init(g_hInst, hDc,IDB_BITMAP21);
ReleaseDC(hWnd, hDc);
break;
case WM_PAINT:
hDc = BeginPaint( hWnd, &ps);
if ( wButtonState == 0)
bmpArrowNotOn.Show(hDc, 0, 0);
else if( wButtonState == 1)
bmpArrowOn.Show(hDc, 0, 0);
else bmpArrowDown.Show(hDc, 0, 0);
EndPaint( hWnd, &ps);
return 0L;
case WM_LBUTTONDOWN:
wButtonState = 2;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
wMyParam = MAKEWPARAM(ID_MINUSBUTTON, (WORD)ACK_BN_DOWN);
lMyParam = (LPARAM)hWnd;
SendMessage(GetParent(hWnd), WM_ACK, wMyParam, lMyParam);
break;
case WM_LBUTTONUP:
wButtonState = 1;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
wMyParam = MAKEWPARAM(ID_MINUSBUTTON, (WORD)ACK_BN_UP);
lMyParam = (LPARAM)hWnd;
SendMessage(GetParent(hWnd), WM_ACK, wMyParam, lMyParam);
break;
case WM_MOUSEMOVE:
if ( wButtonState == 0){
wButtonState = 1;
SetTimer( hWnd, 1, 100, NULL);
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow( hWnd);
}
break;
case WM_TIMER:
GetCursorPos( &pt);
ScreenToClient( hWnd, &pt);
if( !PtInRegion( hDrawRgn, pt.x, pt.y)){
wButtonState = 0;
InvalidateRgn( hWnd, hDrawRgn, true);
UpdateWindow(hWnd);
KillTimer( hWnd, 1);
}
break;
case WM_DESTROY:
DeleteObject( hDrawRgn);
DeleteObject( hWndRgn);
break;
}
return DefWindowProc( hWnd, wMessage, wParam, lParam);
}
BOOL MainWindow_OnCreate(HWND hWnd)
{
static TOOLINFO tlinf;
CREATESTRUCT cs;
g_myCamera.m_iIllumination = 100;
//-------------------------------------------------------
g_hwndToolTip = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, g_hInst, NULL);
//-------------------------------------------------------
// Create arrow windows...
g_hwndUpButton = CreateWindowEx( 0, "UpBtnCls", NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
UP_X, UP_Y, UP_WIDTH, UP_HEIGHT, hWnd,
(HMENU) MAKEINTRESOURCE( ID_UPBUTTON), g_hInst, &cs);
tlinf.cbSize = sizeof( TOOLINFO);
tlinf.uFlags = TTF_IDISHWND | TTF_SUBCLASS;// | TTF_CENTERTIP ;
tlinf.hwnd = g_hwndMainWindow;
tlinf.uId = ( UINT)g_hwndUpButton;
tlinf.hinst = g_hInst;
tlinf.rect.left = tlinf.rect.right = tlinf.rect.top = tlinf.rect.bottom = 0;
tlinf.lpszText = "向上";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
//............
g_hwndLeftButton = CreateWindowEx( 0, "LeftButtonWndClass", NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
LEFT_X, LEFT_Y, LEFT_WIDTH, LEFT_HEIGHT, hWnd,
(HMENU) MAKEINTRESOURCE( ID_LEFTBUTTON), g_hInst, &cs);
tlinf.uId = ( UINT)g_hwndLeftButton;
tlinf.lpszText = "向左";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
//............
g_hwndDownButton = CreateWindowEx( 0, "DownButtonWndClass", NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
DOWN_X, DOWN_Y, DOWN_WIDTH, DOWN_HEIGHT, hWnd,
(HMENU) MAKEINTRESOURCE( ID_DOWNBUTTON), g_hInst, &cs);
tlinf.uId = ( UINT)g_hwndDownButton;
tlinf.lpszText = "向下";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
//............
g_hwndRightButton = CreateWindowEx( 0, "RightButtonWndClass", NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
RIGHT_X, RIGHT_Y, RIGHT_WIDTH, RIGHT_HEIGHT, hWnd,
(HMENU) MAKEINTRESOURCE( ID_RIGHTBUTTON), g_hInst, &cs);
tlinf.uId = ( UINT)g_hwndRightButton;
tlinf.lpszText = "向右";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
//.............
g_hwndPieButton = CreateWindowEx( 0, "PieButtonWndClass", NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
ARROWS_X, ARROWS_Y, PIE_WIDTH, PIE_HEIGHT, hWnd,
(HMENU) MAKEINTRESOURCE( ID_PIEBUTTON), g_hInst, &cs);
tlinf.uId = ( UINT)g_hwndPieButton;
tlinf.lpszText = "捕获";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
//-------------------------------------------------------
// Create Plus and Minus buttons...
//
g_hwndPlusButton = CreateWindowEx( 0, "PlusButtonWndClass", NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
PLUS_X, PLUS_Y, PLUS_WIDTH, PLUS_HEIGHT, hWnd,
(HMENU) MAKEINTRESOURCE( ID_PLUSBUTTON), g_hInst, &cs);
tlinf.uId = ( UINT)g_hwndPlusButton;
tlinf.lpszText = "增大";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
// ......
//
g_hwndMinusButton = CreateWindowEx( 0, "MinusButtonWndClass", NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
MINUS_X, MINUS_Y, MINUS_WIDTH, MINUS_HEIGHT, hWnd,
(HMENU) MAKEINTRESOURCE( ID_MINUSBUTTON), g_hInst, &cs);
tlinf.uId = ( UINT)g_hwndMinusButton;
tlinf.lpszText = "减小";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
//-------------------------------------------------------
// Create control radio buttons...
//
g_hwndRadioManual = CreateWindowEx(0, "button", "M",
BS_PUSHLIKE | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP,
30, BASELINE-5, 25, 20,
hWnd, (HMENU)ID_RADIOMANUAL , g_hInst, NULL);
tlinf.uId = ( UINT)g_hwndRadioManual;
tlinf.lpszText = "手动";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
g_hwndRadioAuto = CreateWindowEx(0, "button", "A",
BS_PUSHLIKE | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE,
55, BASELINE-5, 25, 20,
hWnd, (HMENU)ID_RADIOAUTO, g_hInst, NULL);
tlinf.uId = ( UINT)g_hwndRadioAuto;
tlinf.lpszText = "自动";
if( ! SendMessage( g_hwndToolTip, TTM_ADDTOOL, 0L, ( LPARAM)( LPTOOLINFO)&tlinf))
MessageBox( g_hwndMainWindow, "add tooltip error", "message", MB_OK);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -