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

📄 vncmenu.cpp

📁 teamviewer source code vc++
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			if (_this->m_server->RemoveWallpaperEnabled())
			{
				KillWallpaper();
			}
		} else {
			if (_this->m_server->RemoveWallpaperEnabled())
			{
				RestoreWallpaper();

				_this->m_server->EnableRemoveWallpaper(FALSE);
			}
		}
		return 0;

		// STANDARD MESSAGE HANDLING

	case WM_COMMAND:
		// User has clicked an item on the tray menu
		switch (LOWORD(wParam))
		{
		case ID_DEFAULT_PROPERTIES:
			// Show the default properties dialog, unless it is already displayed
			vnclog.Print(LL_INTINFO, VNCLOG("show default properties requested"));

			
			_this->m_properties.ShowAdmin(TRUE, FALSE);
			_this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0);
			break;
		
		case ID_PROPERTIES:
			// Show the properties dialog, unless it is already displayed
			vnclog.Print(LL_INTINFO, VNCLOG("show user properties requested"));
			//_this->m_propertiesPoll.Show(TRUE, TRUE);
			_this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0);
			break;


        case ID_ADMIN_PROPERTIES:
			// Show the properties dialog, unless it is already displayed
			vnclog.Print(LL_INTINFO, VNCLOG("show user properties requested"));
			

			SessionDialog::Restore();
			SessionDialog::Show();

			_this->m_properties.ShowAdmin(TRUE, TRUE);
			_this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0);
			
			
			
			break; 

		case ID_OUTGOING_CONN:
			/* Verbindung anfordern
			Dialog kann auch mehrmals aufgerufen werden.

			*/
			{
				SessionDialog::Restore();
				SessionDialog::Show();
				//_this->RequestOutgoingConnection();
			}
			break;

		case ID_KILLCLIENTS:
			// Disconnect all currently connected clients
			_this->m_server->KillAuthClients();
			_this->m_server->KillUnauthClients(); //TR@2005
			break;

#ifndef ROVNCTINY
		// sf@2002
		case ID_LISTCLIENTS:
			_this->m_ListDlg.Display();
			break;
#endif
		case ID_ABOUT:
			// Show the About box
			_this->m_about.Show(TRUE);
			break;

		case ID_CLOSE:
			{

				// User selected Close from the tray menu
				PostMessage(hwnd, WM_CLOSE, 0, 0);
				break;
			}
		case ID_Homepage:
			//char myHome[100];
			//myHome[0]=0;
			//strcat(myHome,"http://www.");
			//strcat(myHome,VNC_HOMESITE);
			ShellExecute(0,"open",sz_IDS_HOMEPAGE_LINK,0,0,SW_SHOW);
			//ShellExecute(0,"open",myHome,0,0,SW_SHOW);
			break;

		case ID_TRAY_WAITFORCONNECTION:
			//ShowSimpleDialog();
			break;
		}
		return 0;
	case WM_COPYDATA:
		{
			PCOPYDATASTRUCT data=(PCOPYDATASTRUCT)lParam;
			SessionDialog::Show();
			char* commandLine=new char[data->cbData+1];
			strncpy(commandLine, (char*)data->lpData, data->cbData);
			commandLine[data->cbData] = '\0';
			SessionDialog::RequestConnection(commandLine);
			delete []commandLine;
			return 0;
		}
	case WM_ENTER_REMOTE_CONTROL_MODE:
		{
			isRemoteControl=true;
			menu->Show(true);
			return 0;
		}
	case WM_TRAYNOTIFY:
		// User has clicked on the tray icon or the menu
		{
			// Get the submenu to use as a pop-up menu
			//HMENU submenu = GetSubMenu(_this->m_hmenu, 0);

			// What event are we responding to, RMB click?
			if (lParam==WM_RBUTTONUP)
			{
				_this->ShowContextMenu();
				//showContextMenu=true;
			}
			else if(lParam==WM_LBUTTONUP)
			{
				if(waitingForDoubleClick)
				{
					waitingForDoubleClick=false;
					SendMessage(_this->m_nid.hWnd,
							WM_COMMAND, 
							ID_OUTGOING_CONN, //GetMenuItemID(submenu, 0),
							0);
				}
				else
				{
					POINT cursorPos;
					GetCursorPos(&cursorPos);
					lastLeftClickPosition=cursorPos;
					waitingForDoubleClick=true;
					SetTimer(_this->m_hwnd, DOUBLECLICK_TIMER, 500, NULL);
				}
			}

			return 0;
		}
		
	case WM_CLOSE:
		// don't close if there is a running connection
		if(_this->m_server->AuthClientCount() != 0 || VNCviewerApp32::Instance()->ConnectionCount() != 0)
		{
			SessionDialog::Minimize();
			return TRUE;
		}
		else
		{
			// Only accept WM_CLOSE if the logged on user has AllowShutdown set
			if (!_this->m_properties.AllowShutdown())
			{
				return 0;
			}
			_this->m_server->SetShutdown(true);
			//_this->m_server->KillAuthClients();
			//_this->m_server->KillUnauthClients();  //TR@2005
			// tnatsni Wallpaper fix
			RestoreWallpaper();
			_this->m_properties.Save();
			PostQuitMessage(0);
			break;
		}
	case WM_DESTROY:
		// The user wants WinVNC to quit cleanly...
		vnclog.Print(LL_INTINFO, VNCLOG("quitting from WM_DESTROY"));
		PostQuitMessage(0);
		return 0;
		
	case WM_QUERYENDSESSION:
		vnclog.Print(LL_INTERR, VNCLOG("WM_QUERYENDSESSION"));
		break;
		
	case WM_ENDSESSION:
		vnclog.Print(LL_INTERR, VNCLOG("WM_ENDSESSION"));
		break;

	case WM_REQUEST_UPDATE_TEAMVIEWER:
		_this->updateDialog.Show(true);
		break;

	case WM_UPDATE_TEAMVIEWER:
		//Neuere Version von TeamViewer 
		//TeamViewer Setup in Temp Verzeichnis speichern
		if(!vncService::RunningAsService())
		{
			GetSpecialFolderPath(CSIDL_DESKTOP,sAppPath);		
			sAppPath += "\\..\\temp\\";
			CreateDirectory(sAppPath.c_str(),NULL);
		}
		else
		{
			GetApplicationDirectory(sAppPath);
		}

		if (isQuickSupport)
			strcpy(Setupname,"TeamViewerQS");
		else
			strcpy(Setupname,"TeamViewer_Setup");
		
		if (strcmp(sz_IDS_TEAMVIEWER_LANGUAGE,"en") !=0)
		{
			strcat(Setupname,"_");
			strcat(Setupname,sz_IDS_TEAMVIEWER_LANGUAGE);
		}
			
		sAppPath += Setupname;
		sAppPath += ".exe";

		inetsession = InternetOpen("Mozilla/4.0 (compatible; MSIE 6.0; TeamViewer)" ,INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
		if (inetsession)
		{

			inetconn= InternetConnect(inetsession,Server, INTERNET_INVALID_PORT_NUMBER, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 );
			if (!inetconn)
			{
				InternetCloseHandle(inetsession);
				vnclog.Print(LL_INTERR,VNCLOG("TeamViewer Update NoInternetConnect"));
			}
			else
			{

			
				LPCSTR accepttypes[2];
				accepttypes[0]=(LPCSTR)"*/*";
				accepttypes[1]=0;
				strcat(updateUrl,Setupname);
				ineturl= HttpOpenRequest(inetconn, "GET", updateUrl, NULL, NULL, (LPCSTR *)accepttypes, INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_PRAGMA_NOCACHE|INTERNET_FLAG_RELOAD, 0 );
				
				resend:
				if (! HttpSendRequest(ineturl, NULL,0,NULL,0))	
				{
					InternetCloseHandle(inetconn);
					InternetCloseHandle(inetsession);
					vnclog.Print(LL_INTERR,VNCLOG("TeamViewer Update ErrorSendRequest"));
					return false;
				}

				dwErrorCode = ineturl ? ERROR_SUCCESS : GetLastError();
				dwError = ERROR_SUCCESS;;
				dwError = InternetErrorDlg(hwnd, ineturl, dwErrorCode,
					 FLAGS_ERROR_UI_FILTER_FOR_ERRORS | 
					 FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS |
					 FLAGS_ERROR_UI_FLAGS_GENERATE_DATA,
					 NULL);	

				if (dwError==ERROR_INTERNET_FORCE_RETRY)
				{
					vnclog.Print(LL_INTWARN,VNCLOG("TeamViewer Update Resend"));
					goto resend;
				}

				outfile = fopen(sAppPath.c_str(), "wb"); 

				if (!outfile)
				{
					InternetCloseHandle(ineturl);
					InternetCloseHandle(inetsession);
					vnclog.Print(LL_INTERR,VNCLOG("TeamViewer Update Error fopen"));
					
				}
				else
				{

					// Download the file
					char buffer[32000];
					DWORD dwSize;
					success = true;
					do
					{
						if (! InternetReadFile(ineturl, buffer, sizeof(buffer) - 1, &dwSize))
							success = false;        
						if (! dwSize)
						{
							break;
						}
						else
						{
						size_t write_count = fwrite(buffer, 1, dwSize, outfile);
							if (write_count < (int)dwSize)
							{
								success = false;
								break;
							}

						}
					}
					while (true); 

					fclose (outfile);
					InternetCloseHandle(ineturl);
					InternetCloseHandle(inetsession);

					if (rgw->IsValidExe(sAppPath.c_str()))
					{
						_this->updateDialog.CloseDialog();
						RemoveMutex();
						//TeamViewer schlie遝n
						_this->m_server->SetShutdown(true);
						RestoreWallpaper();
						_this->m_properties.Save();
						
						PostQuitMessage(0);
						rgw->KillGateway(true);
						
						ShellExecute(0,"open",sAppPath.c_str(),0,0,SW_SHOW);
						break;
					}
				}
			}
		}
		RemoveMutex();
		_this->m_server->SetShutdown(true);
		RestoreWallpaper();
		_this->updateDialog.SetText(sz_IDS_UPDATE_FAILED);
		Sleep(3000);
		_this->updateDialog.CloseDialog();
				
		
		_this->m_properties.Save();
		
		PostQuitMessage(0);
		rgw->KillGateway(true);
		ShellExecute(0,"open",sz_IDS_DOWNLOAD_LINK,0,0,SW_SHOW);
		break;

	case WM_USERCHANGED:
		// The current user may have changed.
		{
			char newuser[UNLEN+1];

			if (vncService::CurrentUser((char *) &newuser, sizeof(newuser)))
			{

				// Check whether the user name has changed!
				if (strcmp(newuser, _this->m_username) != 0)
				{
					vnclog.Print(LL_INTINFO,
						VNCLOG("usernames : old=\"%s\", new=\"%s\""),
						_this->m_username, newuser);
			
					// User has changed!
					strcpy(_this->m_username, newuser);

					// Redraw the tray icon and set it's state
					_this->DelTrayIcon();
					_this->AddTrayIcon();
					_this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0);
					// We should load in the prefs for the new user
					_this->m_properties.Load();
				}
			}
		}
		return 0;
	
	default:
		if(iMsg == s_uTaskbarRestart)
		{
			//ex. if explorer has been crashed and reloaded (usually the icon would not be shown anymore)
			_this->AddTrayIcon();	
			break;
		}
		// Deal with any of our custom message types
/*		if (iMsg == MENU_PROPERTIES_SHOW)
		{
			// External request to show our Properties dialog
			PostMessage(hwnd, WM_COMMAND, MAKELONG(ID_PROPERTIES, 0), 0);
			return 0;
		} */
		if (iMsg == MENU_DEFAULT_PROPERTIES_SHOW)
		{
			// External request to show our Properties dialog
			PostMessage(hwnd, WM_COMMAND, MAKELONG(ID_DEFAULT_PROPERTIES, 0), 0);
			return 0;
		}
		if (iMsg == MENU_ABOUTBOX_SHOW)
		{
			// External request to show our About dialog
			PostMessage(hwnd, WM_COMMAND, MAKELONG(ID_ABOUT, 0), 0);
			return 0;
		}
		if (iMsg == MENU_SERVICEHELPER_MSG)
		{
			// CS: DynGate Service helper
			CroGateway::PostServiceHelperMessage(lParam);

			// External ServiceHelper message.
			// This message holds a process id which we can use to
			// impersonate a specific user.  In doing so, we can load their
			// preferences correctly

			// vncService::ProcessUserHelperMessage(wParam, lParam);
			// Modif Jeremy C.
			if (!_this->m_properties.Lock_service_helper)
			{
			vncService::ProcessUserHelperMessage(lParam); 

			// - Trigger a check of the current user
			PostMessage(hwnd, WM_USERCHANGED, 0, 0);
			}
			return 0;
		}

		// Process FileTransfer asynchronous Send Packet Message
		if (iMsg == FileTransferSendPacketMessage) 
		{
		  vncClient* pClient = (vncClient*) wParam;
		  if (_this->m_server->IsClient(pClient)) pClient->SendFileChunk();
		}

	}

	// Message not recognised
	return DefWindowProc(hwnd, iMsg, wParam, lParam);
}

void vncMenu::ShowContextMenu()
{
	// Get the current cursor position, to display the menu at
	POINT mouse;
	GetCursorPos(&mouse);
	ShowContextMenu(mouse);
}

void vncMenu::ShowContextMenu(POINT position)
{
	HMENU submenu = GetSubMenu(m_hmenu, 0);

	// NT4: no SetMenuInfo() function -> don't color menu
	if(m_SetMenuInfo)
	{
		MENUINFO minf;
		minf.cbSize = sizeof(MENUINFO);
		minf.fMask = MIM_BACKGROUND|MIM_APPLYTOSUBMENUS;			// set menu background color to blue
		minf.hbrBack = menuBrush;
		(*m_SetMenuInfo)(submenu, &minf);

		MENUITEMINFO mii;
		mii.cbSize = sizeof (MENUITEMINFO);
		mii.fMask = MIIM_TYPE;
		mii.fType = MFT_OWNERDRAW;
		mii.dwTypeData = "TeamViewer Traymenu";
		int i=0; 
		while(SetMenuItemInfo(submenu,i,TRUE,&mii) != 0) 
			i++;
	}

	// Make the first menu item the default (bold font)
	// SetMenuDefaultItem(submenu, 0, TRUE);
	
	// There's a "bug"
	// (Microsoft calls it a feature) in Windows 95 that requires calling
	// SetForegroundWindow. To find out more, search for Q135788 in MSDN.
	SetForegroundWindow(this->m_nid.hWnd);

	// Display the menu at the desired position
	TrackPopupMenu(submenu,
			0, position.x, position.y, 0,
			this->m_nid.hWnd, NULL);

	//return 0;
}

HWND vncMenu::GetHWND()
{
	return m_hwnd;
}

void vncMenu::Show(bool show)
{
	if(!m_nid.hWnd)
		return;
	if(show)
	{
		Shell_NotifyIcon(NIM_ADD,&m_nid);
	}
	else
	{
		Shell_NotifyIcon(NIM_DELETE,&m_nid);
	}
}

⌨️ 快捷键说明

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