コード例 #1
0
ファイル: AboutBox.cpp プロジェクト: chiradeep/CloudStack
// Process the About dialog.
static LRESULT CALLBACK AboutDlgProc(HWND hwnd, UINT iMsg, 
										   WPARAM wParam, LPARAM lParam) {
	switch (iMsg) {
	case WM_INITDIALOG:
		{
			CentreWindow(hwnd);
			SetForegroundWindow(hwnd);
            extern char buildtime[];
            SetDlgItemText(hwnd, IDC_BUILDTIME, buildtime);
			return TRUE;
		}
	case WM_CLOSE:
		EndDialog(hwnd, TRUE);
		return TRUE;
	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK) {
			EndDialog(hwnd, TRUE);
		}
	/*case WM_ERASEBKGND:
            {
               DoSDKEraseBkGnd((HDC)wParam, RGB(255,0,0));
				return true;
            }
	case WM_CTLCOLORSTATIC:
			{
				SetBkMode((HDC) wParam, TRANSPARENT);
				return (DWORD) GetStockObject(NULL_BRUSH);
			}*/
	}
	return FALSE;
}
コード例 #2
0
ファイル: TestPlugin.cpp プロジェクト: DennisHeerema/ultravnc
//
// Config Dialog box callback
//
BOOL CALLBACK ConfigDlgProc(HWND hwnd,  UINT uMsg,  WPARAM wParam, LPARAM lParam )
{
	PLUGINSTRUCT* _this = (PLUGINSTRUCT*) GetWindowLong(hwnd, GWL_USERDATA);

	switch (uMsg)
	{
	case WM_INITDIALOG:
		{
			// Init the various fields with the saved values if they exist.
			CentreWindow(hwnd);
            return TRUE;
		}

	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDOK:
			// Save the parameters in an ini file or registry for instance/
			// szLoaderType (environnement value) param can be used if necessary.
			return TRUE;

		case IDCANCEL:
			EndDialog(hwnd, FALSE);
			return TRUE;
		}
		break;

	case WM_DESTROY:
		EndDialog(hwnd, FALSE);
		return TRUE;
	}
	return 0;
}
コード例 #3
0
ファイル: ABOUTDLG.C プロジェクト: chrisoldwood/MDADEBUG
/*******************************************************************************
** About box dialog message handler.
**/
DIALOGPROC AboutDialogProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
     /* Decode message. */
     switch (iMsg)
     {
		/* Initialisation. */
		case WM_INITDIALOG:
			CentreWindow(hDlg);
			return TRUE;
			
		/* Command. */
		case WM_COMMAND:
			/* Decode command. */
			switch(wParam)
			{
				/* OK button pressed. */
				case IDOK:
				case IDCANCEL:
					EndDialog(hDlg, TRUE);
					return TRUE;
					
				/* Safe. */
				default:
					break;
			}
			return TRUE;
			
          /* Safe. */
          default:
     		break;
     }

	/* All others. */
     return FALSE;
}
コード例 #4
0
ファイル: bmpFlasher.cpp プロジェクト: DennisHeerema/ultravnc
// Process window messages
LRESULT CALLBACK BmpFlasher::WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) {
	// This is a static method, so we don't know which instantiation we're 
	// dealing with. We use Allen Hadden's ([email protected]) suggestion 
	// from a newsgroup to get the pseudo-this.
	BmpFlasher *_this = (BmpFlasher *) GetWindowLong(hwnd, GWL_USERDATA);

	switch (iMsg) {
	
	case WM_ERASEBKGND:
            {
                DoSDKEraseBkGnd2((HDC)wParam, RGB(255,0,0));
				return true;
            }
	case WM_CTLCOLORSTATIC:
			{
				SetBkMode((HDC) wParam, TRANSPARENT);
				return (DWORD) GetStockObject(NULL_BRUSH);
			}
	case WM_TIMER:
			DestroyWindow(hwnd);
			break;
	case WM_CREATE:
		CentreWindow(hwnd);
		SetForegroundWindow(hwnd);
		m_nTimerID = SetTimer(hwnd,1, 200, 0);
		return 0;
	case WM_CLOSE:
		KillTimer(hwnd,m_nTimerID);
		break;
	case WM_USER:
		switch (lParam)
		{
		case WM_LBUTTONDBLCLK:
		case WM_LBUTTONDOWN:
		case WM_RBUTTONDOWN:
		case WM_KEYDOWN:
		case WM_MBUTTONDOWN:
		DestroyWindow(hwnd);
		KillTimer(hwnd,m_nTimerID);
		break;
		}
	}
	
	return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
コード例 #5
0
ファイル: AuthDialog.cpp プロジェクト: chiradeep/CloudStack
BOOL CALLBACK AuthDialog::DlgProc(  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:
	AuthDialog *_this = (AuthDialog *) GetWindowLong(hwnd, GWL_USERDATA);

	switch (uMsg) {

	case WM_INITDIALOG:
		{
			SetWindowLong(hwnd, GWL_USERDATA, lParam);
			_this = (AuthDialog *) lParam;
			CentreWindow(hwnd);
			SetForegroundWindow(hwnd);
			return TRUE;
		}
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDOK:
			{
				UINT res= GetDlgItemText( hwnd,  IDC_PASSWD_EDIT,
					_this->m_passwd, 256);
				res= GetDlgItemText( hwnd,  IDD_DOMAIN,
					_this->m_domain, 256);
				res= GetDlgItemText( hwnd,  IDD_USER_NAME,
					_this->m_user, 256);
				
				EndDialog(hwnd, TRUE);

				return TRUE;
			}
		case IDCANCEL:
			EndDialog(hwnd, FALSE);
			return TRUE;
		}
		break;
	case WM_DESTROY:
		EndDialog(hwnd, FALSE);
		return TRUE;
	}
	return 0;
}
コード例 #6
0
ファイル: bmpFlasher.cpp プロジェクト: DennisHeerema/ultravnc
BmpFlasher::BmpFlasher()
{
	// Create a dummy window.  We don't use it for anything except
	// receiving socket events, so a seperate listening thread would
	// probably be easier!

	WNDCLASSEX wndclass;

	wndclass.cbSize			= sizeof(wndclass);
	wndclass.style			= CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc	= BmpFlasher::WndProc;
	wndclass.cbClsExtra		= 0;
	wndclass.cbWndExtra		= 0;
	wndclass.hInstance		= pApp->m_instance;
	wndclass.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	wndclass.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wndclass.hbrBackground	= (HBRUSH) GetStockObject(WHITE_BRUSH);
	wndclass.lpszMenuName	= (const char *) NULL;
	wndclass.lpszClassName	= BmpFlasher_CLASS_NAME;
	wndclass.hIconSm		= LoadIcon(NULL, IDI_APPLICATION);

	RegisterClassEx(&wndclass);

	m_hwnd = CreateWindow(BmpFlasher_CLASS_NAME,
				BmpFlasher_CLASS_NAME,
				WS_OVERLAPPED | WS_THICKFRAME,
				CW_USEDEFAULT,
				CW_USEDEFAULT,
				300, 200,
				NULL,
				NULL,
				pApp->m_instance,
				NULL);
	SetWindowLong(m_hwnd, GWL_USERDATA, (LONG) this);
	LONG style = GetWindowLong(m_hwnd, GWL_STYLE);
	style = GetWindowLong(m_hwnd, GWL_STYLE);
	style &= ~(WS_DLGFRAME | WS_THICKFRAME);
	SetWindowLong(m_hwnd, GWL_STYLE, style);
	SetWindowPos(m_hwnd, HWND_TOPMOST, -1, -1,
		300, 200, SWP_FRAMECHANGED);
	CentreWindow(m_hwnd);

}
コード例 #7
0
//---------------------------------------------------------------------------
void CreateNotifyInitWin()
{
  WNDCLASS wc;
  wc.style=CS_NOCLOSE;
  wc.lpfnWndProc=NotifyInitWndProc;
  wc.cbWndExtra=0;
  wc.cbClsExtra=0;
  wc.hInstance=Inst;
  wc.hIcon=hGUIIcon[RC_ICO_APP];
  wc.hCursor=LoadCursor(NULL,IDC_WAIT);
#ifndef ONEGAME
  wc.hbrBackground=ClassBkColour(COLOR_BTNFACE);
#else
  wc.hbrBackground=NULL;
#endif
  wc.lpszMenuName=NULL;
  wc.lpszClassName="Steem Init Window";
  RegisterClass(&wc);

#ifndef ONEGAME
  NotifyWin=CreateWindow("Steem Init Window",T("Steem is Initialising"),WS_SYSMENU,
                          0,0,NOTIFYINIT_WIDTH,NOTIFYINIT_HEIGHT,NULL,NULL,Inst,NULL);
  CentreWindow(NotifyWin,0);
  SetWindowPos(NotifyWin,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
  UpdateWindow(NotifyWin);
#else
  NotifyWinParent=CreateWindow("Steem Init Window","",0,0,0,2,2,NULL,NULL,Inst,NULL);
  NotifyWin=CreateWindowEx(WS_EX_TOPMOST,"Steem Init Window","",WS_POPUP,0,0,NOTIFYINIT_WIDTH,NOTIFYINIT_HEIGHT,
                            NotifyWinParent,NULL,Inst,NULL);
  SetWindowLong(NotifyWin,GWL_STYLE,WS_POPUP);
  MoveWindow(NotifyWin,0,0,NOTIFYINIT_WIDTH,NOTIFYINIT_HEIGHT,0);
  ShowWindow(NotifyWin,SW_SHOW);
  SetWindowPos(NotifyWin,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
  UpdateWindow(NotifyWin);
  SetCursor(NULL);
#endif
}
コード例 #8
0
ファイル: FileTransfer.cpp プロジェクト: bk138/CollabTool
BOOL CALLBACK 
FileTransfer::FTBrowseDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	FileTransfer *_this = (FileTransfer *) GetWindowLong(hwnd, GWL_USERDATA);
	switch (uMsg)
	{
	case WM_INITDIALOG:
		{
			SetWindowLong(hwnd, GWL_USERDATA, lParam);
			_this = (FileTransfer *) lParam;
			CentreWindow(hwnd);
			_this->m_hwndFTBrowse = hwnd;
			if (_this->m_bServerBrowseRequest) {
				_this->SendFileListRequestMessage("", 0x10);
				return TRUE;
			} else {
				TVITEM TVItem;
				TVINSERTSTRUCT tvins; 
				char DrivesString[256];
				char drive[] = "?:";
				int LengthDriveString = GetLogicalDriveStrings(256, DrivesString);
				TVItem.mask = TVIF_CHILDREN | TVIF_TEXT | TVIF_HANDLE;
				for (int i=0; i<LengthDriveString; i++) {
					drive[0] = DrivesString[i];
					TVItem.pszText = drive;
					TVItem.cChildren = 1;
					tvins.item = TVItem;
					tvins.hParent = TreeView_InsertItem(GetDlgItem(hwnd, IDC_FTBROWSETREE), &tvins);
					tvins.item = TVItem;
					TreeView_InsertItem(GetDlgItem(hwnd, IDC_FTBROWSETREE), &tvins);
					tvins.hParent = NULL;
					i += 3;
				}
			}
			return TRUE;
		}
	break;
	case WM_COMMAND:
		{
		switch (LOWORD(wParam))
		{
			case IDC_FTBROWSECANCEL:
				EndDialog(hwnd, TRUE);
				_this->m_bServerBrowseRequest = FALSE;
				return TRUE;
			case IDC_FTBROWSEOK:
				char path[rfbMAX_PATH];
				if (GetWindowText(GetDlgItem(hwnd, IDC_FTBROWSEEDIT), path, rfbMAX_PATH) == 0) {
					EndDialog(hwnd, TRUE);
					_this->m_bServerBrowseRequest = FALSE;
					return TRUE;
				}
				if (_this->m_bServerBrowseRequest) {
					strcpy(_this->m_ServerPathTmp, path);
					EndDialog(hwnd,TRUE);
					_this->m_bServerBrowseRequest = FALSE;
					_this->SendFileListRequestMessage(_this->m_ServerPathTmp, 0);
					return TRUE;
				} else {
					strcpy(_this->m_ClientPathTmp, path);
					EndDialog(hwnd,TRUE);
					_this->ShowClientItems(_this->m_ClientPathTmp);
				}
				return TRUE;
		}
		}
	break;
	case WM_NOTIFY:
		switch (LOWORD(wParam))
		{
		case IDC_FTBROWSETREE:
			switch (((LPNMHDR) lParam)->code)
			{
			case TVN_SELCHANGED:
				{
					NMTREEVIEW *m_lParam = (NMTREEVIEW *) lParam;
					char path[rfbMAX_PATH];
					_this->GetTVPath(GetDlgItem(hwnd, IDC_FTBROWSETREE), m_lParam->itemNew.hItem, path);
					SetWindowText(GetDlgItem(hwnd, IDC_FTBROWSEEDIT), path);
					return TRUE;
				}
				break;
			case TVN_ITEMEXPANDING:
				{
				NMTREEVIEW *m_lParam = (NMTREEVIEW *) lParam;
				char Path[rfbMAX_PATH];
				if (m_lParam -> action == 2) {
					if (_this->m_bServerBrowseRequest) {
						_this->m_hTreeItem = m_lParam->itemNew.hItem;
						_this->GetTVPath(GetDlgItem(hwnd, IDC_FTBROWSETREE), m_lParam->itemNew.hItem, Path);
						_this->SendFileListRequestMessage(Path, 0x10);
						return TRUE;
					} else {
						_this->ShowTreeViewItems(hwnd, m_lParam);
					}
				}
				return TRUE;
				}
			}
			break;
		}
	break;
	case WM_CLOSE:
	case WM_DESTROY:
		EndDialog(hwnd, FALSE);
		_this->m_bServerBrowseRequest = FALSE;
		return TRUE;
	}
	return 0;
}
コード例 #9
0
ファイル: FileTransfer.cpp プロジェクト: bk138/CollabTool
LRESULT CALLBACK 
FileTransfer::FileTransferDlgProc(HWND hwnd, 
								  UINT uMsg, 
								  WPARAM wParam, 
								  LPARAM lParam)
{
	FileTransfer *_this = (FileTransfer *) GetWindowLong(hwnd, GWL_USERDATA);
	int i;
	switch (uMsg)
	{

	case WM_INITDIALOG:
		{
			SetForegroundWindow(hwnd);
			CentreWindow(hwnd);
			return TRUE;
		}
	break;
	case WM_HELP:	
		help.Popup(lParam);
		return 0;
	case WM_COMMAND:
		{
		switch (LOWORD(wParam))
		{
			case IDC_CLIENTPATH:
				switch (HIWORD (wParam))
				{
					case EN_SETFOCUS:
						SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), noactionText);
						EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), FALSE);
						return TRUE;
				}
			break;
			case IDC_SERVERPATH:
				switch (HIWORD (wParam))
				{
					case EN_SETFOCUS:
						SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), noactionText);
						EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), FALSE);
						return TRUE;
				}
			break;
			case IDC_EXIT:
			case IDCANCEL:
				PostMessage(hwnd, WM_CLOSE, 0, 0);
				return TRUE;
			case IDC_CLIENTUP:
				SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), noactionText);
				EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), FALSE);
				SendMessage(_this->m_hwndFTProgress, PBM_SETPOS, 0, 0);
				SetWindowText(_this->m_hwndFTStatus, "");
				if (strcmp(_this->m_ClientPathTmp, "") == 0) return TRUE;
				for (i=(strlen(_this->m_ClientPathTmp)-2); i>=0; i--) {
					if (_this->m_ClientPathTmp[i] == '\\') {
						_this->m_ClientPathTmp[i] = '\0';
						break;
					}
					if (i == 0) _this->m_ClientPathTmp[0] = '\0';
				}
				_this->ShowClientItems(_this->m_ClientPathTmp);
				return TRUE;
			case IDC_SERVERUP:
				SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), noactionText);
				EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), FALSE);
				SendMessage(_this->m_hwndFTProgress, PBM_SETPOS, 0, 0);
				SetWindowText(_this->m_hwndFTStatus, "");
				if (strcmp(_this->m_ServerPathTmp, "") == 0) return TRUE;
				for (i=(strlen(_this->m_ServerPathTmp)-2); i>=0; i--) {
					if (_this->m_ServerPathTmp[i] == '\\') {
						_this->m_ServerPathTmp[i] = '\0';
						break;
					}
					if (i == 0) _this->m_ServerPathTmp[0] = '\0';
				}
				_this->SendFileListRequestMessage(_this->m_ServerPathTmp, 0);
				return TRUE;
			case IDC_CLIENTRELOAD:
				SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), noactionText);
				EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), FALSE);
				SendMessage(_this->m_hwndFTProgress, PBM_SETPOS, 0, 0);
				SetWindowText(_this->m_hwndFTStatus, "");
				_this->ShowClientItems(_this->m_ClientPath);
				return TRUE;
			case IDC_SERVERRELOAD:
				SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), noactionText);
				EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), FALSE);
				SendMessage(_this->m_hwndFTProgress, PBM_SETPOS, 0, 0);
				SetWindowText(_this->m_hwndFTStatus, "");
				_this->SendFileListRequestMessage(_this->m_ServerPathTmp, 0);
				return TRUE;
			case IDC_FTCOPY:
				// First, check if the action is supported by the server.
				if (_this->m_bFTCOPY == FALSE) {
					// Upload was requested.
					if ( !_this->m_clientconn->m_clientMsgCaps.IsEnabled(rfbFileUploadRequest) ||
						 !_this->m_clientconn->m_clientMsgCaps.IsEnabled(rfbFileUploadData) ) {
						MessageBox(hwnd, "Sorry but the server does not support uploading files.",
								   "Error", MB_OK | MB_ICONEXCLAMATION);
						char buf[MAX_PATH];
						sprintf(buf, "File upload not supported by server");
						SetWindowText(_this->m_hwndFTStatus, buf);
						return TRUE;
					}
				} else {
					// Download was requested.
					if ( !_this->m_clientconn->m_clientMsgCaps.IsEnabled(rfbFileDownloadRequest) ||
						 !_this->m_clientconn->m_serverMsgCaps.IsEnabled(rfbFileDownloadData) ) {
						MessageBox(hwnd, "Sorry but the server does not support downloading files.",
								   "Error", MB_OK | MB_ICONEXCLAMATION);
						char buf[MAX_PATH];
						sprintf(buf, "File download not supported by server");
						SetWindowText(_this->m_hwndFTStatus, buf);
						return TRUE;
					}
				}
				// Now, try to upload/download.
				SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), noactionText);
				EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), FALSE);
				if (_this->m_ClientPath[0] == '\0' || _this->m_ServerPath[0] == '\0') {
					SetWindowText(_this->m_hwndFTStatus, "Cannot transfer files: illegal directory.");
					return TRUE;
				}
				if (_this->m_bFTCOPY == FALSE) {
					_this->m_bTransferEnable = TRUE;
					_this->m_bReportUploadCancel = TRUE;
					EnableWindow(GetDlgItem(hwnd, IDC_FTCANCEL), TRUE);
					_this->FileTransferUpload();			
				} else {
					return _this->SendMultipleFileDownloadRequests();
				}
				return TRUE;
			case IDC_FTCANCEL:
				// Check if we allowed to interrupt the transfer.
				if ( _this->m_bUploadStarted &&
					 !_this->m_clientconn->m_clientMsgCaps.IsEnabled(rfbFileUploadFailed) ) {
					char buf[MAX_PATH];
					sprintf(buf, "Sorry, but interrupting upload is not supported by the server");
					SetWindowText(_this->m_hwndFTStatus, buf);
					return TRUE;
				}
				if ( _this->m_bDownloadStarted &&
					 !_this->m_clientconn->m_clientMsgCaps.IsEnabled(rfbFileDownloadCancel) ) {
					char buf[MAX_PATH];
					sprintf(buf, "Sorry, but interrupting download is not supported by the server");
					SetWindowText(_this->m_hwndFTStatus, buf);
					return TRUE;
				}
				// Now try to cancel the operation.
				SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), noactionText);
				EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), FALSE);
				_this->m_bTransferEnable = FALSE;
				EnableWindow(GetDlgItem(hwnd, IDC_FTCANCEL), FALSE);
				return TRUE;
			case IDC_CLIENTBROWSE_BUT:
				SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), noactionText);
				EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), FALSE);
				SendMessage(_this->m_hwndFTProgress, PBM_SETPOS, 0, 0);
				SetWindowText(_this->m_hwndFTStatus, "");
				_this->CreateFTBrowseDialog(FALSE);
				return TRUE;
			case IDC_SERVERBROWSE_BUT:
				SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), noactionText);
				EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), FALSE);
				SendMessage(_this->m_hwndFTProgress, PBM_SETPOS, 0, 0);
				SetWindowText(_this->m_hwndFTStatus, "");
				_this->CreateFTBrowseDialog(TRUE);
				return TRUE;
		}
		}
	break;

	case WM_NOTIFY:
		switch (LOWORD(wParam))
		{
		case IDC_FTCLIENTLIST:
			switch (((LPNMHDR) lParam)->code)
			{
				case NM_SETFOCUS:
					SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), uploadText);
					EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), TRUE);
					_this->m_bFTCOPY = FALSE;
					return TRUE;
				case LVN_GETDISPINFO:
					_this->OnGetDispClientInfo((NMLVDISPINFO *) lParam); 
					return TRUE;
				case LVN_ITEMACTIVATE:
					LPNMITEMACTIVATE lpnmia = (LPNMITEMACTIVATE)lParam;
					_this->ProcessListViewDBLCLK(_this->m_hwndFTClientList, _this->m_ClientPath, _this->m_ClientPathTmp, lpnmia->iItem);
					return TRUE;
			}
		break;
		case IDC_FTSERVERLIST:
			switch (((LPNMHDR) lParam)->code)
			{
				case NM_SETFOCUS:
					SetWindowText(GetDlgItem(hwnd, IDC_FTCOPY), downloadText);
					EnableWindow(GetDlgItem(hwnd, IDC_FTCOPY), TRUE);
					_this->m_bFTCOPY = TRUE;
					return TRUE;
				case LVN_GETDISPINFO: 
					_this->OnGetDispServerInfo((NMLVDISPINFO *) lParam); 
					return TRUE;
				case LVN_ITEMACTIVATE:
					LPNMITEMACTIVATE lpnmia = (LPNMITEMACTIVATE)lParam;
					_this->ProcessListViewDBLCLK(_this->m_hwndFTServerList, _this->m_ServerPath, _this->m_ServerPathTmp, lpnmia->iItem);
					return TRUE;
			}
		break;
		}
		break;
	case WM_CLOSE:
		_this->m_clientconn->m_fileTransferDialogShown = false;
		_this->m_FTClientItemInfo.Free();
		_this->m_FTServerItemInfo.Free();
#ifndef _WIN32_WCE
		{
			VNCviewerApp32 *pApp = (VNCviewerApp32 *)(_this->m_clientconn->m_pApp);
			pApp->RemoveModelessDialog(hwnd);
		}
#endif
		DestroyWindow(hwnd);
		return TRUE;
	}
	return 0;
}
コード例 #10
0
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 = helper::SafeGetWindowUserData<VNCOptions>(hwnd);
	
  switch (uMsg) {
		
  case WM_INITDIALOG:
	  {
          helper::SafeSetWindowUserData(hwnd, lParam);
		  _this = (VNCOptions *) lParam;
		  // Initialise the controls
		  _this->hwnd = hwnd;
		  // Window always on top
		  RECT Rect;
		  GetWindowRect(hwnd, &Rect);
		  SetWindowPos(hwnd, 
			  HWND_TOPMOST,
			  Rect.left,
			  Rect.top,
			  Rect.right - Rect.left,
			  Rect.bottom - Rect.top,
			  SWP_SHOWWINDOW);
		  
		  HWND had = GetDlgItem(hwnd, IDC_AUTODETECT);
		  SendMessage(had, BM_SETCHECK, _this->autoDetect, 0);
		  int i = 0;	  
		  for (i = rfbEncodingRaw; i <= LASTENCODING; i++) {
			  HWND hPref = GetDlgItem(hwnd, IDC_RAWRADIO + (i-rfbEncodingRaw));
			  SendMessage(hPref, BM_SETCHECK, 
				  (i== _this->m_PreferredEncoding), 0);
			  EnableWindow(hPref, _this->m_UseEnc[i] && !_this->autoDetect);
		  }
		  
		  HWND hCopyRect = GetDlgItem(hwnd, ID_SESSION_SET_CRECT);
		  SendMessage(hCopyRect, BM_SETCHECK, _this->m_UseEnc[rfbEncodingCopyRect], 0);
		  EnableWindow(hCopyRect, !_this->autoDetect);
		  
		  HWND hSwap = GetDlgItem(hwnd, ID_SESSION_SWAPMOUSE);
		  SendMessage(hSwap, BM_SETCHECK, _this->m_SwapMouse, 0);
		  
		  // Tight 
		  HWND hAcl = GetDlgItem(hwnd, IDC_ALLOW_COMPRESSLEVEL);
		  EnableWindow(hAcl, !_this->autoDetect);
		  
		  HWND hCl = GetDlgItem(hwnd, IDC_COMPRESSLEVEL);
		  EnableWindow(hCl, !_this->autoDetect);
		  
		  HWND hAj = GetDlgItem(hwnd, IDC_ALLOW_JPEG);
		  EnableWindow(hAj, !_this->autoDetect);
		  
		  HWND hQl = GetDlgItem(hwnd, IDC_QUALITYLEVEL);
		  EnableWindow(hQl, !_this->autoDetect);
		  
		  HWND hDeiconify = GetDlgItem(hwnd, IDC_BELLDEICONIFY);
		  SendMessage(hDeiconify, BM_SETCHECK, _this->m_DeiconifyOnBell, 0);
		  
#ifndef UNDER_CE
		  HWND hDisableClip = GetDlgItem(hwnd, IDC_DISABLECLIPBOARD);
		  SendMessage(hDisableClip, BM_SETCHECK, _this->m_DisableClipboard, 0);
#endif			
		  

		  // sf@2005 - New Color depth choice
		  HWND hColorMode;
		  switch (_this->m_Use8Bit)
		  {
		  case rfbPFFullColors:
			  hColorMode = GetDlgItem(hwnd, IDC_FULLCOLORS_RADIO);
			  break;
		  case rfbPF256Colors:
			  hColorMode = GetDlgItem(hwnd, IDC_256COLORS_RADIO);
			  break;
		  case rfbPF64Colors:
			  hColorMode = GetDlgItem(hwnd, IDC_64COLORS_RADIO);
			  break;
		  case rfbPF8Colors:
			  hColorMode = GetDlgItem(hwnd, IDC_8COLORS_RADIO);
			  break;
		  case rfbPF8GreyColors:
			  hColorMode = GetDlgItem(hwnd, IDC_8GREYCOLORS_RADIO);
			  break;
		  case rfbPF4GreyColors:
			  hColorMode = GetDlgItem(hwnd, IDC_4GREYCOLORS_RADIO);
			  break;
		  case rfbPF2GreyColors:
			  hColorMode = GetDlgItem(hwnd, IDC_2GREYCOLORS_RADIO);
			  break;
		  }
		  SendMessage(hColorMode, BM_SETCHECK,	true, 0);

   	      // sf@2005 - New color depth choice
		  hColorMode = GetDlgItem(hwnd, IDC_FULLCOLORS_RADIO);
		  EnableWindow(hColorMode, !_this->autoDetect);
		  hColorMode = GetDlgItem(hwnd, IDC_256COLORS_RADIO);
		  EnableWindow(hColorMode, !_this->autoDetect);
		  hColorMode = GetDlgItem(hwnd, IDC_64COLORS_RADIO);
		  EnableWindow(hColorMode, !_this->autoDetect);
		  hColorMode = GetDlgItem(hwnd, IDC_8COLORS_RADIO);
		  EnableWindow(hColorMode, !_this->autoDetect);
		  hColorMode = GetDlgItem(hwnd, IDC_8GREYCOLORS_RADIO);
		  EnableWindow(hColorMode, !_this->autoDetect);
		  hColorMode = GetDlgItem(hwnd, IDC_4GREYCOLORS_RADIO);
		  EnableWindow(hColorMode, !_this->autoDetect);
		  hColorMode = GetDlgItem(hwnd, IDC_2GREYCOLORS_RADIO);
		  EnableWindow(hColorMode, !_this->autoDetect);


		  HWND hShared = GetDlgItem(hwnd, IDC_SHARED);
		  SendMessage(hShared, BM_SETCHECK, _this->m_Shared, 0);
		  EnableWindow(hShared, !_this->m_running);
		  
		  HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY);
		  SendMessage(hViewOnly, BM_SETCHECK, _this->m_ViewOnly, 0);
		  
		  // Toolbar
		  HWND hShowToolbar = GetDlgItem(hwnd, IDC_SHOWTOOLBAR);
		  SendMessage(hShowToolbar, BM_SETCHECK, _this->m_ShowToolbar, 0);
		  
		  HWND hAutoScaling = GetDlgItem(hwnd, IDC_SCALING);
		  SendMessage(hAutoScaling, BM_SETCHECK, _this->m_fAutoScaling, 0);
		  
		  // SetDlgItemInt( hwnd, IDC_SCALE_NUM, _this->m_scale_num, FALSE);
		  // SetDlgItemInt( hwnd, IDC_SCALE_DEN, _this->m_scale_den, FALSE);
	
		  // Viewer Scaling combo box - Now using percentage
		  // The combo is still editable for customizable value
		  int Scales[13] = { 25, 50, 75, 80, 85, 90, 95, 100, 125, 150, 200, 300, 400};
		  HWND hViewerScale = GetDlgItem(hwnd, IDC_SCALE_CB);
		  char szPer[4];
		  for (i = 0; i <= 12; i++)
		  {
			  _itoa(Scales[i], szPer, 10);
			  SendMessage(hViewerScale, CB_INSERTSTRING, (WPARAM)i, (LPARAM)(int FAR*)szPer);
		  }
		  SetDlgItemInt(hwnd,
			            IDC_SCALE_CB,
						(( _this->m_scale_num * 100) / _this->m_scale_den),
						FALSE);
				  
		  // Modif sf@2002 - Server Scaling
		  SetDlgItemInt( hwnd, IDC_SERVER_SCALE, _this->m_nServerScale, FALSE);

		  if (_this->m_Shared)
		  SetDlgItemInt( hwnd, IDC_SERVER_RECON, _this->m_reconnectcounter, FALSE);
		  else SetDlgItemInt( hwnd, IDC_SERVER_RECON, 0, FALSE);
		  
		  // Modif sf@2002 - Cache 
		  HWND hCache = GetDlgItem(hwnd, ID_SESSION_SET_CACHE);
		  SendMessage(hCache, BM_SETCHECK, _this->m_fEnableCache, 0);
		  EnableWindow(hCache, !_this->autoDetect);
		  
		  
#ifndef UNDER_CE
		  HWND hFullScreen = GetDlgItem(hwnd, IDC_FULLSCREEN);
		  SendMessage(hFullScreen, BM_SETCHECK, _this->m_FullScreen, 0);
		  
		  HWND hEmulate = GetDlgItem(hwnd, IDC_EMULATECHECK);
		  SendMessage(hEmulate, BM_SETCHECK, _this->m_Emul3Buttons, 0);

		  HWND hJapkeyboard = GetDlgItem(hwnd, IDC_JAPKEYBOARD);
		  SendMessage(hJapkeyboard, BM_SETCHECK, _this->m_JapKeyboard, 0);
#endif

		  

		  // Tight Specific
		  HWND hAllowCompressLevel = GetDlgItem(hwnd, IDC_ALLOW_COMPRESSLEVEL);
		  SendMessage(hAllowCompressLevel, BM_SETCHECK, _this->m_useCompressLevel, 0);
		  
		  HWND hAllowJpeg = GetDlgItem(hwnd, IDC_ALLOW_JPEG);
		  SendMessage(hAllowJpeg, BM_SETCHECK, _this->m_enableJpegCompression, 0);
		  
		  SetDlgItemInt( hwnd, IDC_COMPRESSLEVEL, _this->m_compressLevel, FALSE);
		  SetDlgItemInt( hwnd, IDC_QUALITYLEVEL, _this->m_jpegQualityLevel, FALSE);
		  
		  
		  HWND hRemoteCursor;
		  if (_this->m_requestShapeUpdates && !_this->m_ignoreShapeUpdates) {
			  hRemoteCursor = GetDlgItem(hwnd, IDC_CSHAPE_ENABLE_RADIO);
		  } else if (_this->m_requestShapeUpdates) {
			  hRemoteCursor = GetDlgItem(hwnd, IDC_CSHAPE_IGNORE_RADIO);
		  } else {
			  hRemoteCursor = GetDlgItem(hwnd, IDC_CSHAPE_DISABLE_RADIO);
		  }
		  SendMessage(hRemoteCursor, BM_SETCHECK,	true, 0);

		  HWND hsponsor = GetDlgItem(hwnd, IDC_CHECK1);
		  SendMessage(hsponsor, BM_SETCHECK, g_disable_sponsor, 1);
		  
		  CentreWindow(hwnd);
		  SetForegroundWindow(hwnd);
		  
		  HWND hExitCheck = GetDlgItem(hwnd, IDC_EXIT_CHECK); //PGM @ Advantig
		  SendMessage(hExitCheck, BM_SETCHECK, _this->m_fExitCheck, 0); //PGM @ Advantig
		  
		  return TRUE;
    }
	
  case WM_COMMAND:
	  switch (LOWORD(wParam))
	  {
	  case IDOK:
		  {
			  HWND had = GetDlgItem(hwnd, IDC_AUTODETECT);
			  _this->autoDetect =
				  (SendMessage(had, BM_GETCHECK, 0, 0) == BST_CHECKED);
			  
			  for (int i = rfbEncodingRaw; i <= LASTENCODING; i++) {
				  HWND hPref = GetDlgItem(hwnd, IDC_RAWRADIO+i-rfbEncodingRaw);
				  if (SendMessage(hPref, BM_GETCHECK, 0, 0) == BST_CHECKED)
					  _this->m_PreferredEncoding = i;
			  }

			// [v1.0.2-jp2 fix-->]
			  if (SendMessage(GetDlgItem(hwnd, IDC_ULTRA), BM_GETCHECK, 0, 0) == BST_CHECKED){
					SendMessage(GetDlgItem(hwnd, ID_SESSION_SET_CRECT), BM_SETCHECK, false, 0);
			  }
			// [<--v1.0.2-jp2 fix]
			  
			  HWND hCopyRect = GetDlgItem(hwnd, ID_SESSION_SET_CRECT);
			  _this->m_UseEnc[rfbEncodingCopyRect] =
				  (SendMessage(hCopyRect, BM_GETCHECK, 0, 0) == BST_CHECKED);
			  
			  // Modif sf@2002 - Cache - v1.1.0				
			  HWND hCache = GetDlgItem(hwnd, ID_SESSION_SET_CACHE);
			  _this->m_fEnableCache =
				  (SendMessage(hCache, BM_GETCHECK, 0, 0) == BST_CHECKED);
			  
			  HWND hSwap = GetDlgItem(hwnd, ID_SESSION_SWAPMOUSE);
			  _this->m_SwapMouse =
				  (SendMessage(hSwap, BM_GETCHECK, 0, 0) == BST_CHECKED);
			  
			  HWND hDeiconify = GetDlgItem(hwnd, IDC_BELLDEICONIFY);
			  _this->m_DeiconifyOnBell =
				  (SendMessage(hDeiconify, BM_GETCHECK, 0, 0) == BST_CHECKED);

#ifndef UNDER_CE				
			  HWND hDisableClip = GetDlgItem(hwnd, IDC_DISABLECLIPBOARD);
			  _this->m_DisableClipboard =
				  (SendMessage(hDisableClip, BM_GETCHECK, 0, 0) == BST_CHECKED);
#endif
			  
			  // sd@2005 - New Color depth choice
			  HWND hColorMode = GetDlgItem(hwnd, IDC_FULLCOLORS_RADIO);
			  if (SendMessage(hColorMode, BM_GETCHECK, 0, 0) == BST_CHECKED)
				  _this->m_Use8Bit = rfbPFFullColors;
			  hColorMode = GetDlgItem(hwnd, IDC_256COLORS_RADIO);			  
			  if (SendMessage(hColorMode, BM_GETCHECK, 0, 0) == BST_CHECKED)
				  _this->m_Use8Bit = rfbPF256Colors;
			  hColorMode = GetDlgItem(hwnd, IDC_64COLORS_RADIO);			  
			  if (SendMessage(hColorMode, BM_GETCHECK, 0, 0) == BST_CHECKED)
				  _this->m_Use8Bit = rfbPF64Colors;
			  hColorMode = GetDlgItem(hwnd, IDC_8COLORS_RADIO);			  
			  if (SendMessage(hColorMode, BM_GETCHECK, 0, 0) == BST_CHECKED)
				  _this->m_Use8Bit = rfbPF8Colors;
			  hColorMode = GetDlgItem(hwnd, IDC_8GREYCOLORS_RADIO);			  
			  if (SendMessage(hColorMode, BM_GETCHECK, 0, 0) == BST_CHECKED)
				  _this->m_Use8Bit = rfbPF8GreyColors;
			  hColorMode = GetDlgItem(hwnd, IDC_4GREYCOLORS_RADIO);			  
			  if (SendMessage(hColorMode, BM_GETCHECK, 0, 0) == BST_CHECKED)
				  _this->m_Use8Bit = rfbPF4GreyColors;
			  hColorMode = GetDlgItem(hwnd, IDC_2GREYCOLORS_RADIO);			  
			  if (SendMessage(hColorMode, BM_GETCHECK, 0, 0) == BST_CHECKED)
				  _this->m_Use8Bit = rfbPF2GreyColors;


			  HWND hShared = GetDlgItem(hwnd, IDC_SHARED);
			  _this->m_Shared =
				  (SendMessage(hShared, BM_GETCHECK, 0, 0) == BST_CHECKED);
			  
			  HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY);
			  _this->m_ViewOnly = 
				  (SendMessage(hViewOnly, BM_GETCHECK, 0, 0) == BST_CHECKED);
			  
			  HWND hShowToolbar = GetDlgItem(hwnd, IDC_SHOWTOOLBAR);
			  _this->m_ShowToolbar = 
				  (SendMessage(hShowToolbar, BM_GETCHECK, 0, 0) == BST_CHECKED);
			  
			  HWND hAutoScaling = GetDlgItem(hwnd, IDC_SCALING);
			  _this->m_fAutoScaling = (SendMessage(hAutoScaling, BM_GETCHECK, 0, 0) == BST_CHECKED);
			 
			  HWND hViewerScaling = GetDlgItem(hwnd, IDC_SCALE_CB);
			  int nErr;
			  int nPer = GetDlgItemInt(hwnd, IDC_SCALE_CB, &nErr, FALSE);
			  if (nPer > 0)
			  {
				  _this->m_scale_num = nPer;
				  _this->m_scale_den = 100;
			  }
			  _this->m_scaling = !(_this->m_scale_num == 100);

			  if (_this->m_scaling || _this->m_fAutoScaling)
			  {
				  // _this->m_scale_num = GetDlgItemInt( hwnd, IDC_SCALE_NUM, NULL, TRUE);
				  // _this->m_scale_den = GetDlgItemInt( hwnd, IDC_SCALE_DEN, NULL, TRUE);
				  // Modif sf@2002 - Server Scaling
				  _this->m_nServerScale = GetDlgItemInt( hwnd, IDC_SERVER_SCALE, NULL, TRUE);
				  _this->FixScaling();
				  //if (_this->m_scale_num == 1 && _this->m_scale_den == 1)
				  // 	  _this->m_scaling = false;
			  }
			  else
			  {
				  _this->m_scale_num = 1;
				  _this->m_scale_den = 1;
				  // Modif sf@2002 - Server Scaling
				  _this->m_nServerScale = GetDlgItemInt( hwnd, IDC_SERVER_SCALE, NULL, TRUE);
				  if (_this->m_nServerScale < 1 || _this->m_nServerScale > 9) 
					  _this->m_nServerScale = 1;
			  }
			 if (_this->m_Shared)
			  _this->m_reconnectcounter = GetDlgItemInt( hwnd, IDC_SERVER_RECON, NULL, TRUE);
			 else _this->m_reconnectcounter=0;


			  
#ifndef UNDER_CE
			  HWND hFullScreen = GetDlgItem(hwnd, IDC_FULLSCREEN);
			  _this->m_FullScreen = 
				  (SendMessage(hFullScreen, BM_GETCHECK, 0, 0) == BST_CHECKED);
			  
			  HWND hEmulate = GetDlgItem(hwnd, IDC_EMULATECHECK);
			  _this->m_Emul3Buttons =
				  (SendMessage(hEmulate, BM_GETCHECK, 0, 0) == BST_CHECKED);

			  HWND hJapkeyboard = GetDlgItem(hwnd, IDC_JAPKEYBOARD);
			  _this->m_JapKeyboard =
				  (SendMessage(hJapkeyboard, BM_GETCHECK, 0, 0) == BST_CHECKED);
#endif
			  
			  // Tight Specific
			  HWND hAllowCompressLevel = GetDlgItem(hwnd, IDC_ALLOW_COMPRESSLEVEL);
			  _this->m_useCompressLevel = 
				  (SendMessage(hAllowCompressLevel, BM_GETCHECK, 0, 0) == BST_CHECKED);
			  
			  _this->m_compressLevel = GetDlgItemInt( hwnd, IDC_COMPRESSLEVEL, NULL, TRUE);
			  if ( _this->m_compressLevel < 0 ) { _this->m_compressLevel = 0; }
			  if ( _this->m_compressLevel > 9 ) { _this->m_compressLevel = 9; }
			  
			  HWND hAllowJpeg = GetDlgItem(hwnd, IDC_ALLOW_JPEG);
			  _this->m_enableJpegCompression = 
				  (SendMessage(hAllowJpeg, BM_GETCHECK, 0, 0) == BST_CHECKED);
			  
			  _this->m_jpegQualityLevel = GetDlgItemInt( hwnd, IDC_QUALITYLEVEL, NULL, TRUE);
			  if ( _this->m_jpegQualityLevel < 0 ) { _this->m_jpegQualityLevel = 0; }
			  if ( _this->m_jpegQualityLevel > 9 ) { _this->m_jpegQualityLevel = 9; }
			  
			  _this->m_requestShapeUpdates = false;
			  _this->m_ignoreShapeUpdates = false;
			  HWND hRemoteCursor = GetDlgItem(hwnd, IDC_CSHAPE_ENABLE_RADIO);
			  if (SendMessage(hRemoteCursor, BM_GETCHECK, 0, 0) == BST_CHECKED) {
				  _this->m_requestShapeUpdates = true;
			  } else {
				  hRemoteCursor = GetDlgItem(hwnd, IDC_CSHAPE_IGNORE_RADIO);
				  if (SendMessage(hRemoteCursor, BM_GETCHECK, 0, 0) == BST_CHECKED) {
					  _this->m_requestShapeUpdates = true;
					  _this->m_ignoreShapeUpdates = true;
				  }
			  }

			HWND hsponsor = GetDlgItem(hwnd, IDC_CHECK1);
			if (SendMessage(hsponsor, BM_GETCHECK, 0, 0) == BST_CHECKED)
			{
				g_disable_sponsor = true;
			}
			else 
			{
				g_disable_sponsor = false;

			}

			DWORD dw;
			DWORD val=g_disable_sponsor;
			HKEY huser;
			if (RegCreateKeyEx(HKEY_CURRENT_USER,
			SETTINGS_KEY_NAME,
			0,REG_NONE, REG_OPTION_NON_VOLATILE,
			KEY_WRITE | KEY_READ,
			NULL, &huser, &dw) == ERROR_SUCCESS)
			{
				RegSetValueEx(huser, "sponsor", 0, REG_DWORD, (LPBYTE) &val, sizeof(val));
				if (huser != NULL) RegCloseKey(huser);
			}

			  
			  EndDialog(hwnd, TRUE);
			  
			  return TRUE;
      }
	  
    case IDCANCEL:
		EndDialog(hwnd, FALSE);
		return TRUE;
		
    case IDC_AUTODETECT:
		{
            bool ad = IsDlgButtonChecked(hwnd, IDC_AUTODETECT) ? true : false;
		for (int i = rfbEncodingRaw; i <= LASTENCODING; i++)
		{
			HWND hPref = GetDlgItem(hwnd, IDC_RAWRADIO + (i-rfbEncodingRaw));
			EnableWindow(hPref, _this->m_UseEnc[i] && !ad);
		}
		
		HWND hCopyRect = GetDlgItem(hwnd, ID_SESSION_SET_CRECT);
		EnableWindow(hCopyRect, !ad);

		// sf@2005 - New color depth choice
		HWND hColorMode = GetDlgItem(hwnd, IDC_FULLCOLORS_RADIO);
		EnableWindow(hColorMode, !ad);
		hColorMode = GetDlgItem(hwnd, IDC_256COLORS_RADIO);
		EnableWindow(hColorMode, !ad);
		hColorMode = GetDlgItem(hwnd, IDC_64COLORS_RADIO);
		EnableWindow(hColorMode, !ad);
		hColorMode = GetDlgItem(hwnd, IDC_8COLORS_RADIO);
		EnableWindow(hColorMode, !ad);
		hColorMode = GetDlgItem(hwnd, IDC_8GREYCOLORS_RADIO);
		EnableWindow(hColorMode, !ad);
		hColorMode = GetDlgItem(hwnd, IDC_4GREYCOLORS_RADIO);
		EnableWindow(hColorMode, !ad);
		hColorMode = GetDlgItem(hwnd, IDC_2GREYCOLORS_RADIO);
		EnableWindow(hColorMode, !ad);


		// sf@2002
		HWND hCache = GetDlgItem(hwnd, ID_SESSION_SET_CACHE);
		EnableWindow(hCache, !ad);
		
		HWND hAcl = GetDlgItem(hwnd, IDC_ALLOW_COMPRESSLEVEL);
		EnableWindow(hAcl, !ad);
		
		HWND hCl = GetDlgItem(hwnd, IDC_COMPRESSLEVEL);
		EnableWindow(hCl, !ad);
		
		HWND hAj = GetDlgItem(hwnd, IDC_ALLOW_JPEG);
		EnableWindow(hAj, !ad);
		
		HWND hQl = GetDlgItem(hwnd, IDC_QUALITYLEVEL);
		EnableWindow(hQl, !ad);
		}
		return TRUE;

	// If Xor Zlib is checked, check Cache encoding as well
	// (the user can still uncheck it if he wants)
    case IDC_ZLIBRADIO:
		{
            bool xor = IsDlgButtonChecked(hwnd, IDC_ZLIBRADIO) ? true : false;
		if (xor)
		{
	 	    HWND hCache = GetDlgItem(hwnd, ID_SESSION_SET_CACHE);
			SendMessage(hCache, BM_SETCHECK, true, 0);
		}
		return TRUE;
		}
	case IDC_ULTRA:
		{
		bool ultra=IsDlgButtonChecked(hwnd, IDC_ULTRA) ? true : false;
		if (ultra)
		{
	 	    HWND hCache = GetDlgItem(hwnd, ID_SESSION_SET_CACHE);
			SendMessage(hCache, BM_SETCHECK, false, 0);
			// [v1.0.2-jp2 fix-->]
			HWND hCopyRect = GetDlgItem(hwnd, ID_SESSION_SET_CRECT);
			SendMessage(hCopyRect, BM_SETCHECK, false, 0);
			// [<--v1.0.2-jp2 fix]
			HWND hRemoteCursor = GetDlgItem(hwnd, IDC_CSHAPE_DISABLE_RADIO);
			SendMessage(hRemoteCursor, BM_SETCHECK,	true, 0);
			HWND hRemoteCursor2 = GetDlgItem(hwnd, IDC_CSHAPE_ENABLE_RADIO);
			SendMessage(hRemoteCursor2, BM_SETCHECK,false, 0);
			HWND hRemoteCursor3 = GetDlgItem(hwnd, IDC_CSHAPE_IGNORE_RADIO);
			SendMessage(hRemoteCursor3, BM_SETCHECK,false, 0);
		}
		return TRUE;
		}

    }
    break;
	

  case WM_DESTROY:
	  EndDialog(hwnd, FALSE);
	  return TRUE;
  }
  return 0;
}
コード例 #11
0
BOOL CALLBACK SessionDialog::SessDlgProc(  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:
#ifdef _X64

    SessionDialog *_this = (SessionDialog *) GetWindowLongPtr(hwnd, GWLP_USERDATA);

#else

    SessionDialog *_this = (SessionDialog *) GetWindowLong(hwnd, GWL_USERDATA);

#endif
    switch (uMsg) {

    case WM_INITDIALOG:
    {
        helper::SafeSetWindowUserData(hwnd, (LONG)lParam);
        SessionDialog *_this = (SessionDialog *) lParam;
        CentreWindow(hwnd);
        SetForegroundWindow(hwnd);
        _this->m_pCC->m_hSessionDialog = hwnd;

        // Set up recently-used list
        HWND hcombo = GetDlgItem(  hwnd, IDC_HOSTNAME_EDIT);
        TCHAR valname[256];

        for (int i = 0; i < _this->m_pMRU->NumItems(); i++) {
            _this->m_pMRU->GetItem(i, valname, 255);
            int pos = SendMessage(hcombo, CB_ADDSTRING, 0, (LPARAM) valname);

        }
        SendMessage(hcombo, CB_SETCURSEL, 0, 0);

        // sf@2002 - List available DSM Plugins
        HWND hPlugins = GetDlgItem(hwnd, IDC_PLUGINS_COMBO);
        int nPlugins = _this->m_pDSMPlugin->ListPlugins(hPlugins);
        if (!nPlugins)
        {
            SendMessage(hPlugins, CB_ADDSTRING, 0, (LPARAM) sz_F11);
        }
        else
        {
            // Use the first detected plugin, so the user doesn't have to check the option
            // HWND hUsePlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
            // SendMessage(hUsePlugin, BM_SETCHECK, TRUE, 0);
        }
        SendMessage(hPlugins, CB_SETCURSEL, 0, 0);

        //AaronP
        if( strcmp( _this->m_pOpt->m_szDSMPluginFilename, "" ) != 0 && _this->m_pOpt->m_fUseDSMPlugin ) {
            int pos = SendMessage(hPlugins, CB_FINDSTRINGEXACT, -1,
                                  (LPARAM)&(_this->m_pOpt->m_szDSMPluginFilename[0]));

            if( pos != CB_ERR ) {
                SendMessage(hPlugins, CB_SETCURSEL, pos, 0);
                HWND hUsePlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
                SendMessage(hUsePlugin, BM_SETCHECK, TRUE, 0);
            }
        }
        //EndAaronP

        TCHAR tmphost[256];
        TCHAR tmphost2[256];
        _tcscpy(tmphost, _this->m_pOpt->m_proxyhost);
        if (strcmp(tmphost,"")!=NULL)
        {
            _tcscat(tmphost,":");
            _tcscat(tmphost,_itoa(_this->m_pOpt->m_proxyport,tmphost2,10));
            SetDlgItemText(hwnd, IDC_PROXY_EDIT, tmphost);
        }

        HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY_CHECK);
        SendMessage(hViewOnly, BM_SETCHECK, _this->m_pOpt->m_ViewOnly, 0);

        HWND hAutoScaling = GetDlgItem(hwnd, IDC_AUTOSCALING_CHECK);
        SendMessage(hAutoScaling, BM_SETCHECK, _this->m_pOpt->m_fAutoScaling, 0);

        HWND hProxy = GetDlgItem(hwnd, IDC_PROXY_CHECK);
        SendMessage(hProxy, BM_SETCHECK, _this->m_pOpt->m_fUseProxy, 0);


        // sf@2002 - Select Modem Option as default
        _this->SetQuickOption(_this, hwnd);

        _this->m_fFromOptions = false;
        _this->m_fFromFile = false;

        return TRUE;
    }

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDC_DELETE:
        {
            char optionfile[MAX_PATH];
            char *tempvar=NULL;
            tempvar = getenv( "TEMP" );
            if (tempvar) strcpy(optionfile,tempvar);
            else strcpy(optionfile,"");
            strcat(optionfile,"\\options.vnc");
            DeleteFile(optionfile);
        }
        return TRUE;

        case IDSAVE:
            _this->m_pCC->saved_set=true;
        case IDOK:
        {
            TCHAR tmphost[256];
            TCHAR display[256];
            TCHAR fulldisplay[256];

            // sf@2005

            GetDlgItemText(hwnd, IDC_HOSTNAME_EDIT, display, 256);
            _tcscpy(fulldisplay, display);
            if (!ParseDisplay(display, tmphost, 255, &_this->m_port)) {
                MessageBox(NULL,
                           sz_F8,
                           sz_F10, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
            } else {
                _tcscpy(_this->m_host_dialog, tmphost);
                _this->m_pMRU->AddItem(fulldisplay);
//				_tcscpy(_this->m_remotehost, fulldisplay);
                EndDialog(hwnd, TRUE);
            }

            GetDlgItemText(hwnd, IDC_PROXY_EDIT, display, 256);
            _tcscpy(fulldisplay, display);
            if (!ParseDisplay(display, tmphost, 255, &_this->m_proxyport)) {
                MessageBox(NULL,
                           sz_F8,
                           sz_F10, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
            } else {
                _tcscpy(_this->m_proxyhost, tmphost);
                EndDialog(hwnd, TRUE);
            }

            HWND hProxy = GetDlgItem(hwnd, IDC_PROXY_CHECK);
            if (SendMessage(hProxy, BM_GETCHECK, 0, 0) == BST_CHECKED)
            {
                _this->m_pOpt->m_fUseProxy = true;
                _this->m_fUseProxy = true;
            }
            else
            {
                _this->m_pOpt->m_fUseProxy = false;
                _this->m_fUseProxy = false;
            }

            // sf@2002 - DSMPlugin loading
            // If Use plugin is checked, load the plugin if necessary
            HWND hPlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
            if (SendMessage(hPlugin, BM_GETCHECK, 0, 0) == BST_CHECKED)
            {
                TCHAR szPlugin[MAX_PATH];
                GetDlgItemText(hwnd, IDC_PLUGINS_COMBO, szPlugin, MAX_PATH);
                _this->m_pOpt->m_fUseDSMPlugin = true;
                strcpy(_this->m_pOpt->m_szDSMPluginFilename, szPlugin);

                if (!_this->m_pDSMPlugin->IsLoaded())
                {
                    _this->m_pDSMPlugin->LoadPlugin(szPlugin, _this->m_pOpt->m_listening);
                    if (_this->m_pDSMPlugin->IsLoaded())
                    {
                        if (_this->m_pDSMPlugin->InitPlugin())
                        {
                            _this->m_pDSMPlugin->SetEnabled(true);
                            _this->m_pDSMPlugin->DescribePlugin();
                        }
                        else
                        {
                            _this->m_pDSMPlugin->SetEnabled(false);
                            MessageBox(NULL,
                                       sz_F7,
                                       sz_F6, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
                            return TRUE;
                        }
                    }
                    else
                    {
                        _this->m_pDSMPlugin->SetEnabled(false);
                        MessageBox(NULL,
                                   sz_F5,
                                   sz_F6, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
                        return TRUE;
                    }
                }
                else
                {
                    // sf@2003 - If the plugin is already loaded here it has been loaded
                    // by clicking on the config button: we need to init it !
                    // But we must first check that the loaded plugin is the same that
                    // the one currently selected...
                    _this->m_pDSMPlugin->DescribePlugin();
                    if (_stricmp(_this->m_pDSMPlugin->GetPluginFileName(), szPlugin))
                    {
                        // Unload the previous plugin
                        _this->m_pDSMPlugin->UnloadPlugin();
                        // Load the new selected one
                        _this->m_pDSMPlugin->LoadPlugin(szPlugin, _this->m_pOpt->m_listening);
                    }

                    if (_this->m_pDSMPlugin->IsLoaded())
                    {
                        if (_this->m_pDSMPlugin->InitPlugin())
                        {
                            _this->m_pDSMPlugin->SetEnabled(true);
                            _this->m_pDSMPlugin->DescribePlugin();
                        }
                        else
                        {
                            _this->m_pDSMPlugin->SetEnabled(false);
                            MessageBox(NULL,
                                       sz_F7,
                                       sz_F6, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
                            return TRUE;
                        }
                    }
                    else
                    {
                        _this->m_pDSMPlugin->SetEnabled(false);
                        MessageBox(NULL,
                                   sz_F5,
                                   sz_F6, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
                        return TRUE;
                    }
                }
            }
            else // If Use plugin unchecked but the plugin is loaded, unload it
            {
                _this->m_pOpt->m_fUseDSMPlugin = false;
                if (_this->m_pDSMPlugin->IsEnabled())
                {
                    _this->m_pDSMPlugin->UnloadPlugin();
                    _this->m_pDSMPlugin->SetEnabled(false);
                }
            }

            if (_this->m_fFromOptions || _this->m_fFromFile)
            {
                EndDialog(hwnd, TRUE);
                return TRUE;
            }

            // sf@2002 - Quick options handling
            _this->ManageQuickOptions(_this, hwnd);

            HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY_CHECK);
            _this->m_pOpt->m_ViewOnly = (SendMessage(hViewOnly, BM_GETCHECK, 0, 0) == BST_CHECKED);

            HWND hAutoScaling = GetDlgItem(hwnd, IDC_AUTOSCALING_CHECK);
            _this->m_pOpt->m_fAutoScaling = (SendMessage(hAutoScaling, BM_GETCHECK, 0, 0) == BST_CHECKED);

            EndDialog(hwnd, TRUE);
            return TRUE;
        }

        case IDCANCEL:
            EndDialog(hwnd, FALSE);
            return TRUE;

        case IDC_OPTIONBUTTON:
        {
            if (!_this->m_fFromFile)
            {
                _this->ManageQuickOptions(_this, hwnd);

                HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY_CHECK);
                _this->m_pOpt->m_ViewOnly = (SendMessage(hViewOnly, BM_GETCHECK, 0, 0) == BST_CHECKED);

                HWND hAutoScaling = GetDlgItem(hwnd, IDC_AUTOSCALING_CHECK);
                _this->m_pOpt->m_fAutoScaling = (SendMessage(hAutoScaling, BM_GETCHECK, 0, 0) == BST_CHECKED);

            }

            _this->m_pOpt->DoDialog();
            _this->m_fFromOptions = true;

            return TRUE;
        }

        // sf@2002
        case IDC_PLUGIN_CHECK:
        {
            HWND hUse = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
            BOOL enable = SendMessage(hUse, BM_GETCHECK, 0, 0) == BST_CHECKED;
            HWND hButton = GetDlgItem(hwnd, IDC_PLUGIN_BUTTON);
            EnableWindow(hButton, enable);
        }
        return TRUE;


        case IDC_PLUGIN_BUTTON:
        {
            HWND hPlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
            if (SendMessage(hPlugin, BM_GETCHECK, 0, 0) == BST_CHECKED)
            {
                TCHAR szPlugin[MAX_PATH];
                GetDlgItemText(hwnd, IDC_PLUGINS_COMBO, szPlugin, MAX_PATH);
                // sf@2003 - The config button can be clicked several times with
                // different selected plugins...
                bool fLoadIt = true;
                char szParams[32];
                strcpy(szParams, sz_F4);
                // If a plugin is already loaded, check if it is the same that the one
                // we want to load.
                if (_this->m_pDSMPlugin->IsLoaded())
                {
                    _this->m_pDSMPlugin->DescribePlugin();
                    if (!_stricmp(_this->m_pDSMPlugin->GetPluginFileName(), szPlugin))
                    {
                        fLoadIt = false;
                        _this->m_pDSMPlugin->SetPluginParams(hwnd, szParams);
                    }
                    else
                    {
                        // Unload the previous plugin
                        _this->m_pDSMPlugin->UnloadPlugin();
                        fLoadIt = true;
                    }
                }

                if (!fLoadIt) return TRUE;

                if (_this->m_pDSMPlugin->LoadPlugin(szPlugin, _this->m_pOpt->m_listening))
                {
                    // We don't know the password yet... no matter the plugin requires
                    // it or not, we will provide it later (at plugin "real" startup)
                    // Knowing the environnement ("viewer") right now can be usefull or
                    // even mandatory for the plugin (specific params saving and so on...)
                    // The plugin receives environnement info but isn't inited at this point
                    _this->m_pDSMPlugin->SetPluginParams(hwnd, szParams);
                }
                else
                {
                    MessageBox(NULL,
                               sz_F1,
                               sz_F3, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST);
                }
            }
            return TRUE;
        }

        case IDC_LOADPROFILE_B:
        {
            TCHAR szFileName[MAX_PATH];
            memset(szFileName, '\0', MAX_PATH);
            if (_this->m_pCC->LoadConnection(szFileName, true,false) != -1)
            {
                TCHAR szHost[128];
                if (_this->m_pCC->m_port == 5900)
                    _tcscpy(szHost, _this->m_pCC->m_host);
                else if (_this->m_pCC->m_port > 5900 && _this->m_pCC->m_port <= 5999)
                    _stprintf(szHost, TEXT("%s:%d"), _this->m_pCC->m_host, _this->m_pCC->m_port - 5900);
                else
                    _stprintf(szHost, TEXT("%s::%d"), _this->m_pCC->m_host, _this->m_pCC->m_port);

                SetDlgItemText(hwnd, IDC_HOSTNAME_EDIT, szHost);
                //AaronP
                HWND hPlugins = GetDlgItem(hwnd, IDC_PLUGINS_COMBO);
                if( strcmp( _this->m_pOpt->m_szDSMPluginFilename, "" ) != 0 && _this->m_pOpt->m_fUseDSMPlugin ) {
                    int pos = SendMessage(hPlugins, CB_FINDSTRINGEXACT, -1,
                                          (LPARAM)&(_this->m_pOpt->m_szDSMPluginFilename[0]));

                    if( pos != CB_ERR ) {
                        SendMessage(hPlugins, CB_SETCURSEL, pos, 0);
                        HWND hUsePlugin = GetDlgItem(hwnd, IDC_PLUGIN_CHECK);
                        SendMessage(hUsePlugin, BM_SETCHECK, TRUE, 0);
                    }
                }
                //EndAaronP
            }
            SetFocus(GetDlgItem(hwnd, IDC_HOSTNAME_EDIT));
            _this->SetQuickOption(_this, hwnd);

            HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY_CHECK);
            SendMessage(hViewOnly, BM_SETCHECK, _this->m_pOpt->m_ViewOnly, 0);

            HWND hAutoScaling = GetDlgItem(hwnd, IDC_AUTOSCALING_CHECK);
            SendMessage(hAutoScaling, BM_SETCHECK, _this->m_pOpt->m_fAutoScaling, 0);

            _this->m_fFromOptions = true;
            _this->m_fFromFile = true;
            return TRUE;
        }

        }

        break;

    case WM_DESTROY:
        EndDialog(hwnd, FALSE);
        return TRUE;
    }
    return 0;
}
コード例 #12
0
ファイル: mcdr.cpp プロジェクト: msdsgn/mcdr
/* ======================================================================= */
void Initialise(HINSTANCE *Instance)
{
  ProcessMutex = CreateMutex(0, 1, WindowName);
  if(ProcessMutex == NULL)
    Exception(__LINE__, GetLastError(), "Failed to create mutex object");
  if(GetLastError() == ERROR_ALREADY_EXISTS)
    Exception(__LINE__, GetLastError(), "Another instance of %s is already running. Please wait for it to terminate, click the icon in the taskbar and click terminate or kill the process through the Windows Task Manager", WindowName);

  char **ArgumentsPointer;
  // Walk arguments array
  for(ArgumentsPointer = __argv + 1; *ArgumentsPointer; ++ArgumentsPointer)
  {
    // First character not forward slash
    if(**ArgumentsPointer != 47)
      // Not valid switch character, so bail
      Exception(0, 0, "The switch character '%c' is unrecognised. Please use the '/' character to denote the beginning of an option", **ArgumentsPointer);
    // Compare character after slash
    switch(*(++*ArgumentsPointer))
    {
      // Encoding quality
      case 'q': Quality = Clamp(atoi(++*ArgumentsPointer), 0, 9); break;
      // Enable logging
      case 'l': Log(LOG_OPEN, NULL); break;
      // Enable one-track-only mp3
      case 'o': OneTrackOnly = 1; break;
      // Set CBR quality and bitrate
      case 'b': MP3Quality = Clamp(atoi(++*ArgumentsPointer), ABR_8, ABR_320); break;
      // Set VBR quality
      case 'v': MP3Quality = Clamp(atoi(++*ArgumentsPointer), 0, 9); MP3Quality = VBR_10+(MP3Quality*10); break;
      // Version information
      case '!': Exception(0, 0, "%s; Version %u.%02u (%u-bit) compiled %s.\nCopyright © MS-Design, 2011. http://github.com/msdsgn/mcdr.\n\nUses LAME audio encoder -- http://lame.sourceforge.net/", WindowName, VersionMajor, VersionMinor, VersionBits, VersionDate);
      // Bail on un-supported or invalid parameters
      default : Exception(0, 0, "The parameter '%c' is unrecognised", **ArgumentsPointer);
    }
  }

  Log(LOG_WRITE, "%s %u.%02u (%u-bit); %s", WindowName, VersionMajor, VersionMinor, VersionBits, VersionDate);

  Log(LOG_WRITE, "* MP3 Quality = %d", MP3Quality);
  Log(LOG_WRITE, "* Encoding Quality = %d", Quality);
  Log(LOG_WRITE, "* One Track Only = %d", OneTrackOnly);

  INITCOMMONCONTROLSEX iccData;

  iccData.dwSize = sizeof(iccData);
  iccData.dwICC = ICC_PROGRESS_CLASS;

  if(InitCommonControlsEx(&iccData) == FALSE)
    Exception(__LINE__, GetLastError(), "Error code %u initialising common controls", iccData.dwICC);

  memset(&WindowClass, 0, sizeof(WindowClass));
  WindowClass.cbSize = sizeof(WindowClass);
  WindowClass.style = CS_HREDRAW | CS_VREDRAW;
  WindowClass.lpfnWndProc = (WNDPROC)WinProc;
  WindowClass.hInstance = *Instance;
  WindowClass.hIcon = (HICON)LoadImage(WindowClass.hInstance, MAKEINTRESOURCE(1), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
  WindowClass.hIconSm = (HICON)LoadImage(WindowClass.hInstance, MAKEINTRESOURCE(1), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
  WindowClass.hCursor = LoadCursor(0, IDC_ARROW);
  WindowClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
  WindowClass.lpszClassName = WindowName;
  if(!RegisterClassEx(&WindowClass))
    Exception(__LINE__, GetLastError(), "Failed to register window class");

  WindowFont = CreateFont(13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "MS Shell Dlg");
  if(WindowFont == NULL)
    Exception(__LINE__, GetLastError(), "Failed to create shell dialog font");

  RECT D;
  GetWindowRect(GetDesktopWindow(), &D);

  Handles.WH = CreateWindowEx(WS_EX_APPWINDOW, WindowClass.lpszClassName, WindowClass.lpszClassName, WS_POPUP | WS_DLGFRAME | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, 0, 0, 320, 260, NULL, NULL, WindowClass.hInstance, NULL);
  if(Handles.WH == NULL)
    Exception(__LINE__, GetLastError(), "Failed to load window");

  Handles.WT = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE, 52, 10, 248, 48, Handles.WH, NULL, WindowClass.hInstance, NULL);
  if(Handles.WT == NULL)
    Exception(__LINE__, GetLastError(), "Failed to create window text object");
  SendMessage(Handles.WT, WM_SETFONT, (WPARAM)WindowFont, 0);

  Handles.PO = CreateWindowEx(0, "msctls_progress32", NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 10, 60, 294, 24, Handles.WH, NULL, WindowClass.hInstance, NULL);
  if(Handles.PO == NULL)
    Exception(__LINE__, GetLastError(), "Failed to create progress bar one object");

  Handles.PA = CreateWindowEx(0, "msctls_progress32", NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 10, 98, 294, 24, Handles.WH, NULL, WindowClass.hInstance, NULL);
  if(Handles.PA == NULL)
    Exception(__LINE__, GetLastError(), "Failed to create progress bar all object");

  Handles.WC = CreateWindowEx(0, "Button", "&Cancel", WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 10, 136, 64, 24, Handles.WH, (HMENU)1, WindowClass.hInstance, NULL);
  if(Handles.WC == NULL)
    Exception(__LINE__, GetLastError(), "Failed to create cancel button object");
  SendMessage(Handles.WC, WM_SETFONT, (WPARAM)WindowFont, 0);

  Handles.WI = CreateWindowEx(0, "STATIC", NULL, WS_CHILD | WS_VISIBLE | SS_ICON, 10, 10, 32, 32, Handles.WH, NULL, WindowClass.hInstance, NULL);
  if(Handles.WI == NULL)
    Exception(__LINE__, GetLastError(), "Failed to create icon object");

  Handles.WA = CreateWindowEx(0, "STATIC", "", WS_CHILD | WS_VISIBLE | WS_DISABLED | SS_RIGHT, 80, 134, 224, 32, Handles.WH, NULL, WindowClass.hInstance, NULL);
  if(Handles.WA == NULL)
    Exception(__LINE__, GetLastError(), "Failed to create about text object");
  SendMessage(Handles.WA, WM_SETFONT, (WPARAM)WindowFont, 0);

  Handles.WB = CreateWindowEx(WS_EX_STATICEDGE, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_BITMAP, 9, 174, 294, 48, Handles.WH, NULL, WindowClass.hInstance, NULL);
  if(Handles.WB == NULL)
    Exception(__LINE__, GetLastError(), "Failed to create bitmap object");

  SendMessage(Handles.WI, STM_SETICON, (WPARAM)WindowClass.hIcon, NULL);
  WindowBitmap = (HBITMAP)LoadImage(WindowClass.hInstance, MAKEINTRESOURCE(1), IMAGE_BITMAP, 294, 48, LR_DEFAULTCOLOR);
  if(WindowBitmap == NULL)
    Exception(__LINE__, GetLastError(), "Failed to load window bitmap");
  SendMessage(Handles.WB, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)WindowBitmap);

  SetLabel(Handles.WA, "M-CDR %u.%02u (%u-bit) %s\nCopyright © MS-Design, 2011", VersionMajor, VersionMinor, VersionBits, VersionDate);

  ThreadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadMain, &Handles, 0, NULL);
  if(ThreadHandle == NULL)
    Exception(__LINE__, GetLastError(), "Error creating thread");

  CentreWindow(Handles.WH);
  ShowWindow(Handles.WH, SW_SHOW);
  SetForegroundWindow(Handles.WH);
  SetFocus(Handles.WC);
}
コード例 #13
0
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;
			// Initialise the controls
			for (int i = rfbEncodingRaw; i <= LASTENCODING; i++) {
				HWND hPref = GetDlgItem(hwnd, IDC_RAWRADIO + (i-rfbEncodingRaw));
				SendMessage(hPref, BM_SETCHECK, 
					(i== _this->m_PreferredEncoding), 0);
				EnableWindow(hPref, _this->m_UseEnc[i]);
			}
			
			HWND hCopyRect = GetDlgItem(hwnd, ID_SESSION_SET_CRECT);
			SendMessage(hCopyRect, BM_SETCHECK, _this->m_UseEnc[rfbEncodingCopyRect], 0);
			
			HWND hSwap = GetDlgItem(hwnd, ID_SESSION_SWAPMOUSE);
			SendMessage(hSwap, BM_SETCHECK, _this->m_SwapMouse, 0);
			
			HWND hDeiconify = GetDlgItem(hwnd, IDC_BELLDEICONIFY);
			SendMessage(hDeiconify, BM_SETCHECK, _this->m_DeiconifyOnBell, 0);

#ifndef UNDER_CE
			HWND hDisableClip = GetDlgItem(hwnd, IDC_DISABLECLIPBOARD);
			SendMessage(hDisableClip, BM_SETCHECK, _this->m_DisableClipboard, 0);
#endif			
			
			HWND h8bit = GetDlgItem(hwnd, IDC_8BITCHECK);
			SendMessage(h8bit, BM_SETCHECK, _this->m_Use8Bit, 0);
			
			HWND hShared = GetDlgItem(hwnd, IDC_SHARED);
			SendMessage(hShared, BM_SETCHECK, _this->m_Shared, 0);
			EnableWindow(hShared, !_this->m_running);
			 
			HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY);
			SendMessage(hViewOnly, BM_SETCHECK, _this->m_ViewOnly, 0);


			HWND hScaling = GetDlgItem(hwnd, IDC_SCALING);
			SendMessage(hScaling, BM_SETCHECK, _this->m_scaling, 0);

			SetDlgItemInt( hwnd, IDC_SCALE_NUM, _this->m_scale_num, FALSE);
			SetDlgItemInt( hwnd, IDC_SCALE_DEN, _this->m_scale_den, FALSE);

#ifndef UNDER_CE
			HWND hFullScreen = GetDlgItem(hwnd, IDC_FULLSCREEN);
			SendMessage(hFullScreen, BM_SETCHECK, _this->m_FullScreen, 0);

 			HWND hEmulate = GetDlgItem(hwnd, IDC_EMULATECHECK);
 			SendMessage(hEmulate, BM_SETCHECK, _this->m_Emul3Buttons, 0);
#endif

			CentreWindow(hwnd);
			
			return TRUE;
		}
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDOK:
			{
				for (int i = rfbEncodingRaw; i <= LASTENCODING; i++) {
					HWND hPref = GetDlgItem(hwnd, IDC_RAWRADIO+i-rfbEncodingRaw);
					if (SendMessage(hPref, BM_GETCHECK, 0, 0) == BST_CHECKED)
						_this->m_PreferredEncoding = i;
				}
				
				HWND hCopyRect = GetDlgItem(hwnd, ID_SESSION_SET_CRECT);
				_this->m_UseEnc[rfbEncodingCopyRect] =
					(SendMessage(hCopyRect, BM_GETCHECK, 0, 0) == BST_CHECKED);
				
				HWND hSwap = GetDlgItem(hwnd, ID_SESSION_SWAPMOUSE);
				_this->m_SwapMouse =
					(SendMessage(hSwap, BM_GETCHECK, 0, 0) == BST_CHECKED);
				
				HWND hDeiconify = GetDlgItem(hwnd, IDC_BELLDEICONIFY);
				_this->m_DeiconifyOnBell =
					(SendMessage(hDeiconify, BM_GETCHECK, 0, 0) == BST_CHECKED);
#ifndef UNDER_CE				
				HWND hDisableClip = GetDlgItem(hwnd, IDC_DISABLECLIPBOARD);
				_this->m_DisableClipboard =
					(SendMessage(hDisableClip, BM_GETCHECK, 0, 0) == BST_CHECKED);
#endif

				HWND h8bit = GetDlgItem(hwnd, IDC_8BITCHECK);
				_this->m_Use8Bit =
					(SendMessage(h8bit, BM_GETCHECK, 0, 0) == BST_CHECKED);
				
				HWND hShared = GetDlgItem(hwnd, IDC_SHARED);
				_this->m_Shared =
					(SendMessage(hShared, BM_GETCHECK, 0, 0) == BST_CHECKED);
				
				HWND hViewOnly = GetDlgItem(hwnd, IDC_VIEWONLY);
				_this->m_ViewOnly = 
					(SendMessage(hViewOnly, BM_GETCHECK, 0, 0) == BST_CHECKED);

				HWND hScaling = GetDlgItem(hwnd, IDC_SCALING);
				_this->m_scaling = 
					(SendMessage(hScaling, BM_GETCHECK, 0, 0) == BST_CHECKED);

				if (_this->m_scaling) {
					_this->m_scale_num = GetDlgItemInt( hwnd, IDC_SCALE_NUM, NULL, TRUE);
					_this->m_scale_den = GetDlgItemInt( hwnd, IDC_SCALE_DEN, NULL, TRUE);
					_this->FixScaling();
					if (_this->m_scale_num == 1 && _this->m_scale_den == 1)
						_this->m_scaling = false;
				} else {
					_this->m_scale_num = 1;
					_this->m_scale_den = 1;
				}

#ifndef UNDER_CE
				HWND hFullScreen = GetDlgItem(hwnd, IDC_FULLSCREEN);
				_this->m_FullScreen = 
					(SendMessage(hFullScreen, BM_GETCHECK, 0, 0) == BST_CHECKED);

 				HWND hEmulate = GetDlgItem(hwnd, IDC_EMULATECHECK);
 				_this->m_Emul3Buttons =
				  (SendMessage(hEmulate, BM_GETCHECK, 0, 0) == BST_CHECKED);
#endif

				EndDialog(hwnd, TRUE);
				
				return TRUE;
			}
		case IDCANCEL:
			EndDialog(hwnd, FALSE);
			return TRUE;
		}
		break;
        case WM_DESTROY:
			EndDialog(hwnd, FALSE);
			return TRUE;
	}
	return 0;
}