⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vncclientcontrol.cpp

📁 teamviewer source code vc++
💻 CPP
📖 第 1 页 / 共 2 页
字号:

				// write id
				SetTextColor(dcDest, RGB(117, 117, 117));
				SetBkMode(dcDest, TRANSPARENT);
				SelectObject(dcDest, GetStockObject(DEFAULT_GUI_FONT));
				RECT textrect;
				textrect.left = 13;
				textrect.right = r.right - 45;
				textrect.top = 5;
				textrect.bottom = 18;
				DrawText(dcDest, 
						 _this->m_pClient->GetRemoteIdentity().c_str(), 
						 _this->m_pClient->GetRemoteIdentity().length(),
						 &textrect, DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER);

				textrect.left = 0;
				textrect.right = r.right;
				textrect.bottom = r.bottom - 1;
				textrect.top = r.bottom - 14;
				if(textrect.right > 80)
					DrawText(dcDest, "TeamViewer.com", 14,
							 &textrect, DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_CENTER);
				else
					DrawText(dcDest, "TeamViewer", 10,
							 &textrect, DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_CENTER);

				if(oldPen)
					SelectObject(dcDest, oldPen);
				if(oldBrush)
					SelectObject(dcDest, oldBrush);
				if(greyPen)
					DeletePen(greyPen);
				DeleteDC(dcSrc);
			}
			return TRUE;
		}
		case WM_LBUTTONUP:
		{
			RECT r;
			GetClientRect(hwnd, &r);
			int x = LOWORD(lParam);
			int y = HIWORD(lParam);
			if(x>=r.right-21 && x <r.right-21+16 && y>=r.top+4 && y<r.top+4+14)
			{
				SendMessage(hwnd, WM_CLOSE, 0, 0);			// close button
			} else
			if(x>=r.right-40 && x <r.right-40+16 && y>=r.top+4 && y<r.top+4+14)
			{
				// Minimize
				_this->m_closed = true;
				ShowWindow(_this->m_hwndClientControl, SW_HIDE);
				ShowWindow(_this->m_hwndHandleClosed, SW_SHOWNA);
			}
			break;
		}
		case WM_SHOW_FILETRANSFER_LOG:
			_this->m_fileTransferLog->DoDialog();
			break;
		case WM_FILETRANSFER_MESSAGE:
		{
			HWND log=GetDlgItem(_this->m_fileTransferLog->m_hwnd,IDC_LOG);
			int length=GetWindowTextLength(log);
			SendMessage(log,EM_SETSEL,length,length);
			SendMessage(log,EM_REPLACESEL, false, (LPARAM)((string*)lParam)->c_str());
			break;
		}
		case WM_NOTIFY:
			switch (((LPNMHDR) lParam)->code) 
			{ 
				case TTN_GETDISPINFO: 
				{ 
					LPTOOLTIPTEXT lpttt;								// ToolTip struct
		
					lpttt = (LPTOOLTIPTEXT) lParam;						// button info
					lpttt->hinst = hAppInstance;						// used in our main dialog

					DWORD idButton = lpttt->hdr.idFrom;					// get the ID of the selected button
					switch (idButton)									// Check which button we hover on
					{
						case ID_BUTTON_CAD:
							lpttt->lpszText = sz_L2;
							break;
						case ID_BUTTON_FULLSCREEN:
							lpttt->lpszText = sz_L3;
							break;
						case ID_BUTTON_PROPERTIES:
							lpttt->lpszText = sz_L4;
							break;
						case ID_BUTTON_REFRESH:
							lpttt->lpszText = sz_L5;
							break;
						case ID_BUTTON_STRG_ESC:
							lpttt->lpszText = sz_L6;
							break;
						case ID_BUTTON_INFO:
							lpttt->lpszText = sz_L8;
							break;
						case ID_BUTTON_END:
							lpttt->lpszText = sz_L9;
							break;
						case ID_BUTTON_DBUTTON:
							lpttt->lpszText = sz_L10;
							break;
						case ID_BUTTON_DINPUT:
							lpttt->lpszText = sz_L11;
							break;
						case ID_BUTTON_FTRANS:
							lpttt->lpszText = sz_L12;
							break;
						case ID_BUTTON_SW:
							lpttt->lpszText = sz_L13;
							break;
						case ID_BUTTON_DESKTOP:
							lpttt->lpszText = sz_L14;
							break;
						case ID_BUTTON_TEXTCHAT:
							lpttt->lpszText = sz_L15;
							break;
						case ID_BUTTON_DIRCHANGE:
							lpttt->lpszText = sz_ID_REQUEST_CLIENTMODE;
							break;
						case ID_BUTTON_DISABLE_INPUT:
							lpttt->lpszText = sz_IDS_DISABLE_REMOTE;
							break;
						case ID_BUTTON_ENABLE_INPUT:
							lpttt->lpszText = sz_IDS_ENABLE_REMOTE;
							break;
						case ID_BUTTON_PAUSE:
							lpttt->lpszText = sz_IDS_PAUSE_CONNECTION;
							break;
						case ID_BUTTON_CONTINUE:
							lpttt->lpszText = sz_IDS_CONTINUE_CONNECTION;
							break;
					}
				}
			}
			break;
		case WM_SYSCOMMAND:
			switch(wParam)
			{
				case SC_CLOSE:
					vnclog.Print(LL_INTINFO, VNCLOG("ClientControl manually closed (close window)"));
					break;
			}
			break;
		case WM_COMMAND:		
			if(!_this->m_pClient || _this->m_pClient->m_deleting)
				break;
			switch (LOWORD(wParam))
			{
				case ID_BUTTON_DIRCHANGE:
				case ID_REQUEST_CLIENTMODE:	// Request Switch to Client Mode
					rfbModeChangeMsg mchange;

					mchange.type = rfbModeChangeRequest;
					if (_this->m_pClient->m_ActiveMode == rfbMC_PresentationServer)
						// special: if we had a presentation session now switch to Teamwork mode
						mchange.newmode = rfbMC_TeamworkServer;
					else
						mchange.newmode = (CARD8)_this->m_pClient->m_ActiveMode;  // the client should later have the mode we have now
					_this->m_pClient->m_socket->SendExact((char *)&mchange, sz_rfbModeChangeMsg);
					break;

				case ID_BUTTON_END:
				case ID_CLOSE :
					vnclog.Print(LL_INTINFO, VNCLOG("ClientControl manually closed (ID_CLOSE)"));
					SendMessage(hwnd,WM_CLOSE,0,0);
					break;
						
				//CW@2004 - Change window top most style
				case ID_TOPMOST_TOOLBAR_WINDOW :
				{
					HMENU hsysmenu = GetSystemMenu(_this->m_hwndClientControl, FALSE);
					UINT Flag = GetMenuState(hsysmenu, ID_TOPMOST_TOOLBAR_WINDOW, MF_BYCOMMAND);

					if (Flag & MF_CHECKED)
					{
						Flag = MF_UNCHECKED;
						SetWindowPos(_this->m_hwndClientControl,HWND_NOTOPMOST,0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
					}
					else
					{
						Flag = MF_CHECKED;
						SetWindowPos(_this->m_hwndClientControl,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE + SWP_NOSIZE);
					}

					CheckMenuItem(hsysmenu, ID_TOPMOST_TOOLBAR_WINDOW,MF_BYCOMMAND | Flag);
					break;
				}
				case ID_BUTTON_TEXTCHAT:
				case ID_TEXTCHAT:  // Open Chat
					if (_this->m_pClient->m_pTextChat->m_fTextChatRunning)
					{
						SetForegroundWindow(_this->m_pClient->m_pTextChat->m_hWnd);
						ShowWindow(_this->m_pClient->m_pTextChat->m_hWnd, SW_RESTORE);
					}
					else
						_this->m_pServer->TextChatClient(_this->m_pClient->m_client_name);
					break;
				
				case ID_BUTTON_DISABLE_INPUT:
					_this->m_pClient->EnablePointer(FALSE);
					_this->m_pClient->EnableKeyboard(FALSE);
					_this->m_pClient->m_thread->m_tvinfo->SendInfo(tvAllowPointer, "TRUE");
					_this->m_pClient->m_thread->m_tvinfo->FinishTeamviewerInfo();
					_this->CreateButtons();
					break;
				case ID_BUTTON_ENABLE_INPUT:
					_this->m_pClient->EnablePointer(TRUE);
					_this->m_pClient->EnableKeyboard(TRUE);
					_this->m_pClient->m_thread->m_tvinfo->SendInfo(tvAllowPointer, "FALSE");
					_this->m_pClient->m_thread->m_tvinfo->FinishTeamviewerInfo();
					_this->CreateButtons();
					break;
				case ID_BUTTON_DESKTOP:					
					_this->m_pClient->m_encodemgr.m_buffer->m_desktop->SetSW(NULL);					
					break;
				case ID_BUTTON_PAUSE:
				case ID_BUTTON_CONTINUE:
					_this->m_pClient->PauseConnection(!_this->m_pClient->IsConnectionPaused());
					break;
				case ID_BUTTON_REFRESH:
				case ID_REQUEST_REFRESH:    // Send Refresh
					_this->m_pClient->RequestRefresh();
					break;		
				case ID_BUTTON_PROPERTIES:
					_this->m_opts.SetStatus(_this->m_pClient->GetRemoteIdentity().c_str(),
						0, 0, 0, _this->m_pClient->m_socket->BytesRead(), _this->m_pClient->m_socket->BytesSent(), 0, 0, 0, 0);
					if(_this->m_opts.DoDialog(hwnd, IDD_PRESENTATION_OPTIONS))
					{
						_this->ApplyOptions();
					}
					break;
			}
			break;

		case WM_CLOSE:
			SetLastError(0);				// Clear error
			// Client-Verbindung beenden
			if(_this->m_pClient && !_this->m_pClient->m_deleting)
				_this->m_pClient->Kill();
			DestroyWindow(hwnd);
			return 0;
	
		case WM_DESTROY:
			KillTimer(hwnd, 1);
			PostQuitMessage(0);
			return 0;
	}

	if(uMsg == ShowPointerMessage)
	{
		if(_this->m_hwndPointer != NULL)
			DestroyWindow(_this->m_hwndPointer);
		_this->m_hwndPointer = CreateWindowEx(
								WS_EX_TOPMOST,
								_T("ClientControl_WinPointer"),
								"TeamViewer_ClientControl_WndPointer",
								WS_POPUP,
								wParam-16, lParam-16, 32, 32,
								NULL, 
								//m_client->m_ClientControl->m_hwndClientControl,			// Parent handle
								NULL,														// Menu handle
								hAppInstance,
								NULL);
		HRGN rgn;
		rgn = CreateEllipticRgn(6,6,26,26);
		SetWindowRgn(_this->m_hwndPointer, rgn, TRUE);
		ShowWindow(_this->m_hwndPointer, SW_SHOW);
		return 0;
	}
	return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

LRESULT CALLBACK vncClientControl::WndProcTB(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've stored a 'pseudo-this' in the window data.
	vncClientControl *_this = (vncClientControl *) GetWindowLong(hwnd, GWL_USERDATA);
	if (_this == NULL)
		return DefWindowProc(hwnd, uMsg, wParam, lParam);
	switch (uMsg)
	{
		case WM_LBUTTONDOWN:
			int xPos, yPos;
			xPos = GET_X_LPARAM(lParam); 
			yPos = GET_Y_LPARAM(lParam); 
			if(!_this->m_pClient->m_encodemgr.m_buffer->m_desktop->m_Single_hWnd 
			   && (xPos+1)/27 == _this->m_SW_Buttonpos)				// is button number 4 pressed?
			{
				_this->wf->SearchWindow();
				return TRUE;
			}
			else
				break;
		case WM_MOUSELEAVE:
			ReleaseCapture();
			break;
		case WM_MOUSEMOVE:
			if (_this->wf->g_bStartSearchWindow)
			{
				// Only when we have started the Window Searching operation will we 
				// track mouse movement.
				_this->wf->DoMouseMove(uMsg, wParam, lParam);
			}
			else
			{
				// activate control window so that tooltips are displayed
				SetForegroundWindow(_this->m_hwndClientControl);
				SetActiveWindow(_this->m_hwndClientControl);
			}
			break;
		case WM_LBUTTONUP :
			if (_this->wf->g_bStartSearchWindow)
			{
				// Only when we have started the window searching operation we will
				// be interested when the user lifts up the left mouse button.
				HWND sw;
				sw = _this->wf->DoMouseUp(uMsg, wParam, lParam);
				if(sw)
					_this->m_pClient->m_encodemgr.m_buffer->m_desktop->SetSW(sw);
				else
					MessageBox(hwnd, sz_IDS_SINGLEWINDOW_FAILED, "TeamViewer", MB_OK);
				return TRUE;
			}
			else
				break;
	}
	return CallWindowProc(_this->oldWndProcTB, hwnd, uMsg, wParam, lParam);

}

LRESULT CALLBACK vncClientControl::WndProcHandle(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've stored a 'pseudo-this' in the window data.
	vncClientControl *_this = (vncClientControl *) GetWindowLong(hwnd, GWL_USERDATA);
	if (_this == NULL)
		return DefWindowProc(hwnd, uMsg, wParam, lParam);

	switch (uMsg)
	{
		case WM_ERASEBKGND:
		{
			HDC dcDest,dcSrc;
			RECT r;
			GetClientRect(hwnd, &r);
			dcDest = (HDC)wParam;
			dcSrc = CreateCompatibleDC(dcDest);
			if(dcSrc)
			{
				// paint background
				SelectObject(dcSrc, _this->m_bmpToolbarBackground);
				StretchBlt(dcDest, r.left, r.bottom-5, r.right-r.left, 5, 
						   dcSrc, 0, 38, 1, -5, SRCCOPY);
				// paint handle
				SelectObject(dcSrc, _this->m_bmpToolbarHandleClosed);
				StretchBlt(dcDest, (r.right-r.left-43)/2, 0, 43, 14, 
						   dcSrc,  0, 14, 43, -14, SRCCOPY);
				DeleteDC(dcSrc);
			}
			return 1;
		}
		case WM_LBUTTONUP:
			_this->m_closed = !_this->m_closed;
			ShowWindow(_this->m_hwndClientControl, _this->m_closed ? SW_HIDE : SW_SHOWNA);
			ShowWindow(_this->m_hwndHandleClosed, _this->m_closed ? SW_SHOWNA : SW_HIDE);
			break;
	}
	return DefWindowProc(hwnd, uMsg, wParam, lParam);
}


LRESULT CALLBACK vncClientControl::WndProcPointer(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
		case WM_PAINT:
		{
			PAINTSTRUCT ps;
			HGDIOBJ old = NULL;
			HDC dc = BeginPaint(hwnd, &ps);
			HBRUSH br = CreateSolidBrush(RGB(255,0,0));
			if(br)
				old = SelectObject(dc, br);
			Rectangle(dc, 0, 0, 32, 32);
			if(br)
			{
				SelectObject(dc, old);
				DeleteObject(br);
			}
			EndPaint(hwnd, &ps);
			return 0;
		}
		case WM_LBUTTONDOWN:
			DestroyWindow(hwnd);
			return 1;
	}
	return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

void vncClientControl::PaintBorder(HWND window)
{
	HINSTANCE dll = m_pClient->m_encodemgr.m_buffer->m_desktop->GetHookDll();
	if(dll == NULL)
		return;

	SetSingleWindowFn SetSingleWindow = (SetSingleWindowFn)GetProcAddress(dll, "SetSingleWindow");
	if(SetSingleWindow)
		SetSingleWindow(window);
}

void vncClientControl::ApplyOptions()
{
	{
		omni_mutex_lock l(m_pClient->GetUpdateLock());
		m_pClient->SetScaling(m_opts.m_nServerScale);
	}

	stringstream enc;
	enc << m_opts.m_PreferredEncoding << "," << m_opts.m_Use8Bit;
	m_pClient->m_thread->m_tvinfo->SendCommand(tvChangeEncoding, enc.str());
	m_pClient->m_thread->m_tvinfo->FinishTeamviewerInfo();
	m_pServer->EnableRemoveWallpaper(m_opts.m_RemoveWallpaper);
	if(m_opts.m_RemoveWallpaper)
		HideDesktop();
	else
		RestoreDesktop();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -