📄 sessiondialog.cpp
字号:
{
RECT winRect;
GetClientRect(hwnd,&winRect);
//get ratio of original and actual window size
//to determine DPI scale for bitmaps
double xDPI = winRect.right / 572.0;//572 is original Session Dialog width
double yDPI = winRect.bottom / 354.0;//354 is original Session Dialog height
/*
We do use here pixel coordinates instead of dialog base units that are defined in our rc file
see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/DialogBoxes/DialogBoxReference/DialogBoxFunctions/MapDialogRect.asp
This article explains how to write DPI scaled programs:
Unfortunately the given code (GetDeviceCaps) does not work
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngdi/html/highdpiapp.asp
*/
SelectObject(dcSrc, bmpBackground);
StretchBlt(dcDest, 0, 0, winRect.right, winRect.bottom, dcSrc, 0, 0, 1, 354, SRCCOPY);
SelectObject(dcSrc, bmpLogo);
BitBlt(dcDest, (int)(28*xDPI), (int)(25*yDPI), 54, 79, dcSrc, 0, 0, SRCCOPY);
SelectObject(dcSrc, bmpBackgroundLeft);
StretchBlt(dcDest, (int)(109.0*xDPI), (int)(37.0*yDPI), (int)(11.0*xDPI), (int)(68.0*yDPI), dcSrc, 0, 0,11,68, SRCCOPY);
SelectObject(dcSrc, bmpBackgroundCenter);
StretchBlt(dcDest, (int)(119.0*xDPI), (int)(37.0*yDPI), (int)(425.0*xDPI), (int)(68.0*yDPI), dcSrc, 0, 0, 1, 68, SRCCOPY);
SelectObject(dcSrc, bmpBackgroundRight);
StretchBlt(dcDest, (int)(544*xDPI), (int)(38*yDPI), (int)(12*xDPI), (int)(68*yDPI), dcSrc, 0, 0,12,68, SRCCOPY);
}
DeleteDC(dcSrc);
return TRUE;
}
case WM_SYSCOMMAND:
switch(wParam)
{
case SC_MINIMIZE:
if(_this->m_server->GetServerMode() || isRemoteControl)
{
Hide();
return TRUE;
}
else
return FALSE;
}
break;
case WM_CLOSE:
{
if(_this->m_server->GetServerMode() || isRemoteControl)
Hide();
else
PostMessage(menu->GetHWND(),WM_CLOSE,0,0);
return TRUE;
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
// Staudenmeyer@2005: The following command is not used by the normal IDD_SESSION_DLG, only by the IDD_SIMPLE dialog
case ID_TV_LINK:
case ID_TV_LINK2:
char link[64];
GetDlgItemText(hwnd,ID_TV_LINK,link,63);
ShellExecute(0,"open",link,0,0,SW_SHOW);
break;
case IDC_BUTTON_ABORT_CONNECTION:
VNCviewerApp32::Instance()->AbortConnections();
_this->ConnectionFailed();
break;
case IDOK:
{
/*LRESULT res = DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_TEXTCHAT_DLG),
NULL, (DLGPROC) TextChat::TextChatDlgProc, (LONG) _this);
return TRUE;*/
if(_this->m_connectionRequested)
{
MessageBox(NULL,LoadString(IDS_CONNECTION_REQUESTED_TEXT).c_str(),LoadString(IDS_CONNECTION_REQUESTED_CAPTION).c_str(),MB_OK | MB_ICONERROR);
return TRUE;
}
_this->m_connectionRequested=true;
isOutgoingConnection = true; // No Enddialog etc.
TCHAR tmphost[256];
TCHAR display[256];
TCHAR fulldisplay[256];
GetDlgItemText(hwnd, IDC_HOSTNAME_EDIT, display, 256);
// intercept empty ID-field
if(strcmp(display,"")==0)
{
MessageBox(NULL,
sz_F10,
sz_L74, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
ConnectionFailed();
return TRUE;
}
_tcscpy(fulldisplay, display);
if (!ParseDisplay(display, tmphost, 255, &_this->m_port)) {
MessageBox(NULL,
sz_F8,
sz_L74, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
} else {
_tcscpy(_this->m_host_dialog, tmphost);
_this->m_pMRU->AddItem(fulldisplay);
_this->UpdateMRU(hwnd);
}
//CW@2004
//resolves a name to an ip, even it is already an ip
bool iscid = false;
// Check if valid GW Client ID (local or external)
if (_this->m_server->UseDynGate())
{
CroGateway *roGateway = CroGateway::Instance();
if (roGateway->isClientID(_this->m_host_dialog))
iscid = true;
}
if (!iscid)
{
// solve to ip if not clientid
struct sockaddr_in Addr;
memset (&Addr,0,sizeof(Addr));
Addr.sin_addr.s_addr = ResolveName(_this->m_host_dialog);
if (inet_ntoa(Addr.sin_addr)!=NULL && strcmp(inet_ntoa(Addr.sin_addr),"255.255.255.255")!=0)
_tcscpy(_this->m_host_dialog, inet_ntoa(Addr.sin_addr));
/*
cw@21.11.2006
prevents from connecting to localhost or 127.0.0.1
It does not prevent connecting to local computer ip address.
*/
if (strcmp(inet_ntoa(Addr.sin_addr),"127.0.0.1") == 0)
{
MessageBox(NULL,
sz_F10,
sz_L74, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
ConnectionFailed();
return TRUE;
}
}
DWORD threadID;
HANDLE threadHandle = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE )SessionDialog::Connect,(LPVOID)_this,0,&threadID);
ResumeThread(threadHandle);
return TRUE;
}
case IDC_MODE_TEAMWORK:
case IDC_MODE_PRESENTATION:
case IDC_MODE_FILETRANSFER:
if (IsDlgButtonChecked(hwnd,IDC_MODE_PRESENTATION) == BST_CHECKED)
vncProperties::singleton->SetConnectionMode(Presentation);
else if (IsDlgButtonChecked(hwnd,IDC_MODE_FILETRANSFER) == BST_CHECKED)
vncProperties::singleton->SetConnectionMode(Filetransfer);
else
vncProperties::singleton->SetConnectionMode(RemoteControl);
break;
case IDC_AUTOCLOSE: // Close message for incoming connections
//KillTimer(hwnd,333);
//EndDialog(hwnd, FALSE);
Hide();
return TRUE;
case IDCANCEL:
PostMessage(menu->GetHWND(),WM_CLOSE,0,0);
return TRUE;
case IDC_BUTTON_HELP:
ShellExecute(hwnd,"open",sz_IDS_HELP_LINK,0,0,SW_SHOW);
return TRUE;
// menu:
case ID_CONNECTION_INVITEPARTNER:
{
_this->InvitePartner();
break;
}
case ID_CONNECTION_CLOSE:
{
SendMessage(hwnd,WM_COMMAND,IDCANCEL,0);
break;
}
case ID_EXTRAS_SHOWDYNGATEMENU:
{
//HWND hDynGate=FindWindow(NULL,"DynGate");
//SendMessage(h,WM_COMMAND,4030,0); // CS: 4030 is ID_CLOSE in roVNCGateway, which is a custom defined command
break;
}
case ID_EXTRAS_PROPERTIES:
{
menu->m_properties.ShowAdmin(TRUE, TRUE);
break;
}
case ID_EXTRAS_TELL_A_FRIEND:
{
ShellExecute(NULL,"open",sz_IDS_TELL_A_FRIEND,NULL,NULL,NULL);
break;
}
case ID_EXTRAS_CONFIGUREHOSTMODE:
{
vncProperties::singleton->ShowAdmin(TRUE,TRUE,5);
break;
}
case ID_EXTRAS_ACTIVATELICENSE:
{
CroGateway *rgw = CroGateway::Instance();
rgw->ShowActivateLicense();
break;
}
case ID_EXTRAS_DYNGATEOPTIONS:
{
CroGateway *rgw = CroGateway::Instance();
rgw->ShowOptions();
break;
}
case ID_EXTRAS_DYNGATECONNECTIVITY:
{
CroGateway *rgw = CroGateway::Instance();
rgw->ShowConnectivity();
break;
}
case ID_HELP_TEAMVIEWERWEBSITE:
{
ShellExecute(NULL,"open",sz_IDS_HOMEPAGE_LINK,NULL,NULL,NULL);
break;
}
case ID_HELP_ABOUT:
{
vncAbout about;
about.Show(TRUE);
break;
}
case ID_HELP_USAGE:
{
ShellExecute(NULL,"open",sz_IDS_HELP_LINK,NULL,NULL,NULL);
break;
}
case ID_EXTRAS_REGISTER:
case IDC_BUTTON_UPGRADE:
{
ShellExecute(NULL,"open",sz_IDS_REGISTER_LINK,NULL,NULL,NULL);
break;
}
case ID_HELP_SUPPORT:
{
ShellExecute(NULL,"open",sz_IDS_SUPPORT_LINK,NULL,NULL,NULL);
break;
}
}
break;
case WM_DESTROY:
{
DeleteObject(bmpLogo);
DeleteObject(bmpBackground);
DeleteObject(bmpBackgroundLeft);
DeleteObject(bmpBackgroundCenter);
DeleteObject(bmpBackgroundRight);
DeleteObject(brushEditControl);
DeleteObject(brushQSEditControl);
ColorBrushType::iterator i;
for(i=colorBrushes.begin(); i!=colorBrushes.end(); i++)
DeleteObject(i->second);
KillTimer(hwnd,333);
EndDialog(hwnd, FALSE);
return TRUE;
}
case WM_TIMER:
if(wParam == TIMER_BALLOON)
{
KillTimer(hwnd, TIMER_BALLOON);
menu->ShowBalloonTip(sz_ID_BALLOONTIPTITLE, sz_ID_BALLOONTIP,10000);
return 0;
}
// download DynGate if required
if (_this && _this->m_server->UseDynGate())
{
CroGateway *roGateway = CroGateway::Instance();
bool bGatewayInstalled = roGateway->GatewayInstalled();
bool bInstallRequired = roGateway->InstallInquired();
if (!bGatewayInstalled && !bInstallRequired)
{
KillTimer(hwnd,333);
SetDlgItemText(hwnd, IDC_MYNAME, sz_ID_DynGate_download);
if (roGateway->DownloadDynGate(hwnd))
{
SetDlgItemText(hwnd, IDC_MYNAME, sz_ID_DynGate_install);
if (roGateway->InstallDynGate(hwnd))
roGateway->BeginWaitAtMaster(true);
else
{
// Something unknown might be wrong, manually download
roGateway->DownloadDynGateFallback(hwnd);
SetDlgItemText(hwnd, IDC_MYNAME, sz_ID_DynGate_notrunning);
}
}
else
{
// Something unknown might be wrong, manually download
roGateway->DownloadDynGateFallback(hwnd);
SetDlgItemText(hwnd, IDC_MYNAME, sz_ID_DynGate_notinstalled);
}
SetTimer(hwnd,333,1500,(TIMERPROC)SessDlgProc);
// do not ask again during this program run
roGateway->set_InstallInquired(true);
}
if (roGateway->GatewayRunning())
{
// New installed? - run Keepalive
if (!roGateway->BeginWaitAtMaster(true))
roGateway->ReadDyngateRegistry(); // Reload settings to detect manually installed DynGate-Upgrade
if(roGateway->QueryClientID())
roGateway->PollDynGate();
// Upgrade-Button ausgeblendet
//if(!roGateway->Licensed())
// ShowWindow(GetDlgItem(Hwnd(),IDC_BUTTON_UPGRADE),SW_SHOW);
//else
// ShowWindow(GetDlgItem(Hwnd(),IDC_BUTTON_UPGRADE),SW_HIDE);
string cid = roGateway->ClientID();
if(cid != "")
{
// Maybe there is a last Timer Message after the connection was already destroyed. So better check.
SetDlgItemText(hwnd, IDC_MYNAME, cid.data());
UpdatePassword();
}
else
SetDlgItemText(hwnd, IDC_MYNAME, sz_ID_DynGate_notconnected);
// Set download link
// For now this is a fixed value
char *dl = "http://www.teamviewer.com/download";
SetDlgItemText(hwnd, IDC_URL_DOWNLOAD, dl);
}
else
{
SetDlgItemText(hwnd, IDC_MYNAME, sz_ID_DynGate_notrunning);
// Registrierung regelm溥ig neu auslesen, damit erkannt wird, wenn DynGate
// nachtr鋑lich manuell installiert wurde
roGateway->ReadDyngateRegistry();
}
}
break;
case WM_HIDE_SESSION_DIALOG:
Hide();
break;
case WM_CTLCOLOREDIT:
case WM_CTLCOLORLISTBOX:
{
HDC hdc = (HDC)wParam;
SetBkColor(hdc, EDIT_BACKCOLOR);
SetTextColor(hdc, RGB(255,255,255));
return (BOOL)brushEditControl;
}
case WM_CTLCOLORBTN:
{
HDC hdc = (HDC)wParam;
SetBkMode(hdc, TRANSPARENT);
return (BOOL)GetStockObject(NULL_BRUSH);
}
case WM_CTLCOLORSTATIC:
{
HDC hdc = (HDC)wParam;
char buffer[255];
GetClassName((HWND)lParam, buffer, 255);
if(strcmp(buffer, "Edit") == 0) // non-readable edit box
{
if (isQuickSupport)
{
SetBkColor(hdc,RGB(231,227,231));
SetTextColor(hdc, RGB(0,0,0));
return (BOOL)brushQSEditControl;
}
else
{
SetTextColor(hdc, RGB(255,255,255));
SetBkColor(hdc, EDIT_BACKCOLOR);
return (BOOL)brushEditControl;
}
}
else // Label/GroupBox
{
if(isQuickSupport)
{
SetBkMode(hdc, TRANSPARENT);
return (BOOL)GetStockObject(NULL_BRUSH);
}
else // transparent Background doesn't work for GroupBoxes and
{ // Labels that are written more than once
RECT inner, outer;
COLORREF col = RGB(0, 0, 0);
HBRUSH brush;
RECT winRect;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -