📄 vncoptions.cpp
字号:
{//ret false
m_ignoreShapeUpdates = false;
m_requestShapeUpdates = true;
m_localCursor = NOCURSOR;
//Standard
//m_ignoreShapeUpdates = false;//true;
//m_requestShapeUpdates = true;
//m_localCursor = NOCURSOR;//NORMALCURSOR;
}
return result;
}
void VNCOptions::ApplyOptions(HWND hwnd)
{
m_Quality = SendMessage(GetDlgItem(hwnd, IDC_CONN_QUALITY), CB_GETCURSEL, 0, 0);
m_ViewOnly = IsDlgButtonChecked(hwnd, IDC_CONN_VIEWONLY);
m_DisableInput = IsDlgButtonChecked(hwnd, IDC_CONN_DINPUT);
m_BlackScreen = IsDlgButtonChecked(hwnd, IDC_CONN_BLACKSCREEN);
m_nServerScale = GetDlgItemInt(hwnd, IDC_CONN_SERVERSCALE, NULL, FALSE);
m_scaling = IsDlgButtonChecked(hwnd, IDC_CONN_SCALING);
m_fAutoScaling = IsDlgButtonChecked(hwnd, IDC_CONN_AUTOSCALING);
m_set_scale_num = GetDlgItemInt(hwnd, IDC_CONN_SCALEBY, NULL, FALSE);
ShowRemoteCursor(IsDlgButtonChecked(hwnd,IDC_SHOWREMOTECURSOR));
FixScaling();
ApplyQuality();
}
VOID CALLBACK VNCOptions::TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
VNCOptions *_this = (VNCOptions *) GetWindowLong(hwnd, GWL_USERDATA);
POINT p;
GetCursorPos(&p);
HWND control = WindowFromPoint(p);
HWND helptext = GetDlgItem(hwnd, IDC_CONN_HELPTEXT);
char *newtext = _this->helptexts[control];
char oldtext[512];
GetWindowText(helptext, oldtext, 512);
if(newtext && strncmp(newtext, oldtext, 512))
SetWindowText(helptext, newtext);
else if(!newtext && oldtext[0]!='\0')
SetWindowText(helptext, "");
}
BOOL CALLBACK VNCOptions::OptDlgProc( HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam ) {
// This is a static method, so we don't know which instantiation we're
// dealing with. But we can get a pseudo-this from the parameter to
// WM_INITDIALOG, which we therafter store with the window and retrieve
// as follows:
VNCOptions *_this = (VNCOptions *) GetWindowLong(hwnd, GWL_USERDATA);
switch (uMsg)
{
case WM_INITDIALOG:
{
SetWindowLong(hwnd, GWL_USERDATA, lParam);
_this = (VNCOptions *) lParam;
_this->InitDialog(hwnd);
UINT_PTR p = SetTimer(hwnd, 11, 200, (TIMERPROC) VNCOptions::TimerProc);
return FALSE;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDOK:
{
_this->ApplyOptions(hwnd);
EndDialog(hwnd, TRUE);
return TRUE;
}
case IDCANCEL:
{
EndDialog(hwnd, FALSE);
return TRUE;
}
case IDC_CONN_QUALITY:
{
int quality = SendMessage(GetDlgItem(hwnd, IDC_CONN_QUALITY), CB_GETCURSEL, 0, 0);
EnableWindow(GetDlgItem(hwnd, IDC_CONN_CUSTOM), quality == 3);
return TRUE;
}
case IDC_CONN_CUSTOM:
{
CustomSettings cs;
cs.SetCompression(_this->m_Compression);
cs.SetColorDepth(_this->m_Use8Bit);
cs.SetRemoveWallpaper(_this->m_RemoveWallpaper);
if(cs.DoDialog(hwnd))
{
_this->m_Compression = cs.GetCompression();
_this->ApplyQuality();
_this->m_Use8Bit = cs.GetColorDepth();
_this->m_RemoveWallpaper = cs.GetRemoveWallpaper();
}
return TRUE;
}
case IDC_CONN_DINPUT:
{
EnableWindow(GetDlgItem(hwnd, IDC_CONN_BLACKSCREEN),
IsDlgButtonChecked(hwnd, IDC_CONN_DINPUT));
return TRUE;
}
case IDC_CONN_SCALING:
{
UINT scaling = IsDlgButtonChecked(hwnd, IDC_CONN_SCALING) > 0;
EnableWindow(GetDlgItem(hwnd, IDC_CONN_AUTOSCALING), scaling);
EnableWindow(GetDlgItem(hwnd, IDC_CONN_SCALE_CONSTANT), scaling);
UINT autoscaling = IsDlgButtonChecked(hwnd, IDC_CONN_AUTOSCALING) > 0;
EnableWindow(GetDlgItem(hwnd, IDC_CONN_SCALEBY), scaling && !autoscaling);
EnableWindow(GetDlgItem(hwnd, IDC_CONN_SCALE_LABEL), scaling && !autoscaling);
return TRUE;
}
case IDC_CONN_AUTOSCALING:
case IDC_CONN_SCALE_CONSTANT:
{
UINT autoscaling = IsDlgButtonChecked(hwnd, IDC_CONN_AUTOSCALING) > 0;
EnableWindow(GetDlgItem(hwnd, IDC_CONN_SCALEBY), !autoscaling);
EnableWindow(GetDlgItem(hwnd, IDC_CONN_SCALE_LABEL), !autoscaling);
return TRUE;
}
}
break;
}
case WM_ERASEBKGND:
EraseBkgnd(hwnd, wParam);
return TRUE;
case WM_CTLCOLORBTN:
return CtlColorBtn(wParam);
case WM_CTLCOLORSTATIC:
return CtlColorStatic(hwnd, wParam, lParam);
case WM_DESTROY:
KillTimer(hwnd, 11);
EndDialog(hwnd, FALSE);
return TRUE;
}
return FALSE;
}
inline bool SwitchMatch(LPCTSTR arg, LPCTSTR swtch) {
return (arg[0] == '-' || arg[0] == '/') &&
(_tcsicmp(&arg[1], swtch) == 0);
}
void VNCOptions::SetFromCommandLine(LPTSTR szCmdLine)
{
// We assume no quoting here.
// Copy the command line - we don't know what might happen to the original
int cmdlinelen = _tcslen(szCmdLine);
if (cmdlinelen == 0) return;
TCHAR *cmd = new TCHAR[cmdlinelen + 1];
_tcscpy(cmd, szCmdLine);
// Count the number of spaces
// This may be more than the number of arguments, but that doesn't matter.
int nspaces = 0;
TCHAR *p = cmd;
TCHAR *pos = cmd;
while ( ( pos = _tcschr(p, ' ') ) != NULL )
{
nspaces ++;
p = pos + 1;
}
// Create the array to hold pointers to each bit of string
TCHAR **args = new LPTSTR[nspaces + 1];
// replace spaces with nulls and
// create an array of TCHAR*'s which points to start of each bit.
pos = cmd;
int i = 0;
args[i] = cmd;
bool inquote=false;
for (pos = cmd; *pos != 0; pos++)
{
// Arguments are normally separated by spaces, unless there's quoting
if ((*pos == ' ') && !inquote)
{
*pos = '\0';
p = pos + 1;
args[++i] = p;
}
if (*pos == '"')
{
if (!inquote) // Are we starting a quoted argument?
args[i] = ++pos; // It starts just after the quote
else
*pos = '\0'; // Finish a quoted argument?
inquote = !inquote;
}
}
i++;
bool hostGiven = false, portGiven = false;
// take in order.
for (int j = 0; j < i; j++)
{
if(SwitchMatch(args[j], _T("mode")))
{
if (++j == i)
{
continue;
}
string mode(args[j]);
transform(mode.begin(),mode.end(), mode.begin(), tolower);
if(mode=="presentation")
{
m_ActiveMode = rfbMC_PresentationServer;
}
else if(mode=="remotecontrol")
{
m_ActiveMode = rfbMC_RemotecontrolClient;
}
else if(mode=="teamwork")
{
m_ActiveMode = rfbMC_TeamworkClient;
}
}
else if ( SwitchMatch(args[j], _T("autoscaling")))
{
m_fAutoScaling = true;
}
else if ( SwitchMatch(args[j], _T("password") ))
{
if (++j == i)
{
continue;
}
memcpy(m_clearPassword, args[j], MAXPWLEN);
}
else if ( SwitchMatch(args[j], _T("quickoption") ))
{
m_SetFromCommandLine = true;
if (++j == i)
{
continue;
}
int oldquality;
_stscanf(args[j], _T("%d"), &oldquality);
switch(oldquality)
{
case 1:
m_Quality = 0;
break;
case 2:
m_Quality = 1;
break;
default:
m_Quality = 2;
}
ApplyQuality();
}
else
{
TCHAR phost[256];
if (ParseDisplay(args[j], phost, 255, &m_port))
{
_tcscpy(m_host, phost);
}
}
}
// tidy up
delete [] cmd;
delete [] args;
}
void VNCOptions::SetStatus(const char *name, int width, int height, int cols,
__int64 bytesread, __int64 bytessent,
int readlast, int readmin, int readavg, int readmax)
{
strncpy(m_status_name, name, 100);
m_status_name[100] = '\0';
m_status_width = width;
m_status_height = height;
m_status_colors = cols;
m_status_bytesread = bytesread;
m_status_bytessent = bytessent;
m_status_readlast = readlast;
m_status_readmin = readmin;
m_status_readavg = readavg;
m_status_readmax = readmax;
}
void VNCOptions::SetActiveMode(ConnectionMode cm)
{
switch(cm)
{
case Presentation:
m_ActiveMode = rfbMC_PresentationServer;
break;
case Filetransfer:
m_ActiveMode = rfbMC_FiletransferClient;
break;
default:
m_ActiveMode = rfbMC_RemotecontrolClient;
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -