📄 zmproc.c
字号:
magsize = info->magsize;
GetDisplaySize( hwnd, info );
/* correct the magnifier position so we magnify about the centre
* instead of the corner */
info->magpos.x += ( magsize.x - info->magsize.x ) / 2;
info->magpos.y += ( magsize.y - info->magsize.y ) / 2;
GetScreen( info->screen, &info->magpos, &info->magsize, TRUE );
dc = GetDC( hwnd );
DrawScreen( info->screen, dc, &Origin, &info->wndsize,
&Origin, &info->magsize );
ReleaseDC( hwnd, dc );
}
/*
* DoMouseMove - move or resize the magnifier based on a WM_MOUSEMOVE
* message
*/
static void DoMouseMove( MainWndInfo *info, DWORD lparam ) {
int xpos;
int ypos;
int xsize;
int ysize;
BOOL resetcursor;
POINT oldmagsize;
HDC dc;
xpos = (int_16)LOWORD( lparam ) + info->wndpos.x;
ypos = (int_16)HIWORD( lparam ) + info->wndpos.y;
dc = GetDC( NULL );
if( !info->new_look ) {
EraseMagnifier( dc, info );
} else {
info->new_look = FALSE;
}
/* resize the magnifier if needed */
if( info->sizing ) {
resetcursor = FALSE;
oldmagsize = info->magsize;
info->magsize.x = xpos - info->magpos.x;
info->magsize.y = ypos - info->magpos.y;
if( info->magsize.y < 1 ) {
info->magsize.y = 1;
resetcursor = TRUE;
ypos = info->magpos.y + info->magsize.y;
}
GetWndSize( info, &xsize, &ysize );
if( info->magsize.x > oldmagsize.x && xsize > MAX_XSIZE ) {
info->magsize.x = oldmagsize.x;
resetcursor = TRUE;
}
if( info->magsize.y > oldmagsize.y && ysize > MAX_YSIZE ) {
info->magsize.y = oldmagsize.y;
resetcursor = TRUE;
}
if( xsize < MIN_WND_WIDTH ) {
info->magsize.x = ( ( MIN_WND_WIDTH -
GetSystemMetrics( SM_CXVSCROLL )
- 2 * GetSystemMetrics( SM_CXFRAME ) ) * ZOOM_FACTOR )
/ info->magnif;
resetcursor = TRUE;
}
if( resetcursor ) {
xpos = info->magpos.x + info->magsize.x;
ypos = info->magpos.y + info->magsize.y;
SetCursorPos( xpos, ypos );
}
}
/* move the magnifier */
info->magpos.x = xpos - info->magsize.x;
info->magpos.y = ypos - info->magsize.y;
CheckMagnifierPos( info );
DrawMagnifier( dc, info );
if( !info->sizing ) {
DrawScreen( info->screen, NULL, &Origin, &info->wndsize,
&Origin, &info->magsize );
}
ReleaseDC( NULL, dc );
}
static void displayAbout( HWND hwnd ) {
about_info ai;
ai.owner = hwnd;
ai.inst = Instance;
#ifdef __NT__
ai.name = AllocRCString( STR_ABOUT_NAME_NT );
#else
ai.name = AllocRCString( STR_ABOUT_NAME );
#endif
ai.version = banner1p2( _ZOOM_VERSION_ );
ai.first_cr_year = AllocRCString( STR_ABOUT_YEAR );
ai.title = AllocRCString( STR_ABOUT_TITLE );
DoAbout( &ai );
FreeRCString( (char *)ai.name );
FreeRCString( (char *)ai.version );
FreeRCString( (char *)ai.first_cr_year );
FreeRCString( (char *)ai.title );
}
BOOL __export FAR PASCAL ZOOMMainWndProc( HWND hwnd, UINT msg, WPARAM wparam,
LPARAM lparam )
{
MainWndInfo *info;
HDC dc;
int xsize;
int ysize;
PAINTSTRUCT paintinfo;
MINMAXINFO *mminfo;
HMENU mh;
WORD item;
WORD flags;
info = (MainWndInfo *)GetWindowLong( hwnd, 0 );
switch( msg ) {
case WM_CREATE:
info = (MainWndInfo *)( ( (CREATESTRUCT *)lparam )->lpCreateParams );
info->screen = InitScreenBitmap( hwnd );
info->magnif = 5 * ZOOM_FACTOR;
info->magnifpen = CreatePen( PS_INSIDEFRAME, 1, RGB( 0, 0, 0) );
info->zoomincrement = 0;
mh = GetMenu( hwnd );
if( ConfigInfo.topmost ) {
SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE );
}
if( ConfigInfo.autorefresh ) {
DoAutoRefresh( hwnd, TRUE );
}
CreateScrollBars( hwnd, info );
PositionWidgets( hwnd, info );
SetWindowLong( hwnd, 0, (DWORD)info );
break;
case WM_PAINT:
BeginPaint( hwnd, &paintinfo );
DrawScreen( info->screen, paintinfo.hdc, &Origin, &info->wndsize,
&Origin, &info->magsize );
EndPaint( hwnd, &paintinfo );
break;
case WM_SIZE:
EndScrolling( info );
PositionWidgets( hwnd, info );
GetDisplaySize( hwnd, info );
CheckMagnifierPos( info );
GetScreen( info->screen, &info->magpos, &info->magsize, FALSE );
DrawScreen( info->screen, NULL, &Origin, &info->wndsize,
&Origin, &info->magsize );
break;
case WM_HSCROLL:
case WM_VSCROLL:
DoScroll( GET_WM_VSCROLL_HWND( wparam, lparam ),
GET_WM_VSCROLL_CODE( wparam, lparam ), info );
break;
case WM_MENUSELECT:
mh = GET_WM_MENUSELECT_HMENU( wparam, lparam );
flags = GET_WM_MENUSELECT_FLAGS( wparam, lparam );
item = GET_WM_MENUSELECT_ITEM( wparam, lparam );
if( flags == (WORD)-1 && mh == 0
&& info->zoomincrement != 0 ) {
info->zoomincrement = 0;
KillTimer( hwnd, ZM_TIMER );
break;
} else if( item == ZMMENU_ZOOMIN ) {
EndScrolling( info );
info->zoomincrement = 1;
info->zoomincrement *= info->magnif / 4 + 1;
} else if( item == ZMMENU_ZOOMOUT ) {
EndScrolling( info );
info->zoomincrement = -1;
info->zoomincrement *= info->magnif / 4 + 1;
} else {
break;
}
DoMagnify( hwnd, info );
SetTimer( hwnd, ZM_TIMER, ZOOM_FREQUENCY, NULL );
break;
case WM_TIMER:
switch( wparam ) {
case ZM_TIMER:
DoMagnify( hwnd, info );
break;
case ZM_SCROLL_TIMER:
EndScrolling( info );
break;
case ZM_REFRESH_TIMER:
#if(0)
if( info->scrolling || ( info->looking && !info->new_look ) ) {
dc = GetDC( NULL );
DrawMagnifier( dc, info );
ReleaseDC( NULL, dc );
}
#endif
if( !info->sizing ) {
GetScreen( info->screen, &info->magpos, &info->magsize, TRUE );
DrawScreen( info->screen, NULL, &Origin, &info->wndsize,
&Origin, &info->magsize );
}
#if(0)
if( info->scrolling || ( info->looking && !info->new_look ) ) {
dc = GetDC( NULL );
DrawMagnifier( dc, info );
ReleaseDC( NULL, dc );
}
#endif
break;
}
break;
case WM_GETMINMAXINFO:
mminfo = (MINMAXINFO *)lparam;
mminfo->ptMinTrackSize.x = MIN_WND_WIDTH;
break;
case WM_MOVE:
{
RECT wndarea;
info->wndpos.x = (int_16)LOWORD( lparam );
info->wndpos.y = (int_16)HIWORD( lparam );
GetWindowRect( hwnd, &wndarea );
info->caption_hite = info->wndpos.y - wndarea.top;
}
break;
case WM_RBUTTONDOWN:
info->sizing = TRUE;
break;
case WM_RBUTTONUP:
info->sizing = FALSE;
dc = GetDC( NULL );
EraseMagnifier( dc, info );
ReleaseDC( NULL, dc );
GetWndSize( info, &xsize, &ysize );
SetWindowPos( hwnd, NULL, 0, 0, xsize, ysize,
SWP_NOZORDER | SWP_NOMOVE );
dc = GetDC( NULL );
DrawMagnifier( dc, info );
ReleaseDC( NULL, dc );
break;
case WM_LBUTTONDOWN:
info->looking = !info->looking;
if( info->looking ) {
BeginZooming( hwnd, info );
} else {
EndZooming( info );
}
break;
case WM_LBUTTONUP:
if( info->looking && !ConfigInfo.stickymagnifier ) {
EndZooming( info );
}
break;
case WM_MOUSEMOVE:
if( info->looking ) {
DoMouseMove( info, lparam );
}
break;
case WM_COMMAND:
switch( LOWORD( wparam ) ) {
case ZMMENU_BEGIN:
BeginZooming( hwnd, info );
break;
case ZMMENU_CONFIG:
DoConfig( hwnd );
break;
case ZMMENU_PASTE:
CopyToClipBoard( info );
break;
case ZMMENU_ABOUT:
displayAbout( hwnd );
break;
case ZMMENU_SETLIMITS:
break;
case ZMMENU_EXIT:
DestroyWindow( hwnd );
break;
}
break;
case WM_QUERYENDSESSION:
SaveConfig();
return( TRUE );
break;
case WM_DESTROY:
EndScrolling( info );
FiniScreenBitmap( info->screen );
SaveConfig();
DeleteObject( info->magnifpen );
FreeRCString( AppName );
PostQuitMessage( 0 );
break;
default:
return( DefWindowProc( hwnd, msg, wparam, lparam ) );
}
return( FALSE );
}
void DoAutoRefresh( HWND mainhwnd, BOOL on ) {
UINT ret;
KillTimer( mainhwnd, ZM_REFRESH_TIMER );
ConfigInfo.autorefresh = FALSE;
if( on ) {
ret = SetTimer( mainhwnd, ZM_REFRESH_TIMER,
ConfigInfo.refresh_interval * 100, NULL );
if( !ret ) {
RCMessageBox( mainhwnd, STR_UNABLE_TO_AUTOREFRESH,
AppName, MB_OK | MB_ICONEXCLAMATION );
ConfigInfo.autorefresh = FALSE;
} else {
ConfigInfo.autorefresh = TRUE;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -