📄 floatwindow.c
字号:
0,
(LPARAM)MAKELONG(10, 10));
hImageList = InitImageList(NumButtons,
IDB_HISTBACK);
ImageList_Destroy((HIMAGELIST)SendMessage(hButtons,
TB_SETIMAGELIST,
0,
(LPARAM)hImageList));
SendMessage(hButtons,
TB_SETBUTTONSIZE,
0,
MAKELONG(18, 16));
SendMessage(hButtons,
TB_ADDBUTTONS,
NumButtons,
(LPARAM)HistoryButtons);
return TRUE;
}
return FALSE;
}
static VOID
DoTimer(PFLT_WND FltInfo,
UINT idTimer)
{
switch (idTimer)
{
/* timer to check if cursor is in toolbar coords */
case ID_TIMER1:
{
POINT pt;
/* kill timer if toobar is not opaque */
if (FltInfo->bOpaque != TRUE)
{
KillTimer(FltInfo->hSelf,
ID_TIMER1);
break;
}
if (GetCursorPos(&pt))
{
RECT rect;
if (GetWindowRect(FltInfo->hSelf,
&rect))
{
if (!PtInRect(&rect,
pt))
{
KillTimer(FltInfo->hSelf,
ID_TIMER1);
KillTimer(FltInfo->hSelf,
ID_TIMER2);
/* timer to fade out toolbar */
SetTimer(FltInfo->hSelf,
ID_TIMER3,
50,
NULL);
}
}
}
}
break;
/* timer to fade in toolbar */
case ID_TIMER2:
{
SetLayeredWindowAttributes(FltInfo->hSelf,
0,
(255 * FltInfo->Transparancy) / 100,
LWA_ALPHA);
/* increment transparancy until it is opaque (100) */
FltInfo->Transparancy += 5;
if (FltInfo->Transparancy == 100)
{
SetWindowLongPtr(FltInfo->hSelf,
GWL_EXSTYLE,
GetWindowLongPtr(FltInfo->hSelf,
GWL_EXSTYLE) & ~WS_EX_LAYERED);
FltInfo->bOpaque = TRUE;
KillTimer(FltInfo->hSelf,
ID_TIMER2);
}
}
break;
case ID_TIMER3:
{
LONG Style;
Style = GetWindowLongPtr(FltInfo->hSelf,
GWL_EXSTYLE);
if (Style & ~WS_EX_LAYERED)
{
SetWindowLongPtr(FltInfo->hSelf,
GWL_EXSTYLE,
Style | WS_EX_LAYERED);
}
FltInfo->Transparancy -= 5;
if (FltInfo->Transparancy >= 60)
{
/* set the tranclucency to 60% */
SetLayeredWindowAttributes(FltInfo->hSelf,
0,
(255 * FltInfo->Transparancy) / 100,
LWA_ALPHA);
if (FltInfo->Transparancy == 60)
{
FltInfo->bOpaque = FALSE;
KillTimer(FltInfo->hSelf,
ID_TIMER3);
}
}
}
break;
}
}
LRESULT CALLBACK
FloatToolbarWndProc(HWND hwnd,
UINT Message,
WPARAM wParam,
LPARAM lParam)
{
PFLT_WND FltInfo;
/* Get the window context */
FltInfo = (PFLT_WND)GetWindowLongPtr(hwnd,
GWLP_USERDATA);
if (FltInfo == NULL && Message != WM_CREATE)
{
goto HandleDefaultMessage;
}
switch(Message)
{
case WM_CREATE:
{
FltInfo = (PFLT_WND)(((LPCREATESTRUCT)lParam)->lpCreateParams);
/*FIXME: read this from registry */
// FltInfo->bShow = TRUE;
SetWindowLongPtr(hwnd,
GWLP_USERDATA,
(LONG_PTR)FltInfo);
FltInfo->bOpaque = FALSE;
SetWindowLongPtr(hwnd,
GWL_EXSTYLE,
GetWindowLongPtr(hwnd,
GWL_EXSTYLE) | WS_EX_LAYERED);
/* set the tranclucency to 60% */
FltInfo->Transparancy = 60;
SetLayeredWindowAttributes(hwnd,
0,
(255 * FltInfo->Transparancy) / 100,
LWA_ALPHA);
}
break;
case WM_TIMER:
{
DoTimer(FltInfo,
wParam);
}
break;
case WM_NCMOUSEMOVE:
case WM_MOUSEMOVE:
{
if (FltInfo->bOpaque == FALSE)
{
RedrawWindow(hwnd,
NULL,
NULL,
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
FltInfo->bOpaque = TRUE;
//MessageBox(NULL, _T("in"), _T("Hit test"), MB_OK | MB_ICONEXCLAMATION);
/* timer to check if cursor is in toolbar coords */
SetTimer(hwnd,
ID_TIMER1,
200,
NULL);
/* timer to fade in the toolbars */
SetTimer(hwnd,
ID_TIMER2,
50,
NULL);
}
}
break;
case WM_CLOSE:
ShowHideWindow(FltInfo->hSelf);
break;
case WM_COMMAND:
{
if (LOWORD(wParam) == IDCANCEL)
ShowHideWindow(FltInfo->hSelf);
switch(LOWORD(wParam))
{
case ID_NEW:
MessageBox(hwnd, _T("Kapow!"), _T("Hit test"), MB_OK | MB_ICONEXCLAMATION);
break;
case ID_CLONESTAMP:
case ID_COLORPICKER:
case ID_ECLIPSE:
case ID_ECLIPSESEL:
case ID_ERASER:
case ID_FREEFORM:
case ID_LASOO:
case ID_LINE:
case ID_MAGICWAND:
case ID_MOVE:
case ID_MOVESEL:
case ID_PAINTBRUSH:
case ID_PAINTBUCKET:
case ID_PENCIL:
case ID_RECOLORING:
case ID_RECTANGLE:
case ID_ROUNDRECT:
case ID_TEXT:
case ID_ZOOM:
/*SendMessage(Info->hSelf,
LOWORD(wParam),
wParam,
lParam);*/
break;
}
}
break;
case WM_NCACTIVATE:
/* FIXME: needs fully implementing */
return DefWindowProc(hwnd,
Message,
TRUE,
lParam);
break;
case WM_DESTROY:
SetWindowLongPtr(hwnd,
GWLP_USERDATA,
0);
break;
default:
HandleDefaultMessage:
return DefWindowProc(hwnd,
Message,
wParam,
lParam);
}
return 0;
}
BOOL
InitFloatWndClass(VOID)
{
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = FloatToolbarWndProc;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL,
IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszClassName = szFloatWndClass;
wc.hIconSm = NULL;
return RegisterClassEx(&wc) != (ATOM)0;
}
VOID
UninitFloatWndImpl(VOID)
{
UnregisterClass(szFloatWndClass,
hInstance);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -