Exemple #1
0
//游戏开始
bool CGameClientDlg::OnSubGameStart(const void * pBuffer, WORD wDataSize)
{
	//效验数据
	ASSERT(wDataSize==sizeof(CMD_S_GameStart));
	if (wDataSize!=sizeof(CMD_S_GameStart)) 
		return false;

	//变量定义
	CMD_S_GameStart * pGameStart=(CMD_S_GameStart *)pBuffer;

	//设置状态
	SetGameStatus(GS_MJ_PLAY);
	m_GameClientView.m_ScoreControl.RestorationData();
	m_GameClientView.SetCurrentUser(INVALID_CHAIR);

	//设置变量
	m_bHearStatus=false;
	m_bWillHearStatus=false;
	m_wBankerUser=pGameStart->wBankerUser;
	m_wCurrentUser=pGameStart->wCurrentUser;
	m_cbLeftCardCount=MAX_REPERTORY-GAME_PLAYER*(MAX_COUNT-1)-1;

	//出牌信息
	m_cbOutCardData=0;
	m_wOutCardUser=INVALID_CHAIR;
	ZeroMemory(m_cbDiscardCard,sizeof(m_cbDiscardCard));
	ZeroMemory(m_cbDiscardCount,sizeof(m_cbDiscardCount));

	//组合扑克
	ZeroMemory(m_cbWeaveCount,sizeof(m_cbWeaveCount));
	ZeroMemory(m_WeaveItemArray,sizeof(m_WeaveItemArray));

	//设置扑克
	BYTE cbCardCount=(GetMeChairID()==m_wBankerUser)?MAX_COUNT:(MAX_COUNT-1);
	m_GameLogic.SwitchToCardIndex(pGameStart->cbCardData,cbCardCount,m_cbCardIndex);

	//设置界面
	bool bPlayerMode=(IsLookonMode()==false);
	m_GameClientView.SetUserListenStatus(INVALID_CHAIR,false);
	m_GameClientView.m_HandCardControl.SetPositively(bPlayerMode);
	m_GameClientView.SetBankerUser(SwitchViewChairID(m_wBankerUser));
	m_GameClientView.SetDiscUser(INVALID_CHAIR);

	//旁观界面
	if (bPlayerMode==false)
	{
		m_GameClientView.SetHuangZhuang(false);
		m_GameClientView.SetStatusFlag(false,false);
		m_GameClientView.SetUserAction(INVALID_CHAIR,0);
		m_GameClientView.SetOutCardInfo(INVALID_CHAIR,0);
	}

	//堆立扑克
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		m_cbHeapCardInfo[i][0]=0;
		m_cbHeapCardInfo[i][1]=0;
	}

	//分发扑克
	BYTE cbTakeCount=(MAX_COUNT-1)*GAME_PLAYER+1;
	BYTE cbSiceFirst=HIBYTE(pGameStart->wSiceCount);
	BYTE cbSiceSecond=LOBYTE(pGameStart->wSiceCount);
	WORD wTakeChairID=(m_wBankerUser+7-cbSiceFirst)%GAME_PLAYER;
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//计算数目
		BYTE cbValidCount=HEAP_FULL_COUNT-m_cbHeapCardInfo[wTakeChairID][1]-((i==0)?(cbSiceSecond-1)*2:0);
		BYTE cbRemoveCount=__min(cbValidCount,cbTakeCount);

		//提取扑克
		cbTakeCount-=cbRemoveCount;
		m_cbHeapCardInfo[wTakeChairID][(i==0)?1:0]+=cbRemoveCount;

		//完成判断
		if (cbTakeCount==0)
		{
			m_wHeapHand=wTakeChairID;
			m_wHeapTail=(m_wBankerUser+7-cbSiceFirst)%GAME_PLAYER;
			break;
		}

		//切换索引
		wTakeChairID=(wTakeChairID+1)%GAME_PLAYER;
	}

	//扑克设置
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wViewChairID=SwitchViewChairID(i);

		//组合界面
		m_GameClientView.m_WeaveCard[i][0].SetDisplayItem(true);
		m_GameClientView.m_WeaveCard[i][1].SetDisplayItem(true);
		m_GameClientView.m_WeaveCard[i][2].SetDisplayItem(true);
		m_GameClientView.m_WeaveCard[i][3].SetDisplayItem(true);
		m_GameClientView.m_HeapCard[wViewChairID].SetCardData(m_cbHeapCardInfo[i][0],m_cbHeapCardInfo[i][1],HEAP_FULL_COUNT);

		//用户扑克
		if (wViewChairID!=2)
		{
			WORD wIndex=(wViewChairID>=3)?2:wViewChairID;
			m_GameClientView.m_UserCard[wIndex].SetCardData(CountArray(pGameStart->cbCardData)-1,(i==m_wBankerUser));
		}
		else
		{
			BYTE cbBankerCard=(i==m_wBankerUser)?pGameStart->cbCardData[MAX_COUNT-1]:0;
			m_GameClientView.m_HandCardControl.SetCardData(pGameStart->cbCardData,MAX_COUNT-1,cbBankerCard);
		}

		//旁观界面
		if (bPlayerMode==false)
		{
			m_GameClientView.m_TableCard[wViewChairID].SetCardData(NULL,0);
			m_GameClientView.m_DiscardCard[wViewChairID].SetCardData(NULL,0);
			m_GameClientView.m_WeaveCard[wViewChairID][0].SetCardData(NULL,0);
			m_GameClientView.m_WeaveCard[wViewChairID][1].SetCardData(NULL,0);
			m_GameClientView.m_WeaveCard[wViewChairID][2].SetCardData(NULL,0);
			m_GameClientView.m_WeaveCard[wViewChairID][3].SetCardData(NULL,0);
		}
	}

	//出牌提示
	if ((bPlayerMode==true)&&(m_wCurrentUser!=INVALID_CHAIR))
	{
		WORD wMeChairID=GetMeChairID();
		if (m_wCurrentUser==wMeChairID) m_GameClientView.SetStatusFlag(true,false);
	}

	//动作处理
	if ((bPlayerMode==true)&&(pGameStart->cbUserAction!=WIK_NULL))
	{

		ShowOperateControl(pGameStart->cbUserAction,0);
		SetGameTimer(GetMeChairID(),IDI_OPERATE_CARD,TIME_OPERATE_CARD);
	}

	//更新界面
	m_GameClientView.UpdateGameView(NULL);

	//激活框架
	if (bPlayerMode==true)
		ActiveGameFrame();

	//环境处理
		PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_START"));


	//设置时间
	if (m_wCurrentUser!=INVALID_CHAIR)
	{
		m_GameClientView.SetCurrentUser(SwitchViewChairID(m_wCurrentUser));
		SetGameTimer(m_wCurrentUser,IDI_OPERATE_CARD,TIME_OPERATE_CARD);
	}
	//托管设置
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		m_GameClientView.SetTrustee(SwitchViewChairID(i),pGameStart->bTrustee[i]);
	}

	return true;
}
Exemple #2
0
int CVSFilterApp::ExitInstance()
{
	DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_DETACH, 0); // "DllMain" of the dshow baseclasses

	return CWinApp::ExitInstance();
}
void CDlgShowPrivateKeyEC::UpdateEcListBox()
{
	unsigned int bitlength;

	m_dom_param_listview.DeleteAllItems(); // Delete all data in the listview
// == EC curve parameter a, b, p
	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_SEPERATOR,pc_str,STR_LAENGE_STRING_TABLE);
	m_dom_param_listview.InsertItem( 0, pc_str );
	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_DESCRIPTION,pc_str,STR_LAENGE_STRING_TABLE);
	m_dom_param_listview.SetItemText( 0, 1, pc_str );
	m_dom_param_listview.InsertItem( 1, "a" );
	m_dom_param_listview.SetItemText( 1, 1, ecParamString.a );
	bitlength = theApp.SecudeLib.lngtouse(curveParameter->E->a);
	_itoa(bitlength+1, pc_str, 10);
	m_dom_param_listview.SetItemText( 2, 2, pc_str ); // Bitlänge von a
	m_dom_param_listview.InsertItem( 2, "b" );
	m_dom_param_listview.SetItemText( 2, 1, ecParamString.b );
	bitlength = theApp.SecudeLib.lngtouse(curveParameter->E->b);
	_itoa(bitlength+1, pc_str, 10);
	m_dom_param_listview.SetItemText( 2, 2, pc_str ); // Bitlänge von b
	m_dom_param_listview.InsertItem( 3, "p" );
	m_dom_param_listview.SetItemText( 3, 1, ecParamString.p );
	bitlength = theApp.SecudeLib.lngtouse(curveParameter->E->p);
	_itoa(bitlength+1, pc_str, 10);
	m_dom_param_listview.SetItemText( 3, 2, pc_str ); // Bitlänge von p
// == EC curve point G = (x,y)
	m_dom_param_listview.InsertItem( 4, " " );
	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_SEPERATOR,pc_str,STR_LAENGE_STRING_TABLE);
	m_dom_param_listview.InsertItem( 5, pc_str );
	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_POINT_DESCRIPTION,pc_str,STR_LAENGE_STRING_TABLE);
	m_dom_param_listview.SetItemText( 5, 1, pc_str );
	m_dom_param_listview.InsertItem( 6, "x" );
	m_dom_param_listview.SetItemText( 6, 1, ecParamString.G_xcoord );
	bitlength = theApp.SecudeLib.lngtouse(curveParameter->G->x);
	_itoa(bitlength+1, pc_str, 10);
	m_dom_param_listview.SetItemText( 6, 2, pc_str ); // Bitlänge von x coord of G
	m_dom_param_listview.InsertItem( 7, "y" );
	m_dom_param_listview.SetItemText( 7, 1, ecParamString.G_ycoord );
	bitlength = theApp.SecudeLib.lngtouse(curveParameter->G->y);
	_itoa(bitlength+1, pc_str, 10);
	m_dom_param_listview.SetItemText( 7, 2, pc_str ); // Bitlänge von y coord of G
// == EC kofactor k, the prime number r is the order of G
	m_dom_param_listview.InsertItem( 8, " " );
	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_SEPERATOR,pc_str,STR_LAENGE_STRING_TABLE);
	m_dom_param_listview.InsertItem( 9, pc_str );
	LoadString(AfxGetInstanceHandle(),IDS_STRING_KF_ORD_DESCRIPTION,pc_str,STR_LAENGE_STRING_TABLE);
	m_dom_param_listview.SetItemText( 9, 1, pc_str );
	m_dom_param_listview.InsertItem( 10, "k" );
	m_dom_param_listview.SetItemText( 10, 1, ecParamString.k );
	bitlength = theApp.SecudeLib.lngtouse(curveParameter->k);
	_itoa(bitlength+1, pc_str, 10);
	m_dom_param_listview.SetItemText( 10, 2, pc_str ); // Bitlänge von k
	m_dom_param_listview.InsertItem( 11, "r" );
	m_dom_param_listview.SetItemText( 11, 1, ecParamString.r );
	bitlength = theApp.SecudeLib.lngtouse(curveParameter->r);
	_itoa(bitlength+1, pc_str, 10);
	m_dom_param_listview.SetItemText( 11, 2, pc_str ); // Bitlänge von r
	m_dom_param_listview.InsertItem( 12, " " );

	m_pubKey_listview.DeleteAllItems(); // Delete all data in the listview
	m_pubKey_listview.InsertItem( 0, " ");
	m_pubKey_listview.InsertItem( 1, ((CString)"x = ") + ecParamString.pubKey_xcoord);
	bitlength = theApp.SecudeLib.lngtouse(curveParameter->pubKey->x);
	_itoa(bitlength+1, pc_str, 10);
	m_pubKey_listview.SetItemText( 1, 1, pc_str ); // Bitlänge von x
	m_pubKey_listview.InsertItem( 2, ((CString)"y = ") + ecParamString.pubKey_ycoord);
	bitlength = theApp.SecudeLib.lngtouse(curveParameter->pubKey->y);
	_itoa(bitlength+1, pc_str, 10);
	m_pubKey_listview.SetItemText( 2, 1, pc_str ); // Bitlänge von y
	m_pubKey_listview.InsertItem( 3, " ");

	m_privKey_listview.DeleteAllItems(); // Delete all data in the listview
	m_privKey_listview.InsertItem( 0, " ");
	m_privKey_listview.InsertItem( 1, ((CString)"s = ") + ecParamString.privKey);
	bitlength = theApp.SecudeLib.lngtouse(curveParameter->privKey);
	_itoa(bitlength+1, pc_str, 10);
	m_privKey_listview.SetItemText( 1, 1, pc_str ); // Bitlänge von s
	m_privKey_listview.InsertItem( 2, " ");
}
Exemple #4
0
BOOL CREditCtrl::CREditCtrlFactory::VerifyUserLicense()
{
	return AfxVerifyLicFile(AfxGetInstanceHandle(), _szLicFileName,
		_szLicString);
}
Exemple #5
0
BOOL CAdminControlApp::InitInstance()
{
//TODO: call AfxInitRichEdit2() to initialize richedit2 library.
	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。否则,将无法创建窗口。

	//崩溃开始处
// 	CR_INSTALL_INFO info = {0};  
// 	info.cb = sizeof(CR_INSTALL_INFO); 
// 	info.pszAppName = TEXT("AdminControl"); 
// 	info.pszAppVersion = TEXT("1.0.0");     
// 	info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS;  
// 	info.dwFlags |= CR_INST_DONT_SEND_REPORT;  
// 	info.dwFlags |= CR_INST_NO_GUI;
// 	info.pszErrorReportSaveDir = TEXT("./UMErrReport");  
// 
// 	// Install crash handlers
// 	int nInstResult = crInstall(&info);            
// 	//assert(nInstResult==0);
// 	if(nInstResult!=0)
// 	{
// 		TCHAR buff[256];
// 		crGetLastErrorMsg(buff, 256); // Get last error
// 		_tprintf(_T("%s\n"), buff); // and output it to the screen
// 		return 1;
// 	}

	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinAppEx::InitInstance();

	m_ParameterGlobal.LoadParameter();

	AfxEnableControlContainer();

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));

//	CAdminControlDlg dlg;
// 	CDlgLogin m_login;
// 	if (m_login.DoModal() != IDOK)
// 	{
// 		return FALSE;
// 	}
// 	m_MissionLogon.ShowLogon();
// 	
// 	m_pMainWnd = &dlg;
// 	INT_PTR nResponse = dlg.DoModal();
// 	if (nResponse == IDOK)
// 	{
// 		// TODO: 在此放置处理何时用
// 		//  “确定”来关闭对话框的代码
// 	}
// 	else if (nResponse == IDCANCEL)
// 	{
// 		// TODO: 在此放置处理何时用
// 		//  “取消”来关闭对话框的代码
// 	}
	const TCHAR szPlazaClass[]=TEXT("UM");
	WNDCLASS WndClasss;
	ZeroMemory(&WndClasss,sizeof(WndClasss));

	//注册窗口
	WndClasss.style=CS_DBLCLKS;
	WndClasss.hIcon=NULL;
	WndClasss.lpfnWndProc=DefWindowProc;
	WndClasss.lpszClassName=szPlazaClass;
	WndClasss.hInstance=AfxGetInstanceHandle();
	WndClasss.hCursor=LoadStandardCursor(MAKEINTRESOURCE(IDC_HAND_CUR));
	if (AfxRegisterClass(&WndClasss)==FALSE) AfxThrowResourceException();

	AfxInitRichEdit();
	//建立窗口
	CMyFrameWnd * pPlatformFrame=new CMyFrameWnd;
	pPlatformFrame->Create(szPlazaClass,szProduct,WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_SYSMENU,CRect(0,0,0,0));

	m_pMainWnd = pPlatformFrame;
	m_pMainWnd->ShowWindow(SW_HIDE);
	m_pMainWnd->UpdateWindow();
	// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
	//  而不是启动应用程序的消息泵。
	return TRUE;
}
Exemple #6
0
BOOL CAboutDlg::OnInitDialog()
{
    // Get the default text before it is overwritten by the call to __super::OnInitDialog()
    GetDlgItem(IDC_AUTHORS_LINK)->GetWindowText(m_credits);
#ifndef MPCHC_LITE
    GetDlgItem(IDC_LAVFILTERS_VERSION)->GetWindowText(m_LAVFiltersVersion);
#endif

    __super::OnInitDialog();

    // Because we set LR_SHARED, there is no need to explicitly destroy the icon
    m_icon.SetIcon((HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 48, 48, LR_SHARED));

    m_appname = _T("MPC-HC");
    if (VersionInfo::IsNightly() || VersionInfo::Is64Bit()) {
        m_appname += _T(" (");
    }
    if (VersionInfo::IsNightly()) {
        m_appname += VersionInfo::GetNightlyWord();
    }
    if (VersionInfo::IsNightly() && VersionInfo::Is64Bit()) {
        m_appname += _T(", ");
    }
    if (VersionInfo::Is64Bit()) {
        m_appname += _T("64-bit");
    }
    if (VersionInfo::IsNightly() || VersionInfo::Is64Bit()) {
        m_appname += _T(")");
    }

#ifdef MPCHC_LITE
    m_appname += _T(" Lite");
#endif

    // Build the path to Authors.txt
    m_AuthorsPath = GetProgramPath() + _T("Authors.txt");
    // Check if the file exists
    if (FileExists(m_AuthorsPath)) {
        // If it does, we make the filename clickable
        m_credits.Replace(_T("Authors.txt"), _T("<a>Authors.txt</a>"));
    }

    m_homepage.Format(_T("<a>%s</a>"), WEBSITE_URL);

    m_strBuildNumber = VersionInfo::GetFullVersionString();

#if defined(__INTEL_COMPILER)
#if (__INTEL_COMPILER >= 1210)
    m_MPCCompiler = _T("ICL ") MAKE_STR(__INTEL_COMPILER) _T(" Build ") MAKE_STR(__INTEL_COMPILER_BUILD_DATE);
#else
#error Compiler is not supported!
#endif
#elif defined(_MSC_VER)
#if (_MSC_VER == 1800)              // 2013
#if (_MSC_FULL_VER == 180030501)
    m_MPCCompiler = _T("MSVC 2013 Update 2");
#elif (_MSC_FULL_VER < 180021005)
    m_MPCCompiler = _T("MSVC 2013 Preview/Beta/RC");
#else
    m_MPCCompiler = _T("MSVC 2013");
#endif
#elif (_MSC_VER <= 1700)
#error Compiler is not supported!
#endif
#else
#error Please add support for your compiler
#endif

#if (__AVX__)
    m_MPCCompiler += _T(" (AVX)");
#elif (__SSSE3__)
    m_MPCCompiler += _T(" (SSSE3)");
#elif (__SSE3__)
    m_MPCCompiler += _T(" (SSE3)");
#elif !defined(_M_X64) && defined(_M_IX86_FP)
#if (_M_IX86_FP == 2)   // /arch:SSE2 was used
    m_MPCCompiler += _T(" (SSE2)");
#elif (_M_IX86_FP == 1) // /arch:SSE was used
    m_MPCCompiler += _T(" (SSE)");
#endif
#endif

#ifdef _DEBUG
    m_MPCCompiler += _T(" Debug");
#endif

    m_LAVFilters.Format(IDS_STRING_COLON, _T("LAV Filters"));
#ifndef MPCHC_LITE
    CString LAVFiltersVersion = CFGFilterLAV::GetVersion();
    if (!LAVFiltersVersion.IsEmpty()) {
        m_LAVFiltersVersion = LAVFiltersVersion;
    }
#endif

    m_buildDate = VersionInfo::GetBuildDateString();

    OSVERSIONINFOEX osVersion = SysVersion::GetFullVersion();
    m_OSName.Format(_T("Windows NT %1u.%1u (build %u"),
                    osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.dwBuildNumber);
    if (osVersion.szCSDVersion[0]) {
        m_OSName.AppendFormat(_T(", %s)"), osVersion.szCSDVersion);
    } else {
        m_OSName += _T(")");
    }
    m_OSVersion.Format(_T("%1u.%1u"), osVersion.dwMajorVersion, osVersion.dwMinorVersion);
    if (SysVersion::Is64Bit()) {
        m_OSVersion += _T(" (64-bit)");
    }

    UpdateData(FALSE);

    GetDlgItem(IDOK)->SetFocus();

    return FALSE;
}
BOOL CSaveDlg::OnInitDialog()
{
	CCmdUIDialog::OnInitDialog();

	AppSettings& s = AfxGetAppSettings();

	CString str, in = m_name, out = m_out;

	if (m_in.Find(_T("http://")) != -1 || m_in.Find(_T("ftp://")) != -1) {
		m_anim.SendMessage(ACM_OPEN, (WPARAM)AfxGetInstanceHandle(), (LPARAM)IDR_AVI_WEB_FILECOPY);
	} else {
		m_anim.SendMessage(ACM_OPEN, (WPARAM)AfxGetInstanceHandle(), (LPARAM)IDR_AVI_FILECOPY);
	}
	m_anim.Play(0, (UINT)-1, (UINT)-1);

	if (in.GetLength() > 60) {
		in = in.Left(17) + _T("..") + in.Right(43);
	}

	if (out.GetLength() > 60) {
		out = out.Left(17) + _T("..") + out.Right(43);
	}

	str.Format(_T("%s\r\n%s"), in, out);
	m_fromto.SetWindowText(str);

	m_progress.SetRange(0, 100);

	if (OpenImageCheck(m_in) && s.strSnapShotExt != _T(".*")) {
		OpenImageDIB(m_in, m_out, s.iThumbQuality, 0);
		EndDialog(IDOK);
		return TRUE;
	}

	if (FAILED(pGB.CoCreateInstance(CLSID_FilterGraph)) || !(pMC = pGB) || !(pME = pGB) || !(pMS = pGB)
			|| FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0))) {
		m_report.SetWindowText(_T("Error"));
		return FALSE;
	}

	HRESULT hr;

	CStringW fnw = m_in;
	CComPtr<IFileSourceFilter> pReader;

	if (!pReader && m_in.Mid(m_in.ReverseFind('.')+1).MakeLower() == _T("cda")) {
		hr = S_OK;
		CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDDAReader(NULL, &hr);

		if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
			pReader.Release();
		}
	}

	if (!pReader) {
		hr = S_OK;
		CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDXAReader(NULL, &hr);

		if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
			pReader.Release();
		}
	}

	if (!pReader /*&& ext == _T("ifo")*/) {
		hr = S_OK;
		CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CVTSReader(NULL, &hr);

		if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
			pReader.Release();
		} else {
			CPath pout(m_out);
			pout.RenameExtension(_T(".ifo"));
			CopyFile(m_in, pout, FALSE);
		}
	}

	if (!pReader) {
		hr = S_OK;
		CComPtr<IUnknown> pUnk;
		hr = pUnk.CoCreateInstance(CLSID_AsyncReader);

		if (FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
			pReader.Release();
		}
	}

	if (!pReader) {
		hr = S_OK;
		CComPtr<IUnknown> pUnk;
		hr = pUnk.CoCreateInstance(CLSID_URLReader);

		if (CComQIPtr<IBaseFilter> pSrc = pUnk) {
			hr = pGB->AddFilter(pSrc, fnw);

			if (FAILED(hr) || !(pReader = pUnk) || FAILED(hr = pReader->Load(fnw, NULL))) {
				pReader.Release();
				pGB->RemoveFilter(pSrc);
			}
		}
	}

	CComQIPtr<IBaseFilter> pSrc = pReader;

	if (FAILED(pGB->AddFilter(pSrc, fnw))) {
		m_report.SetWindowText(_T("Sorry, can't save this file, press cancel"));

		return FALSE;
	}

	CComQIPtr<IBaseFilter> pMid = DNew CStreamDriveThruFilter(NULL, &hr);

	if (FAILED(pGB->AddFilter(pMid, L"StreamDriveThru"))) {
		m_report.SetWindowText(_T("Error"));

		return FALSE;
	}

	CComQIPtr<IBaseFilter> pDst;
	pDst.CoCreateInstance(CLSID_FileWriter);
	CComQIPtr<IFileSinkFilter2> pFSF = pDst;
	pFSF->SetFileName(CStringW(m_out), NULL);
	pFSF->SetMode(AM_FILE_OVERWRITE);

	if (FAILED(pGB->AddFilter(pDst, L"File Writer"))) {
		m_report.SetWindowText(_T("Error"));

		return FALSE;
	}

	hr = pGB->Connect(
			 GetFirstPin((pSrc), PINDIR_OUTPUT),
			 GetFirstPin((pMid), PINDIR_INPUT));

	if (FAILED(hr)) {
		m_report.SetWindowText(_T("Error Connect pSrc / pMid"));
		return FALSE;
	}

	hr = pGB->Connect(
			 GetFirstPin((pMid), PINDIR_OUTPUT),
			 GetFirstPin((pDst), PINDIR_INPUT));
	if (FAILED(hr)) {
		m_report.SetWindowText(_T("Error Connect pMid / pDst"));
		return FALSE;
	}

	pMS = pMid;

	pMC->Run();

	m_nIDTimerEvent = SetTimer(1, 500, NULL);

	return TRUE;
}
Exemple #8
0
BOOL CAboutDlg::OnInitDialog()
{
    // Get the default text before it is overwritten by the call to __super::OnInitDialog()
    GetDlgItem(IDC_STATIC1)->GetWindowText(m_appname);
    GetDlgItem(IDC_AUTHORS_LINK)->GetWindowText(m_credits);
#ifndef MPCHC_LITE
    GetDlgItem(IDC_LAVFILTERS_VERSION)->GetWindowText(m_LAVFiltersVersion);
#endif

    __super::OnInitDialog();

    // Because we set LR_SHARED, there is no need to explicitly destroy the icon
    m_icon.SetIcon((HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 48, 48, LR_SHARED));

#if MPC_BETA_RELEASE || _WIN64
    m_appname += _T(" (");
#endif

#if MPC_BETA_RELEASE
    m_appname += MPC_VERSION_BETA;
#endif

#if MPC_BETA_RELEASE && _WIN64
    m_appname += _T(", ");
#endif

#ifdef _WIN64
    m_appname += _T("64-bit");
#endif

#if MPC_BETA_RELEASE || _WIN64
    m_appname += _T(")");
#endif

#ifdef MPCHC_LITE
    m_appname += _T(" Lite");
#endif

    // Build the path to Authors.txt
    m_AuthorsPath = GetProgramPath() + _T("Authors.txt");
    // Check if the file exists
    if (FileExists(m_AuthorsPath)) {
        // If it does, we make the filename clickable
        m_credits.Replace(_T("Authors.txt"), _T("<a>Authors.txt</a>"));
    }

    m_homepage.Format(_T("<a>%s</a>"), WEBSITE_URL);

    m_strBuildNumber = MPC_VERSION_STR_FULL;

#if defined(__INTEL_COMPILER)
#if (__INTEL_COMPILER >= 1210)
    m_MPCCompiler = _T("ICL ") MAKE_STR(__INTEL_COMPILER) _T(" Build ") MAKE_STR(__INTEL_COMPILER_BUILD_DATE);
#else
#error Compiler is not supported!
#endif
#elif defined(_MSC_VER)
#if (_MSC_VER == 1700) // 2012
#if (_MSC_FULL_VER == 170060610)
    m_MPCCompiler = _T("MSVC 2012 Update 3");
#elif (_MSC_FULL_VER == 170060315)  // MSVC 2012 Update 2
#error VS2012 Update 2 is not supported because the binaries will not run on XP. Install Update 3 instead.
#elif (_MSC_FULL_VER == 170051106)
    m_MPCCompiler = _T("MSVC 2012 Update 1");
#elif (_MSC_FULL_VER < 170050727)   // MSVC 2012
#error Please install the latest Update for VS2012.
#else
    m_MPCCompiler = _T("MSVC 2012");
#endif
#elif (_MSC_VER == 1600) // 2010
#if (_MSC_FULL_VER >= 160040219)
    m_MPCCompiler = _T("MSVC 2010 SP1");
#else
    m_MPCCompiler = _T("MSVC 2010");
#endif
#elif (_MSC_VER < 1600)
#error Compiler is not supported!
#endif
#else
#error Please add support for your compiler
#endif

#if (__AVX__)
    m_MPCCompiler += _T(" (AVX)");
#elif (__SSSE3__)
    m_MPCCompiler += _T(" (SSSE3)");
#elif (__SSE3__)
    m_MPCCompiler += _T(" (SSE3)");
#elif !defined(_M_X64) && defined(_M_IX86_FP)
#if (_M_IX86_FP == 2)   // /arch:SSE2 was used
    m_MPCCompiler += _T(" (SSE2)");
#elif (_M_IX86_FP == 1) // /arch:SSE was used
    m_MPCCompiler += _T(" (SSE)");
#endif
#endif

#ifdef _DEBUG
    m_MPCCompiler += _T(" Debug");
#endif

#ifndef MPCHC_LITE
    CString LAVFiltersVersion = CFGFilterLAV::GetVersion();
    if (!LAVFiltersVersion.IsEmpty()) {
        m_LAVFiltersVersion = LAVFiltersVersion;
    }
#endif

    m_buildDate = _T(__DATE__) _T(" ") _T(__TIME__);

    OSVERSIONINFOEX osVersion = SysVersion::GetFullVersion();
    m_OSName.Format(_T("Windows NT %1u.%1u (build %u"),
                    osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.dwBuildNumber);
    if (osVersion.szCSDVersion[0]) {
        m_OSName.AppendFormat(_T(", %s)"), osVersion.szCSDVersion);
    } else {
        m_OSName += _T(")");
    }
    m_OSVersion.Format(_T("%1u.%1u"), osVersion.dwMajorVersion, osVersion.dwMinorVersion);
    if (SysVersion::Is64Bit()) {
        m_OSVersion += _T(" (64-bit)");
    }

    UpdateData(FALSE);

    GetDlgItem(IDOK)->SetFocus();

    return FALSE;
}
Exemple #9
0
void CpermoDlg::DrawInfo(CDC* pDC)
{
	CFont font, *pOldFont;
	LOGFONT logFont;
	pDC->GetCurrentFont()->GetLogFont(&logFont);
	logFont.lfWidth = 0;
	logFont.lfHeight = nFontSize;
	logFont.lfWeight = FW_REGULAR;
	lstrcpy(logFont.lfFaceName, _T("微软雅黑"));
	font.CreateFontIndirect(&logFont);
	pOldFont = pDC->SelectObject(&font);
	COLORREF cOldTextColor;
	if (IDM_GREEN == nSkin || IDM_ORANGE == nSkin)
	{
		cOldTextColor = pDC->SetTextColor(RGB(0, 0, 0));
	}
	else
	{
		cOldTextColor = pDC->SetTextColor(RGB(255, 255, 255));
	}
	int nOldBkMode = pDC->SetBkMode(TRANSPARENT);
	CString strCPU, strMem, strNetUp, strNetDown;
	strCPU.Format(_T("%d%%"), nCPU);
	strMem.Format(_T("%d%%"), nMem);
	if (fNetUp >= 1000)
	{
		strNetUp.Format(_T("%.2fMB/S"), fNetUp/1024.0);
	}
	else
	{
		if (fNetUp < 100)
		{
			strNetUp.Format(_T("%.1fKB/S"), fNetUp);
		}
		else
		{
			strNetUp.Format(_T("%.0fKB/S"), fNetUp);
		}
	}
	if (fNetDown >= 1000)
	{
		strNetDown.Format(_T("%.2fMB/S"), fNetDown/1024.0);
	}
	else
	{
		if (fNetDown < 100)
		{
			strNetDown.Format(_T("%.1fKB/S"), fNetDown);
		}
		else
		{
			strNetDown.Format(_T("%.0fKB/S"), fNetDown);
		}
	}
	CRect rText;
	rText.left = 1;
	rText.right = 36;
	rText.top = 2;
	rText.bottom = 21;
	pDC->DrawText(strCPU, &rText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	rText.left = 186;
	rText.right = 219;
	pDC->DrawText(strMem, &rText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	if (IDM_BLACK == nSkin || IDM_BLUE == nSkin)
	{
		pDC->SetTextColor(RGB(255, 255, 255));
	}
	else
	{
		pDC->SetTextColor(RGB(0, 0, 0));
	}

	CRect rcIcon;
	rcIcon.left = 38;
	rcIcon.right = 50;
	rcIcon.top = 5;
	rcIcon.bottom = 17;
	DrawIconEx(pDC->GetSafeHdc(), rcIcon.left, rcIcon.top, LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_DOWN)), rcIcon.Width(), rcIcon.Height(), 0, NULL, DI_NORMAL);
	rText.left = 52;
	rText.right = 110;
	pDC->DrawText(strNetDown, &rText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	rcIcon.left = 112;
	rcIcon.right = 124;
	DrawIconEx(pDC->GetSafeHdc(), rcIcon.left, rcIcon.top, LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_UP)), rcIcon.Width(), rcIcon.Height(), 0, NULL, DI_NORMAL);
	rText.left = 126;
	rText.right = 185;
	pDC->DrawText(strNetUp, &rText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);


	pDC->SetTextColor(cOldTextColor);
	pDC->SetBkMode(nOldBkMode);
	pDC->SelectObject(pOldFont);
	font.DeleteObject();
}
BOOL CCANMonitorApp::InitInstance()
{
    // Begin of Multiple Language support
    if ( CMultiLanguage::m_nLocales <= 0 )    // Not detected yet
    {
        CMultiLanguage::DetectLangID(); // Detect language as user locale
        CMultiLanguage::DetectUILanguage();    // Detect language in MUI OS
    }
    TCHAR szModuleFileName[MAX_PATH];        // Get Module File Name and path
    int ret = ::GetModuleFileName(theApp.m_hInstance, szModuleFileName, MAX_PATH);
    if ( ret == 0 || ret == MAX_PATH )
    {
        ASSERT(false);
    }
    // Load resource-only language DLL. It will use the languages
    // detected above, take first available language,
    // or you can specify another language as second parameter to
    // LoadLangResourceDLL. And try that first.
    ghLangInst = CMultiLanguage::LoadLangResourceDLL( szModuleFileName );
    if (ghLangInst)
    {
        AfxSetResourceHandle( ghLangInst );
    }
    // End of Multiple Language support

	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

    //InitCommonControls();
    // START CHANGES MADE FOR AUTOMATION
	CWinAppEx::InitInstance();

    // Initialize OLE libraries
    if (!AfxOleInit())
    {
        AfxMessageBox(_("Fail to Intilaize OLE"));
        return FALSE;
    }
    //CoInitializeEx(nullptr, COINIT_MULTITHREADED );

    CBusmasterDump dump("BUSMASTER");
    // END CHANGES MADE FOR AUTOMATION
    // Enable OLE/ActiveX objects support
    AfxEnableControlContainer();
	InitContextMenuManager();
	InitKeyboardManager();
	InitTooltipManager();
	CMFCToolTipInfo ttParams;
	ttParams.m_bVislManagerTheme = TRUE;
	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
    // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need. DEBUG
//#ifdef _AFXDLL
//    Enable3dControls();         // Call this when using MFC in a shared DLL
//#else
//    Enable3dControlsStatic();   // Call this when linking to MFC statically
//#endif
    // Change the registry key under which our settings are stored.
    // TODO: You should modify this string to be something appropriate
    // such as the name of your company or organization.
    SetRegistryKey("RBEI-ETAS\\BUSMASTER_v3.1.0");
    // START CHANGES MADE FOR AUTOMATION
    COleTemplateServer::RegisterAll();
    // END CHANGES MADE FOR AUTOMATION
    //LoadStdProfileSettings(0); // Load standard INI file options (including MRU)
    // Enable drag/drop open
    // Enable DDE Execute open
    //EnableShellOpen();
    //RegisterShellFileTypes(TRUE);
    // Display splash screen
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    short shRegServer = -1;
    short shUnRegServer = -1;

    if (__argc > 1)
    {
        shRegServer = (short) strcmpi(__targv[1],"/regserver");
        shUnRegServer = (short) strcmpi(__targv[1],"/unregserver");
    }

    // Don't display a new MDI child window during startup
    if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew
            || cmdInfo.m_nShellCommand == CCommandLineInfo::FileOpen)
    {
        cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
    }

    // START CHANGES MADE FOR AUTOMATION

    if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
    {
        m_bFromAutomation = TRUE;
        //      return TRUE;
    }
    else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
    {
        AfxOleUnregisterTypeLib(LIBID_CAN_MonitorApp);
    }
    else
    {
        COleObjectFactory::UpdateRegistryAll();
        AfxOleRegisterTypeLib(AfxGetInstanceHandle(), LIBID_CAN_MonitorApp);
    }

    if (  shRegServer == 0  || shUnRegServer == 0 ) //If command line argument match
    {
        return FALSE;
    }

    if (!m_bFromAutomation)
    {
        CSplashScreen::ActivateSplashScreen(cmdInfo.m_bShowSplash);
    }

    // Allocate memory for CFlags
    m_pouFlags = &(CFlags::ouGetFlagObj());
    // create main MDI Frame window
    CMainFrame* pMainFrame = new CMainFrame;

    if ( pMainFrame == nullptr )
    {
        ::PostQuitMessage(0);
        return FALSE;
    }

    if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
    {
        return FALSE;
    }

    m_pMainWnd = pMainFrame;

    // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
    {
        return FALSE;
    }

    m_pMainWnd->DragAcceptFiles();
    // show main frame
    m_pMainWnd->ShowWindow(m_nCmdShow);
    m_pMainWnd->UpdateWindow();
    //// Create message window



    if(m_pouMsgSgInactive == nullptr )
    {
        if(m_bFromAutomation==FALSE)
            MessageBox(nullptr,_(MSG_MEMORY_CONSTRAINT),
                       "BUSMASTER", MB_OK|MB_ICONINFORMATION);

        ::PostQuitMessage(0);
    }

    BOOL bResult;
    bResult = m_aomState[UI_THREAD].SetEvent();
    // get the information of the last used configuration file..
    // initialize the flag that indicates if the configuratin file has been
    // loaded..
    m_bIsConfigFileLoaded = FALSE;
    CString ostrCfgFilename = "";

    // If user has double click the .cfg file then assign that file name else
    // read from registry.
    if(cmdInfo.m_strFileName.IsEmpty() == TRUE)
    {
        //ostrCfgFilename =
        //    GetProfileString(_(SECTION), defCONFIGFILENAME, "");
        DWORD dwVal;
        bReadFromRegistry(HKEY_CURRENT_USER, _(SECTION), defCONFIGFILENAME, REG_SZ, ostrCfgFilename, dwVal);
    }
    else
    {
        ostrCfgFilename = cmdInfo.m_strFileName;
    }

    BOOL bValidDir = TRUE;
    CFileFind findFile;
    if (!ostrCfgFilename.IsEmpty() && !findFile.FindFile(ostrCfgFilename))
    {
        DWORD dwErr = GetLastError();
        CString strMsg = "";
        if (dwErr == ERROR_PATH_NOT_FOUND)
        {
            bValidDir = FALSE;
            FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, dwErr, 0, strMsg.GetBuffer(1024), 1024, nullptr);
            AfxMessageBox(strMsg);
        }
    }
    if(ostrCfgFilename.IsEmpty() == FALSE && bValidDir == TRUE)
    {
        bInitialiseConfiguration(m_bFromAutomation);

        // load the configuration information
        if(pMainFrame->nLoadConfigFile(ostrCfgFilename) != defCONFIG_FILE_SUCCESS)
        {
            //m_oConfigDetails.vInitDefaultValues();
            m_ostrConfigFilename = "";
        }
        else
        {
            m_ostrConfigFilename = ostrCfgFilename;
        }

        m_bIsConfigFileLoaded = TRUE;

        //build all nodes -- Node Simulation.
        pMainFrame->BuildAllNodes();

    }
    else
    {
        BOOL bReturn = bInitialiseConfiguration(m_bFromAutomation);

        if(bReturn == FALSE )
        {
            ::PostQuitMessage(0);
        }

        // Load a default database file
        //CStringArray omDatabaseArray;
        //CString omSampleDatabasePath;
        //omSampleDatabasePath.Format("%s\\Samples\\SampleDB.dbf",m_acApplicationDirectory);
        //DWORD dRetVal = pMainFrame->dLoadDataBaseFile(omSampleDatabasePath, FALSE);

        //if (dRetVal == S_OK)
        //{
        //    //omDatabaseArray.Add(omSampleDatabasePath);
        //    //Store in configdetails
        //    //bSetData(DATABASE_FILE_NAME, &omDatabaseArray);
        //    bWriteIntoTraceWnd(_(MSG_DEFAULT_DATABASE));
        //    bWriteIntoTraceWnd(_(MSG_CREATE_UNLOAD_DATABASE));
        //}
        pMainFrame->OnHex_DecButon();           // setting HEX by default
    }

    // ********  Filter workaround  ********
    // Filter list is initialised before msg wnd creation. So update display
    // filter here
    // Update Message Display Filter List
    //::PostThreadMessage(GUI_dwThread_MsgDisp, TM_UPDATE_FILTERLIST, nullptr, nullptr );
    // ********  Filter workaround  ********

    // Start Logging if is enabled
    // Get the Flag Pointer
    CFlags* pomFlag =  pouGetFlagsPtr();

    if( pomFlag != nullptr )
    {
        // Get the Logging Status
        BOOL bLogON = pomFlag->nGetFlagStatus(LOGTOFILE);

        // If it is on then post a message to display thread to start logging
        if(bLogON == TRUE )
        {
            // Start Logging
            //CLogManager::ouGetLogManager().vStartStopLogging( TRUE );
        }
    }
    //pMainFrame->OnHex_DecButon();           // setting HEX by default
    //CExecuteManager::ouGetExecuteManager().vStartDllReadThread();
    return TRUE;
}
BOOL CERadQueueCallApp::InitATL()
{
	_Module.Init(ObjectMap, AfxGetInstanceHandle());
	return TRUE;

}
Exemple #12
0
void ModifyTrayIcon(HWND hWnd, DWORD idi)
{
	TrayMessage(hWnd, NIF_ICON, NIM_MODIFY, _TRAY_ICON_ID, (HICON)LoadImage(AfxGetInstanceHandle(), 
		MAKEINTRESOURCE(idi), IMAGE_ICON, 16, 16, 0), _APP_NAME);
	SetClassLong(hWnd, GCL_HICON, (LONG)LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(idi)));
}
Exemple #13
0
void CAnimateButton::SetCursor(UINT nIDCursor)
{
	m_hCursor = ::LoadCursor(AfxGetInstanceHandle(), MAKEINTRESOURCE(nIDCursor));
	SendMessage(WM_SETCURSOR);
}
Exemple #14
0
// Initialise the dialog
//
BOOL CEventWizardDlg::OnInitDialog() 
{
	// Startup
	CDialog::OnInitDialog();

	int currentPosition = 1;

	// Create an m_ObjectImages
	m_ObjectImages.DeleteImageList();

	bool bSmallImages = false;

	// Check what size images we'll need
	// 32x32 without families or 16x16 with
	if (application->families.size() == 0)
	{
		m_ObjectImages.Create(32, 32, ILC_COLOR24, 3, 3);
		m_List.SetImageList(&m_ObjectImages, LVSIL_NORMAL);

		HBITMAP SystemBitmap = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_SYSTEM));
		ImageList_Add(m_ObjectImages, SystemBitmap, SystemBitmap);
		DeleteObject(SystemBitmap);
	}

	else
	{
		// If it's small, also set the view to small images
		m_List.SetView(LV_VIEW_SMALLICON);

		m_ObjectImages.Create(16, 16, ILC_COLOR24, 3, 3);
		m_List.SetImageList(&m_ObjectImages, LVSIL_SMALL);

		HBITMAP SystemBitmap = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_SYSTEMC));
		ImageList_Add(m_ObjectImages, SystemBitmap, SystemBitmap);	
		DeleteObject(SystemBitmap);

		bSmallImages = true;
	}

	// Prepare to iterate all objects to add icons
	POSITION pos = objMap->GetStartPosition();
	long mapKey;
	CObjType* ObjectType;

	// Add '(System)' because system uses it
	object_folders["(System)"] = 0;

	// Loop through and add all objects to the otList
	while (pos != NULL) 
	{
		objMap->GetNextAssoc(pos, mapKey, ObjectType);

		if(!ObjectType->m_bIsGroupType)
		{
			CObj *o;
			bool bAdd = false;

			// If global, its okay to add...if its not global..and we have a layout...we need to check
			if (ObjectType->m_bGlobal) 
			{
				bAdd = true;
			}
			else if(layout)
			{
				POSITION pos = layout->objects.GetStartPosition();

				for (int i = 0; i < layout->objects.GetCount(); i++) 
				{
					long ID;
					layout->objects.GetNextAssoc(pos, ID, o);
						
					if (o->GetGlobalID() == ObjectType->ObjectIdentifier)
					{
						bAdd = true;	
					}
				}
			}
			else // we have no layout to this event sheet
			{
				bAdd = true;
			}

			// Dont add if it doesn't have conditions/actions
			bool hasAces = false;
			for (int i = 0; i < ObjectType->GetTableCount(m_aceType); i++)
			{
				if (ObjectType->GetACESEntry(m_aceType, i)->aceListName == "")
				{
					hasAces = true;
					break;
				}
				if (hasAces)
					break;
			}
			if(!hasAces)
				bAdd = false;

			// Okay cool...look like its okay to add...just check if is showabout in the event sheet editor
			if(bAdd && ObjectType->m_bShowInEventSheetEditor)
			{
				// Possibly add a new category
				if(object_folders.find(ObjectType->GetFolder()) == object_folders.end())
				{
					object_folders[ObjectType->GetFolder()] = object_folders.size();
				}
				m_otList.push_back(ObjectType);
			}
		}
	}

	// Sort
	sort(m_otList.begin(), m_otList.end(), ObjTypeSortFunction);

	// Now loop the otList backwards to display each object icon
	for(vector<CObjType*>::iterator i = m_otList.begin(); i != m_otList.end(); i++)
	{	
		HBITMAP Bitmap;

		if (bSmallImages)
			Bitmap = (*i)->small_image.MakeBitmap();
		else
			Bitmap = (*i)->m_Image.MakeBitmap();

		ImageList_Add(m_ObjectImages, Bitmap, Bitmap);

		DeleteObject(Bitmap);
	}	

	pos = objMap->GetStartPosition();

	// Family icons
	list<Family>::iterator f = application->families.begin();

	for ( ; f != application->families.end(); f++)
	{
		if(f->is_in_use)
		{
			HBITMAP Bitmap = f->small_image.MakeBitmap();
			ImageList_Add(m_ObjectImages, Bitmap, Bitmap);
			
			DeleteObject(Bitmap);
		}
	}
	
	// Title
	CString Title;

	if (m_aceType == CONDITION)
		Title.Format("Construct : New condition");
	else if (m_aceType == ACTION)
		Title.Format("Construct : New action");
	else if (m_aceType == EXPRESSION)
		Title.Format("Construct : New expression");

	SetWindowText(Title);

	CRect Rect;
	m_ACEList.GetWindowRect(&Rect);
	ScreenToClient(&Rect);
	Rect.top = Rect.bottom - 1;
	Rect.bottom = Rect.top + 18;
	m_CategoryTabs.Create(this, Rect, 1001, WS_CHILD | WS_VISIBLE, __ETWS_ORIENT_BOTTOM);

	m_ACEList.GetWindowRect(&Rect);
	ScreenToClient(&Rect);
	Rect.top -= 17;
	Rect.bottom = Rect.top + 18;
	m_Tabs.Create(this, Rect, 1002, WS_CHILD | WS_VISIBLE, __ETWS_ORIENT_TOP);

	GetClientRect(&Rect);

	Rect.bottom = Rect.top + 22;
	Rect.right += 48;

	// Resizing anchors
	BOOL First = dlgMan.Load(this->m_hWnd, "Software\\Construct\\EventWizardDialogs");
	if (!First)
	{
		first_run.Attach(this);
		first_run.SetHighlightOnMouseOver();
		first_run.SetResize();
		first_run.SetWrapText();

		if (m_aceType == ACTION)
			first_run.SetText("Events are created via this wizard.  Choose an object from the list below.  A list of actions will then appear, some of which require parameters: for example 'Create object' under System.  Once all parameters are filled out, click Finish to insert your action.");
		if (m_aceType == CONDITION)
			first_run.SetText("Events are created via this wizard.  Choose an object from the list below.  A list of conditions will then appear, some of which require parameters: for example 'Compare' under System.  Once all parameters are filled out, click Finish to insert your condition.");

	}

    dlgAnchor.Init(this->m_hWnd);

	dlgAnchor.Add(IDC_OBJECTLIST, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT);
	dlgAnchor.Add(IDC_ACELIST, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT);
	dlgAnchor.Add(IDC_FIND, ANCHOR_TOP | ANCHOR_RIGHT);

	dlgAnchor.Add(1001, ANCHOR_LEFT | ANCHOR_BOTTOMRIGHT);
	dlgAnchor.Add(1002, ANCHOR_TOPLEFT | ANCHOR_RIGHT);
	dlgAnchor.Add(1003, ANCHOR_TOPLEFT | ANCHOR_RIGHT);
	
	dlgAnchor.Add(IDC_BACK, ANCHOR_BOTTOM | ANCHOR_RIGHT);
	dlgAnchor.Add(IDC_CANCEL, ANCHOR_BOTTOM | ANCHOR_LEFT);
	dlgAnchor.Add(IDC_NEXT, ANCHOR_BOTTOM | ANCHOR_RIGHT);
	
	m_Cancel.SetWindowText(CANCEL);

	// Set ACE margins
	CRect ListRect;
	m_ACEList.GetClientRect(&ListRect);
	ListRect.left += 5;
	ListRect.top += 5;
	m_ACEList.SetWorkAreas(1, &ListRect);
	m_ACEList.SetColumnWidth(0, 200);		// Spaces everything out nicely for step 2.

	int initStep = m_iStep;

	if (m_InitialStage == 0)
	{
		m_iStep = 1;
		ChangeStep();
	}

	else
	{
		// New to 0.96.3
		m_pSelectedObject = m_InitialSelect;
		initStep = 2;
	}

	// The below is used so we set the default selected items (eg. if we are editing)
	if(m_pSelectedObject != -2)
	{
		// Have an object already selected
		for(int i = 0; i < m_List.GetItemCount(); i++)
			if(m_List.GetItemData(i) == m_pSelectedObject)
				m_List.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED);
	}

	if(m_aceIndex != -1)
	{
		PreChangeStep();
		m_iStep = 2;
		int aceIndex = m_aceIndex;

		ChangeStep();
		if(m_childid != 0)
		{
			CObjType* pType = application->FindObjTypeFromNumber(m_pSelectedObject);
			if(pType)
			{
				int index = 1;
				list<CBehavior>::iterator i = pType->behaviors.begin();
				list<CBehavior>::iterator end = pType->behaviors.end();

				for(; i!= end; i++)
				{
					if(i->id == m_childid)
					{
						m_Tabs.SelectionSet(index);
						break;
					}

					index ++;
				}

				list<CEffect>::iterator e = pType->effects.begin();
				for(;e!= pType->effects.end(); e++)
				{
					if(e->m_effectID == -m_childid)				
						m_Tabs.SelectionSet(index);

					index ++;
				}
			}

			ChangeStep();
		}

		m_aceIndex = aceIndex;

		for(int i = 0; i < m_ACEList.GetItemCount(); i++)
		{
			if(m_ACEList.GetItemData(i) == m_aceIndex)
				m_ACEList.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED);
		}		
	}

	if(initStep != m_iStep)
	{
		PreChangeStep();
		m_iStep = initStep;
		ChangeStep();
	}

	UpdateButtons();

	// Expression dialogs will move slightly to make it clear it's on top of the existing parameters dialog.
	if (m_aceType == EXPRESSION) {
		RECT rc;
		this->GetWindowRect(&rc);
		rc.left += 50;
		rc.top += 50;
		this->SetWindowPos(NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE);
	}

	// New drawing code
	LOGFONT* m_pLF;
	m_pLF=(LOGFONT*)calloc(1,sizeof(LOGFONT));
	strncpy(m_pLF->lfFaceName,"Segoe UI",9);
	m_pLF->lfHeight=14;
	m_pLF->lfWeight=600;
	m_pLF->lfItalic=0;
	m_pLF->lfUnderline=0;
	m_FontBold.CreateFontIndirect(m_pLF);

	m_pLF->lfWeight = 0;
	m_Font.CreateFontIndirect(m_pLF);

	m_Find.SetIcon(IDI_SEARCH);

	return FALSE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
   // Register your unique class name that you wish to use
   WNDCLASS wndcls;

   memset(&wndcls, 0, sizeof(WNDCLASS));   // start with NULL defaults

   wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;

   //you can specify your own window procedure
   wndcls.lpfnWndProc = ::DefWindowProc; 
   wndcls.hInstance = AfxGetInstanceHandle();
   wndcls.hIcon = LoadIcon(wndcls.hInstance, MAKEINTRESOURCE(IDI_MYICON));
   wndcls.hCursor = LoadCursor(wndcls.hInstance, MAKEINTRESOURCE(IDC_ARROW));
   wndcls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
   wndcls.lpszMenuName = NULL;

   // Specify your own class name for using FindWindow later
   wndcls.lpszClassName = _T("MyNewClass");

   // Register the new class and trace if it fails
   if(!AfxRegisterClass(&wndcls))
   {
      TRACE("Class Registration Failed\n");
   }
Exemple #16
0
BOOL CDtxShellExApp::InitATL()
{
	_Module.Init(ObjectMap, AfxGetInstanceHandle(),&LIBID_THUMBDTXSHELLEXLib);
	return TRUE;
}
void CDlgCheckRuleMdlMatSystem::OnBnClickedMatFolder()
{
	CString strMatResPath;
	CBpRegKey rk;
	CString strPath = DOCTOR_PRODUCT_KEYROOT;
	strPath += REGISTRY_KEY_OPTION;
	if (rk.Open(HKEY_CURRENT_USER, strPath) == ERROR_SUCCESS)
	{
		// 材料库的路径
		CString strValue;
		if (rk.Read(REGISTRY_KEY_MATERIALLIB_PATH, strValue) == ERROR_SUCCESS)
			strMatResPath = strValue;
	}

	if (strMatResPath.IsEmpty())
	{
		GetMainModulePath(AfxGetInstanceHandle(), strMatResPath);
		strMatResPath = strMatResPath + L"Resource\\MaterialLib\\";
	}
	if (strMatResPath[strMatResPath.GetLength()-1] != L'\\')
		strMatResPath = strMatResPath + L"\\";

	// 允许多选
	CFileDialog dlgFile(TRUE, _T("*.mtl"), NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, _T("材料文件(*.mtl)|*.mtl"));
	if (GetVersion() < 0x80000000) 
		// 运行的操作系统是Windows NT/2000 
		dlgFile.m_ofn.lStructSize = 88;	// 显示新的文件对话框 
	else
		// 运行的操作系统Windows 95/98 
		dlgFile.m_ofn.lStructSize = 76;	// 显示老的文件对话框 
	dlgFile.m_ofn.lpstrInitialDir = strMatResPath;
	
	if (dlgFile.DoModal() == IDOK)
	{
		POSITION pos_file;
		pos_file = dlgFile.GetStartPosition();

		CString strFilePath;
		CStringArray arrMatNames;
		while(pos_file != NULL)
		{
			strFilePath = dlgFile.GetNextPathName(pos_file);
			int nLength = strFilePath.GetLength();
			int nPos = strFilePath.ReverseFind(_T('\\'));
			strFilePath = strFilePath.Mid(nPos+1, nLength-nPos-5);
			arrMatNames.Add(strFilePath);
		}
		int nListCount = (int)m_listMats.GetItemCount();
		for (int i=0; i<arrMatNames.GetCount(); i++)
		{
			BOOL bExist = FALSE;
			for (int j=0; j<nListCount; j++)
			{
				if (arrMatNames[i].CompareNoCase(m_listMats.GetItemText(j, 0)) == 0)
				{
					bExist = TRUE;
				}
			}
			if (!bExist)
				m_listMats.InsertItem(nListCount, arrMatNames[i]);
		}
		UpdateCheckRuleByControl();
		::SendMessage(GetParent()->m_hWnd, WM_MODIFY_CHECK_RULE, 0, (LPARAM)&m_checkRule);
	}
}
Exemple #18
0
/////////////////////////////////////////////////////////////////////////////
// CDocSelector message handlers
BOOL CDocSelector::AddButton( CWnd* wnd, WORD wIcon ,HICON hIcon )
{
	CRect rect;
	GetClientRect(&rect);

	// Yogesh Jagota
	CDocument* pDoc = ((CView *) wnd)->GetDocument();

	CString sPath = pDoc->GetPathName();
	CString sFileName;
	
	if ( sPath.IsEmpty() )
		sPath = pDoc->GetTitle();

	// Can be only the filename, like Noname01
	if ( sPath.Find( _T('\\') ) != -1 )
		sFileName = sPath.Mid( sPath.ReverseFind( _T('\\') ) + 1 );
	else
		sFileName = sPath;

	// If there is no space left to display extra buttons...
	int nNewSize = ( ( rect.Width() - DS_MENU_BUTTON_WIDTH ) 
		/ ( m_Buttons.GetSize() + 1 ) ) - DS_SEPERATER_MARGIN;

	bool bShowButton = true;
	if ( nNewSize <= MINWIDTH )
	{
		// Check if the menu button is displayed, if not, display it...
		m_btnMenuButton.ShowWindow( SW_SHOW );

		// Don't show the button...
		bShowButton = false;
	}
	else
		m_nDisplayedButtons++;

	// End Yogesh Jagota

	CSwitcherButton* newbutton = new CSwitcherButton();

	 // Yogesh Jagota
	newbutton->m_AttachedView = wnd;

	// I am saving the frame to make life easier in case
	// of activation in selection process...
	CMDIFrameWnd *pFrame = (CMDIFrameWnd *)AfxGetMainWnd();
	CWnd * pWnd = pFrame->GetWindow( GW_CHILD );
	ASSERT (pWnd);
	pWnd = pWnd->GetWindow( GW_CHILD );
	while (pWnd)
	{
		if ( ((CFrameWnd *)pWnd)->GetActiveView() == (CView*)wnd )
			newbutton->m_FrameWnd = (CFrameWnd *)pWnd;

		pWnd = pWnd->GetWindow( GW_HWNDNEXT );
	}

	// Load the icon....
	if ( hIcon)
	{
		newbutton->m_iIcon=hIcon;
		newbutton->m_iIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	}
	
	else

	if ( wIcon != -1 )
		newbutton->m_iIcon = ::LoadIcon( AfxGetInstanceHandle(), 
			MAKEINTRESOURCE( wIcon ) );
	// End Yogesh Jagota

	newbutton->m_iID = m_Buttons.GetSize();
	if (!newbutton->DoCreate(this, m_iNextButtonStart, 
		rect.top + 3, m_iButtonWidth, DS_HEIGHT - 2, 
		sFileName, sPath )) // Yogesh Jagota
	{
		return FALSE;
	}

	if ( !bShowButton )
		newbutton->ShowWindow( SW_HIDE );

	m_Buttons.Add((void*)newbutton);
	m_iNextButtonStart += m_iButtonWidth + DS_SEPERATER_MARGIN;

	if (m_iNextButtonStart - DS_SEPERATER_MARGIN > rect.Width())
	{
		// this loop makes a neat little animation
		int newsize = ((rect.Width() - DS_MENU_BUTTON_WIDTH ) 
			/ (m_Buttons.GetSize())) - DS_SEPERATER_MARGIN;

//		Yogesh Jagota. Removed animation because did'nt liked it.
//		Remove if you want animated addition or removal of buttons.
//
//		register int y;
//		for (y = m_iButtonWidth; y >= newsize; y-=3)
//		{
//			ResizeButtons(y);
//			Sleep(15);
//		}
//
//		if (y != newsize)
//			/* ResizeButtons(newsize); */ <- this is the next line...
//		End Yogesh Jagota

		ResizeButtons(newsize);

		if (m_iButtonWidth < MINWIDTH)
		{
			// the smallest allowable button size has been reached...
			// in this version, we can't handle this
			ASSERT(0);
			return FALSE;
		}
	}
	else
		m_btnMenuButton.ShowWindow( SW_HIDE );

	// Yogesh Jagota
	if ( m_iSelectedButton != -1 )
		((CSwitcherButton *) m_Buttons.GetAt( m_iSelectedButton ))->Unselect();

	m_iSelectedButton = newbutton->m_iID;
	((CSwitcherButton *) m_Buttons.GetAt( m_iSelectedButton ))->Select();
	// End Yogesh Jagota

	return TRUE;
}
void CDlgSideChannelAttackVisualizationHEPreparations::OnOK() {
	//CDialog::OnOK();
	
	int result = 0;
	
	// MÖGLICHKEIT [1]
	// ===============
	//	Benutzer hat beim Öffnen des SCA-Dialogs noch keine Datei geöffnet. Folglich gibt es zwei
	//	Möglichkeiten: Zum einen (a) die Hybridverschlüsselung selbst durchführen oder (b) eine
	//	bereits hybridverschlüsselte Datei für einen schon angelegten Benutzer verwenden.
	if(initMode & SCA_MODE_NO_FILE)
	{
		CDlgSideChannelAttackVisualizationHEPreparationsRequest1 dlg;
		if(dlg.DoModal() == IDOK)
		{
			// Fall (a)
			if(dlg.getRadioChoice1())
			{
				// Benutzer möchte eine Datei wählen und hybridverschlüsseln
				CDlgHybridEncryptionDemoSCA dlg;
				if(dlg.DoModal() == IDOK)
				{
					certificateSerial = dlg.getSelectedCertificateSerial();
					finalHybEncFile = dlg.getDocumentFileNameResult();
					originalSessionKey = dlg.getByteStringSymmetricKey().toString(16);
					CDialog::OnOK();
				}
				return;
			}
			// Fall (b)
			if(dlg.getRadioChoice2())
			{
				// ACHTUNG!!! Hier möchte der Benutzer die Hybridverschlüsselung NICHT SELBST durchführen,
				useExistingHybEncFile = true;
				// Default-PSE-Datei verwenden
				LoadString(AfxGetInstanceHandle(), IDS_SCA_HYBRIDENCRYPTEDFILE_DEFAULT_PSEFILE, pc_str, STR_LAENGE_STRING_TABLE);
				// Dateinamen setzen (VOLLER PFAD!)
				finalHybEncFile = CrypTool::getCrypToolPath() + "\\" + pc_str;
				// Zertifikatsinformationen ermitteln
				CrypTool::Cryptography::Asymmetric::AsymmetricAlgorithmType asymmetricAlgorithmType;
				CrypTool::Cryptography::Symmetric::SymmetricAlgorithmType symmetricAlgorithmType;
				CrypTool::ByteString byteStringSessionKeyEncrypted;
				CrypTool::ByteString byteStringCipherText;
				if (!CrypTool::Utilities::parseHybridEncryptedFile(finalHybEncFile, certificateSerial, asymmetricAlgorithmType, symmetricAlgorithmType, byteStringSessionKeyEncrypted, byteStringCipherText)) {
					CString message;
					message.Format(IDS_SCA_ERROR_CERTINFOEXTRACTION, finalHybEncFile);
					MessageBox(message, "CrypTool", MB_OK);
					return;
				}
				CDialog::OnOK();
				return;
			}
		}
	}
	// MÖGLICHKEIT [2]
	// ===============
	//	Benutzer hat beim Öffnen des SCA-Dialogs schon eine Datei geöffnet. Folglich gibt es drei
	//	Möglichkeiten: (a) Die Hybridverschlüsselung mit der geöffneten Datei selbst durchführen
	//	oder (b) die Hybridverschlüsselung mit einer anderen Datei durchführen oder (c) eine
	//	bereits hybridverschlüsselte Datei für einen schon angelegten Benutzer verwenden.
	else if(initMode & SCA_MODE_INVALID_FILE)
	{
		CDlgSideChannelAttackVisualizationHEPreparationsRequest2 dlg;
		if(dlg.DoModal() == IDOK)
		{
			// Fall (a)
			if(dlg.getRadioChoice1())
			{
				CDlgHybridEncryptionDemoSCA dlg(initFile, initFileTitle);
				if(dlg.DoModal() == IDOK)
				{
					certificateSerial = dlg.getSelectedCertificateSerial();
					finalHybEncFile = dlg.getDocumentFileNameResult();
					originalSessionKey = dlg.getByteStringSymmetricKey().toString(16);
					CDialog::OnOK();
				}
				return;
			}
			// Fall (b)
			if(dlg.getRadioChoice2())
			{
				// Benutzer möchte andere Datei wählen und hybridverschlüsseln
				CDlgHybridEncryptionDemoSCA dlg;
				if(dlg.DoModal() == IDOK)
				{
					certificateSerial = dlg.getSelectedCertificateSerial();
					finalHybEncFile = dlg.getDocumentFileNameResult();
					originalSessionKey = dlg.getByteStringSymmetricKey().toString(16);
					CDialog::OnOK();
				}
				return;
			}
			// Fall (c)
			if(dlg.getRadioChoice3())
			{
				// ACHTUNG!!! Hier möchte der Benutzer die Hybridverschlüsselung NICHT SELBST durchführen,
				useExistingHybEncFile = true;
				// Default-PSE-Datei verwenden
				LoadString(AfxGetInstanceHandle(), IDS_SCA_HYBRIDENCRYPTEDFILE_DEFAULT_PSEFILE, pc_str, STR_LAENGE_STRING_TABLE);
				// Dateinamen setzen (VOLLER PFAD!)
				finalHybEncFile = CrypTool::getCrypToolPath() + "\\" + pc_str;
				// Zertifikatsinformationen ermitteln
				CrypTool::Cryptography::Asymmetric::AsymmetricAlgorithmType asymmetricAlgorithmType;
				CrypTool::Cryptography::Symmetric::SymmetricAlgorithmType symmetricAlgorithmType;
				CrypTool::ByteString byteStringSessionKeyEncrypted;
				CrypTool::ByteString byteStringCipherText;
				if (!CrypTool::Utilities::parseHybridEncryptedFile(finalHybEncFile, certificateSerial, asymmetricAlgorithmType, symmetricAlgorithmType, byteStringSessionKeyEncrypted, byteStringCipherText)) {
					CString message;
					message.Format(IDS_SCA_ERROR_CERTINFOEXTRACTION, finalHybEncFile);
					MessageBox(message, "CrypTool", MB_OK);
					return;
				}
				CDialog::OnOK();
				return;
			}
		}
	}
	// MÖGLICHKEIT [3]
	// ===============
	//	Benutzer hat beim Öffnen des SCA-Dialogs schon eine hybridverschlüsselte Datei geöffnet.
	//	Folglich gibt es drei Möglichkeiten: (a) Die geöffnete hybridverschlüsselte Datei verwenden
	//	oder (b) die Hybridverschlüsselung mit einer anderen Datei durchführen oder (c) eine
	//	bereits hybridverschlüsselte Datei für einen schon angelegten Benutzer verwenden.
	else if(initMode & SCA_MODE_VALID_FILE)
	{
		CDlgSideChannelAttackVisualizationHEPreparationsRequest3 dlg;
		if(dlg.DoModal() == IDOK)
		{
			// Fall (a)
			if(dlg.getRadioChoice1())
			{
				// Benutzer möchte eine bereits existente und hybridverschlüsselte
				// Datei, die geöffnet ist, als Basis für Angriff verwenden
				useExistingHybEncFile = true;
				finalHybEncFile = initFile;
				// Zertifikatsinformationen ermitteln
				CrypTool::Cryptography::Asymmetric::AsymmetricAlgorithmType asymmetricAlgorithmType;
				CrypTool::Cryptography::Symmetric::SymmetricAlgorithmType symmetricAlgorithmType;
				CrypTool::ByteString byteStringSessionKeyEncrypted;
				CrypTool::ByteString byteStringCipherText;
				if (!CrypTool::Utilities::parseHybridEncryptedFile(finalHybEncFile, certificateSerial, asymmetricAlgorithmType, symmetricAlgorithmType, byteStringSessionKeyEncrypted, byteStringCipherText)) {
					CString message;
					message.Format(IDS_SCA_ERROR_CERTINFOEXTRACTION, finalHybEncFile);
					MessageBox(message, "CrypTool", MB_OK);
					return;
				}
				// ORIGINAL-Session-Key ermitteln nicht möglich, da Datei bereits verschlüsselt
				LoadString(AfxGetInstanceHandle(), IDS_SCA_CLIENT_SESSIONKEYUNKNOWN, pc_str, STR_LAENGE_STRING_TABLE);
				originalSessionKey = pc_str;
				CDialog::OnOK();
				return;
			}
			// Fall (b)
			if(dlg.getRadioChoice2())
			{
				// Benutzer möchte andere Datei wählen und hybridverschlüsseln
				CDlgHybridEncryptionDemoSCA dlg;
				if (dlg.DoModal() == IDOK)
				{
					certificateSerial = dlg.getSelectedCertificateSerial();
					finalHybEncFile = dlg.getDocumentFileNameResult();
					originalSessionKey = dlg.getByteStringSymmetricKey().toString(16);
					CDialog::OnOK();
				}
				return;
			}
			// Fall (c)
			if(dlg.getRadioChoice3())
			{
				// ACHTUNG!!! Hier möchte der Benutzer die Hybridverschlüsselung NICHT SELBST durchführen,
				useExistingHybEncFile = true;
				// Default-PSE-Datei verwenden
				LoadString(AfxGetInstanceHandle(), IDS_SCA_HYBRIDENCRYPTEDFILE_DEFAULT_PSEFILE, pc_str, STR_LAENGE_STRING_TABLE);
				// Dateinamen setzen (VOLLER PFAD!)
				finalHybEncFile = CrypTool::getCrypToolPath() + "\\" + pc_str;
				// Zertifikatsinformationen ermitteln
				CrypTool::Cryptography::Asymmetric::AsymmetricAlgorithmType asymmetricAlgorithmType;
				CrypTool::Cryptography::Symmetric::SymmetricAlgorithmType symmetricAlgorithmType;
				CrypTool::ByteString byteStringSessionKeyEncrypted;
				CrypTool::ByteString byteStringCipherText;
				if (!CrypTool::Utilities::parseHybridEncryptedFile(finalHybEncFile, certificateSerial, asymmetricAlgorithmType, symmetricAlgorithmType, byteStringSessionKeyEncrypted, byteStringCipherText)) {
					CString message;
					message.Format(IDS_SCA_ERROR_CERTINFOEXTRACTION, finalHybEncFile);
					MessageBox(message, "CrypTool", MB_OK);
					return;
				}
				CDialog::OnOK();
				return;
			}
		}
	}

	return;
}
Exemple #20
0
void CKillGrpDlg::OnCancel() 
{
	PlaySound((LPCTSTR)IDR_WAVE2, AfxGetInstanceHandle(), SND_RESOURCE | SND_ASYNC);
	CDialog::OnCancel();
}
Exemple #21
0
// This is called when the user first loads the add-in, and on start-up
//  of each subsequent Developer Studio session
STDMETHODIMP CDSAddIn::OnConnection(IApplication* pApp, VARIANT_BOOL bFirstTime,
		long dwCookie, VARIANT_BOOL* OnConnection)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	
	// Store info passed to us
	IApplication* pApplication = NULL;
	if (FAILED(pApp->QueryInterface(IID_IApplication, (void**) &pApplication))
		|| pApplication == NULL)
	{
		*OnConnection = VARIANT_FALSE;
		return S_OK;
	}

	m_dwCookie = dwCookie;

	// Create command dispatch, send info back to DevStudio
	CCommandsObj::CreateInstance(&m_pCommands);
	m_pCommands->AddRef();

	// The QueryInterface above AddRef'd the Application object.  It will
	//  be Release'd in CCommand's destructor.
	m_pCommands->SetApplicationObject(pApplication);

	// (see stdafx.h for the definition of VERIFY_OK)

	VERIFY_OK(pApplication->SetAddInInfo((long) AfxGetInstanceHandle(),
		(LPDISPATCH) m_pCommands, IDR_TOOLBAR_MEDIUM, IDR_TOOLBAR_LARGE, m_dwCookie));

	// Inform DevStudio of the commands we implement

	// TODO: Replace the AddCommand call below with a series of calls,
	//  one for each command your add-in will add.

	// The command name should not be localized to other languages.  The 
	//  tooltip, command description, and other strings related to this
	//  command are stored in the string table (IDS_CMD_STRING) and should
	//  be localized.
	LPCTSTR szCommand = _T("ShowGroupsAddinCommand");
	VARIANT_BOOL bRet;
	CString strCmdString;
	strCmdString.LoadString(IDS_CMD_STRING);
	strCmdString = szCommand + strCmdString;
	CComBSTR bszCmdString(strCmdString);
	CComBSTR bszMethod(_T("ShowGroupsAddinCommandMethod"));
	CComBSTR bszCmdName(szCommand);
	VERIFY_OK(pApplication->AddCommand(bszCmdString, bszMethod, 0, m_dwCookie, &bRet));
	if (bRet == VARIANT_FALSE)
	{
		// AddCommand failed because a command with this name already
		//  exists.  You may try adding your command under a different name.
		//  Or, you can fail to load as we will do here.
		*OnConnection = VARIANT_FALSE;
		return S_OK;
	}

	// Add toolbar buttons only if this is the first time the add-in
	//  is being loaded.  Toolbar buttons are automatically remembered
	//  by Developer Studio from session to session, so we should only
	//  add the toolbar buttons once.
	if (bFirstTime == VARIANT_TRUE)
	{
		VERIFY_OK(pApplication->
			AddCommandBarButton(dsGlyph, bszCmdName, m_dwCookie));
	}

	// Create the WWhizInterface.
	g_wwhizInterface = WWhizInterface2Create(AfxGetInstanceHandle(), pApplication);

	*OnConnection = VARIANT_TRUE;
	return S_OK;
}
BOOL CTimerCronApp::InitInstance()
{
	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。  否则,将无法创建窗口。
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	WNDCLASS wndMyClass;
	::GetClassInfo(AfxGetInstanceHandle(), "#32770", &wndMyClass);
	wndMyClass.lpszClassName ="TimerCron";
	AfxRegisterClass(&wndMyClass); //注册窗口类

	CWinApp::InitInstance();


	AfxEnableControlContainer();

	// 创建 shell 管理器,以防对话框包含
	// 任何 shell 树视图控件或 shell 列表视图控件。
	CShellManager *pShellManager = new CShellManager;

	// 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO:  应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));

	CTimerCronDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO:  在此放置处理何时用
		//  “确定”来关闭对话框的代码
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO:  在此放置处理何时用
		//  “取消”来关闭对话框的代码
	}
	else if (nResponse == -1)
	{
		TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
		TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
	}

	// 删除上面创建的 shell 管理器。
	if (pShellManager != NULL)
	{
		delete pShellManager;
	}

	// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
	//  而不是启动应用程序的消息泵。
	return FALSE;
}
Exemple #23
0
HMENU CSitesWnd::Plugin_GetViewMenu()
{
	return LoadMenu (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDM_SITES_VIEW));
}
void VBA::winSetLanguageOption(int option, bool force)
{
  if(((option == languageOption) && option != 2) && !force)
    return;
  switch(option) {
  case 0:
    {
      char lbuffer[10];

      if(GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME,
                       lbuffer, 10)) {
        HINSTANCE l = winLoadLanguage(lbuffer);
        if(l == NULL) {
          LCID locIdBase = MAKELCID( MAKELANGID( PRIMARYLANGID( GetSystemDefaultLangID() ), SUBLANG_NEUTRAL ), SORT_DEFAULT );
          if(GetLocaleInfo(locIdBase, LOCALE_SABBREVLANGNAME,
                           lbuffer, 10)) {
            l = winLoadLanguage(lbuffer);
            if(l == NULL) {
              //printErrorMessage(IDS_FAILED_TO_LOAD_LIBRARY,
                            //"Failed to load library %s",
                            //lbuffer);
              return;
            }
          }
        }
        AfxSetResourceHandle(l);
        if(languageModule != NULL)
#ifdef _AFXDLL
          AfxFreeLibrary( languageModule );
#else
          FreeLibrary( languageModule );
#endif
        languageModule = l;
      } else {
        //printErrorMessage(IDS_FAILED_TO_GET_LOCINFO,
                      //"Failed to get locale information");
        return;
      }
    }
    break;
  case 1:
    if(languageModule != NULL)
#ifdef _AFXDLL
      AfxFreeLibrary( languageModule );
#else
      FreeLibrary( languageModule );
#endif
    languageModule = NULL;
    AfxSetResourceHandle(AfxGetInstanceHandle());
    break;
  case 2:
    {
      if(!force) {
        LangSelect dlg;
        if(dlg.DoModal()) {
          HINSTANCE l = winLoadLanguage(languageName);
          if(l == NULL) {
            //printErrorMessage(IDS_FAILED_TO_LOAD_LIBRARY,
                          //"Failed to load library %s",
                          //languageName);
            return;
          }
          AfxSetResourceHandle(l);
          if(languageModule != NULL)
		  {
#ifdef _AFXDLL
            AfxFreeLibrary( languageModule );
#else
            FreeLibrary( languageModule );
#endif
		  }
          languageModule = l;
        }
      } else {
        if(languageName.IsEmpty())
          return;
        HINSTANCE l = winLoadLanguage(languageName);
        if(l == NULL) {
          //printErrorMessage(IDS_FAILED_TO_LOAD_LIBRARY,
                        //"Failed to load library %s",
                        //languageName);
          return;
        }
        AfxSetResourceHandle(l);
        if(languageModule != NULL)
          FreeLibrary(languageModule);
        languageModule = l;
      }
    }
    break;
  }
  languageOption = option;
  updateMenuBar();
}
BOOL CFamiTrackerApp::InitInstance()
{
	// InitCommonControls() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	InitCommonControls();
#ifdef SUPPORT_TRANSLATIONS
	LoadLocalization();
#endif
	CWinApp::InitInstance();

	TRACE("App: InitInstance\n");

	if (!AfxOleInit()) {
		TRACE("OLE initialization failed\n");
	}

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T(""));
	LoadStdProfileSettings(MAX_RECENT_FILES);  // Load standard INI file options (including MRU)

	// Load program settings
	m_pSettings = CSettings::GetObject();
	m_pSettings->LoadSettings();

	// Parse command line for standard shell commands, DDE, file open + some custom ones
	CFTCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	if (CheckSingleInstance(cmdInfo))
		return FALSE;

	//who: added by Derek Andrews <[email protected]>
	//why: Load all custom exporter plugins on startup.
	
	TCHAR pathToPlugins[MAX_PATH];
	GetModuleFileName(NULL, pathToPlugins, MAX_PATH);
	PathRemoveFileSpec(pathToPlugins);
	PathAppend(pathToPlugins, _T("\\Plugins"));
	m_customExporters = new CCustomExporters( pathToPlugins );

	// Load custom accelerator
	m_pAccel = new CAccelerator();
	m_pAccel->LoadShortcuts(m_pSettings);
	m_pAccel->Setup();

	// Create the MIDI interface
	m_pMIDI = new CMIDI();

	// Create sound generator
	m_pSoundGenerator = new CSoundGen();

	// Create channel map
	m_pChannelMap = new CChannelMap();

	// Start sound generator thread, initially suspended
	if (!m_pSoundGenerator->CreateThread(CREATE_SUSPENDED)) {
		// If failed, restore and save default settings
		m_pSettings->DefaultSettings();
		m_pSettings->SaveSettings();
		// Show message and quit
		AfxMessageBox(IDS_START_ERROR, MB_ICONERROR);
		return FALSE;
	}

	// Check if the application is themed
	CheckAppThemed();

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CDocTemplate0CC* pDocTemplate = new CDocTemplate0CC(		// // //
		IDR_MAINFRAME, 
		RUNTIME_CLASS(CFamiTrackerDoc), 
		RUNTIME_CLASS(CMainFrame), 
		RUNTIME_CLASS(CFamiTrackerView));

	if (!pDocTemplate)
		return FALSE;
	
	if (m_pDocManager == NULL)		// // //
		m_pDocManager = new CDocManager0CC { };
	m_pDocManager->AddDocTemplate(pDocTemplate);

	// Work-around to enable file type registration in windows vista/7
	if (IsWindowsVistaOrGreater()) {		// // //
		HKEY HKCU;
		long res_reg = ::RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Classes"), &HKCU);
		if(res_reg == ERROR_SUCCESS)
			RegOverridePredefKey(HKEY_CLASSES_ROOT, HKCU);
	}

	// Enable DDE Execute open
	EnableShellOpen();

	// Skip this if in wip/beta mode
#if !defined(WIP) && !defined(_DEBUG)
	// Add shell options
	RegisterShellFileTypes();		// // //
	static const LPCTSTR FILE_ASSOC_NAME = _T("0CC-FamiTracker Module");
	AfxRegSetValue(HKEY_CLASSES_ROOT, "0CCFamiTracker.Document", REG_SZ, FILE_ASSOC_NAME, lstrlen(FILE_ASSOC_NAME) * sizeof(TCHAR));
	// Add an option to play files
	CString strPathName, strTemp, strFileTypeId;
	AfxGetModuleShortFileName(AfxGetInstanceHandle(), strPathName);
	CString strOpenCommandLine = strPathName;
	strOpenCommandLine += _T(" /play \"%1\"");
	if (pDocTemplate->GetDocString(strFileTypeId, CDocTemplate::regFileTypeId) && !strFileTypeId.IsEmpty()) {
		strTemp.Format(_T("%s\\shell\\play\\%s"), (LPCTSTR)strFileTypeId, _T("command"));
		AfxRegSetValue(HKEY_CLASSES_ROOT, strTemp, REG_SZ, strOpenCommandLine, lstrlen(strOpenCommandLine) * sizeof(TCHAR));
	}
#endif

	// Handle command line export
	if (cmdInfo.m_bExport) {
		CCommandLineExport exporter;
		exporter.CommandLineExport(cmdInfo.m_strFileName, cmdInfo.m_strExportFile, cmdInfo.m_strExportLogFile, cmdInfo.m_strExportDPCMFile);
		ExitProcess(0);
	}

	// Dispatch commands specified on the command line.  Will return FALSE if
	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
	if (!ProcessShellCommand(cmdInfo)) {
		if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister) {
			// Also clear settings from registry when unregistering
			m_pSettings->DeleteSettings();
		}
		return FALSE;
	}

	// Move root key back to default
	if (IsWindowsVistaOrGreater()) {		// // //
		::RegOverridePredefKey(HKEY_CLASSES_ROOT, NULL);
	}

	// The one and only window has been initialized, so show and update it
	m_pMainWnd->ShowWindow(m_nCmdShow);
	m_pMainWnd->UpdateWindow();
	// call DragAcceptFiles only if there's a suffix
	//  In an SDI app, this should occur after ProcessShellCommand
	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();
	
	// Initialize the sound interface, also resumes the thread
	if (!m_pSoundGenerator->InitializeSound(m_pMainWnd->m_hWnd)) {
		// If failed, restore and save default settings
		m_pSettings->DefaultSettings();
		m_pSettings->SaveSettings();
		// Quit program
		AfxMessageBox(IDS_START_ERROR, MB_ICONERROR);
		return FALSE;
	}
	
	// Initialize midi unit
	m_pMIDI->Init();
	
	if (cmdInfo.m_bPlay)
		theApp.StartPlayer(MODE_PLAY);

#ifdef EXPORT_TEST
	if (cmdInfo.m_bVerifyExport) {
		m_bExportTesting = true;
		VerifyExport(cmdInfo.m_strVerifyFile);
	}
	else {
		// Append menu option
		m_pMainWnd->GetMenu()->GetSubMenu(2)->AppendMenu(MF_SEPARATOR);
		m_pMainWnd->GetMenu()->GetSubMenu(2)->AppendMenu(MF_STRING, ID_MODULE_TEST_EXPORT, _T("Test exporter"));
	}
#endif

	// Save the main window handle
	RegisterSingleInstance();

#ifndef _DEBUG
	m_pMainWnd->GetMenu()->GetSubMenu(4)->RemoveMenu(ID_MODULE_CHANNELS, MF_BYCOMMAND);		// // //
#endif

	if (m_pSettings->General.bCheckVersion)		// // //
		CheckNewVersion(true);

	// Initialization is done
	TRACE("App: InitInstance done\n");

	return TRUE;
}
BOOL VBA::InitInstance()
{
  SetRegistryKey(_T("VBA"));

  wndClass = AfxRegisterWndClass(0, LoadCursor(IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), LoadIcon(IDI_MAINICON));

  char winBuffer[2048];

  GetModuleFileName(NULL, winBuffer, 2048);
  char *p = strrchr(winBuffer, '\\');
  if(p)
    *p = 0;

  bool force = false;

  if (m_lpCmdLine[0])
  {
    if(__argc > 0) {
      if( 0 == strcmp( __argv[1], "--configpath" ) ) {
        if( __argc > 2 ) {
          strcpy( winBuffer, __argv[2] );
          force = true;
          if( __argc > 3 ) {
            filename = __argv[3];
          }
        }
      } else {
        filename = __argv[1];
      }
    }
  }

  regInit(winBuffer, force);

  loadSettings();

    if(!initDisplay()) {
    if(videoOption >= VIDEO_320x240) {
      regSetDwordValue("video", VIDEO_2X);
    }
    return FALSE;
  }

  
  if(!initInput())
    return FALSE;

  hAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR));

  winAccelMgr.Connect((MainWnd *)m_pMainWnd);

  winAccelMgr.SetRegKey(HKEY_CURRENT_USER, "Software\\Emulators\\VisualBoyAdvance");

  extern void winAccelAddCommands(CAcceleratorManager&);

  winAccelAddCommands(winAccelMgr);

  winAccelMgr.CreateDefaultTable();

  winAccelMgr.Load();

  winAccelMgr.UpdateWndTable();

  winAccelMgr.UpdateMenu(menu);

  if( !filename.IsEmpty() ) {
    if(((MainWnd*)m_pMainWnd)->FileRun())
      emulating = true;
    else
      emulating = false;
  }

  return TRUE;
}
Exemple #27
0
//创建函数
INT CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct) == -1) return -1;

	//创建控件
	CRect rcCreate(0, 0, 0, 0);
	m_ScoreControl.Create(NULL, NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, rcCreate, this, 100);
	m_ManualList.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY, rcCreate, this, IDC_MANUAL_LIST);

	//设置控件
	m_UserRequestPeace.m_cbRequestType = REQUEST_PEACE;
	m_UserRequestRegret.m_cbRequestType = REQUEST_REGRET;
	//m_ManualList.SetFont(&CSkinResourceManager::GetDefaultFont());

	//控制按钮
	m_btManual.Create(NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, rcCreate, this, IDC_MANUAL);
	m_btStart.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS, rcCreate, this, IDC_START);
	m_btPeace.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS, rcCreate, this, IDC_PEACE);
	m_btRegret.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS, rcCreate, this, IDC_REGRET);
	m_btGiveUp.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS, rcCreate, this, IDC_GIVEUP);
	m_btPreserve.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS, rcCreate, this, IDC_PRESERVE);

	//棋谱按钮
	m_btManualOpen.Create(NULL, WS_CHILD | WS_VISIBLE, rcCreate, this, IDC_MANUAL_BT_OPEN);
	m_btManualHead.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED, rcCreate, this, IDC_MANUAL_BT_HEAD);
	m_btManualLast.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED, rcCreate, this, IDC_MANUAL_BT_LAST);
	m_btManualNext.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED, rcCreate, this, IDC_MANUAL_BT_NEXT);
	m_btManualTail.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED, rcCreate, this, IDC_MANUAL_BT_TAIL);

	//控制按钮
	HINSTANCE hResInstance = AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_BT_START, hResInstance, false);
	m_btPeace.SetButtonImage(IDB_BT_PEACE, hResInstance, false);
	m_btManual.SetButtonImage(IDB_BT_MANUAL, hResInstance, false);
	m_btGiveUp.SetButtonImage(IDB_BT_GIVEUP, hResInstance, false);
	m_btRegret.SetButtonImage(IDB_BT_REGRET, hResInstance, false);
	m_btPreserve.SetButtonImage(IDB_BT_PRESERVE, hResInstance, false);

	//棋谱按钮
	m_btManualHead.SetButtonImage(IDB_MANUAL_BT_HEAD, hResInstance, false);
	m_btManualNext.SetButtonImage(IDB_MANUAL_BT_NEXT, hResInstance, false);
	m_btManualTail.SetButtonImage(IDB_MANUAL_BT_TAIL, hResInstance, false);
	m_btManualOpen.SetButtonImage(IDB_MANUAL_BT_OPEN, hResInstance, false);
	m_btManualLast.SetButtonImage(IDB_MANUAL_BT_LAST, hResInstance, false);

	//建立提示
	m_ToolTipCtrl.Create(this);
	m_ToolTipCtrl.Activate(TRUE);

	//控制提示
	m_ToolTipCtrl.AddTool(&m_btStart, TEXT("开始"));
	m_ToolTipCtrl.AddTool(&m_btPeace, TEXT("求和"));
	m_ToolTipCtrl.AddTool(&m_btManual, TEXT("棋谱"));
	m_ToolTipCtrl.AddTool(&m_btGiveUp, TEXT("认输"));
	m_ToolTipCtrl.AddTool(&m_btRegret, TEXT("悔棋"));
	m_ToolTipCtrl.AddTool(&m_btPreserve, TEXT("保存"));

	//棋谱提示
	m_ToolTipCtrl.AddTool(&m_btManualHead, TEXT("最前"));
	m_ToolTipCtrl.AddTool(&m_btManualLast, TEXT("前一步"));
	m_ToolTipCtrl.AddTool(&m_btManualOpen, TEXT("打开棋谱"));
	m_ToolTipCtrl.AddTool(&m_btManualNext, TEXT("下一步"));
	m_ToolTipCtrl.AddTool(&m_btManualTail, TEXT("最后"));

#ifdef VIDEO_GAME
	//创建视频
	for (WORD i = 0; i < GAME_PLAYER; i++)
	{
		//创建视频
		m_DlgVideoService[i].Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rcCreate, this, 200 + i);
		m_DlgVideoService[i].InitVideoService(i == 1, i == 1);

		//设置视频
		g_VideoServiceManager.SetVideoServiceControl(i, &m_DlgVideoService[i]);
	}
#endif
	//创建窗口
	//CDlgUserRequest * pDlgUserHint=&m_UserRequestRegret;
	//if (pDlgUserHint->m_hWnd==NULL) pDlgUserHint->Create(IDD_USER_REQUEST,this);

	////显示窗口
	//pDlgUserHint->ShowWindow(SW_SHOW);
	//pDlgUserHint->SetForegroundWindow();

	////创建窗口
	//CDlgHint * pDlgUserHint=&m_UserHint;
	//if (pDlgUserHint->m_hWnd==NULL) pDlgUserHint->Create(IDD_USER_HINT,this);

	//////显示窗口
	//pDlgUserHint->ShowWindow(SW_SHOW);
	//pDlgUserHint->SetForegroundWindow();

	//m_ScoreControl.ShowWindow(5);
	return 0;
}
HINSTANCE CCSHPropertySheet::GetInstanceHandle()
{
  return AfxGetInstanceHandle();
}
BOOL CDlgShowPrivateKeyEC::OnInitDialog() 
{
	CDialog::OnInitDialog();

	LOGFONT LogFont;
	LONG defaultFontWeight;
	CFont *defaultFont = m_InfoKeyCreatedByCtrl.GetFont();
	defaultFont->GetLogFont( &LogFont ); // Default Systemschrift ermitteln
	defaultFontWeight = LogFont.lfWeight; // Default Wert sichern
	LogFont.lfWeight = FW_BOLD; // Auf Fettdruck umstellen
	m_Font.CreateFontIndirect( &LogFont ); // Font initialisieren
	m_TextKeyCreatDateCtrl.SetFont(&m_Font);
	m_TextKeyTypeCtrl.SetFont(&m_Font);
	m_TextKeyOwnerCtrl.SetFont(&m_Font);


	CheckRadioButton (IDC_RADIO1, IDC_RADIO3, IDC_RADIO2); // base 10 is default
	base = 10;

	// Info about Key Owner
	LoadString(AfxGetInstanceHandle(),IDS_STRING_KEY_OWNER,pc_str,STR_LAENGE_STRING_TABLE);
	m_TextKeyOwner = (CString) pc_str;
	m_InfoKeyCreatedBy = Firstname+((CString)" ")+Name; // Created by

	LoadString(AfxGetInstanceHandle(),IDS_STRING_KEY_TYPE,pc_str,STR_LAENGE_STRING_TABLE);
	m_TextKeyType = (CString) pc_str;
	m_InfoKeyType = curveID; // Key Type

	LoadString(AfxGetInstanceHandle(),IDS_STRING_KEY_GENERATION_DATE,pc_str,STR_LAENGE_STRING_TABLE);
	m_TextKeyCreatDate = (CString) pc_str;
	m_InfoCreatTime = CreatTime; // Time of key creation

	UpdateData(FALSE);

	// m_dom_param_listview aufbauen
	UpdateData(TRUE);
	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_DOMAIN_PARAMETER,pc_str,STR_LAENGE_STRING_TABLE);
	sprintf(pc_str1, pc_str, curveID);
	m_ec_dom_par_editbox = (CString) pc_str1;
	UpdateData(FALSE);
	LoadString(AfxGetInstanceHandle(),IDS_STRING_PARAMETER,pc_str,STR_LAENGE_STRING_TABLE);
	m_dom_param_listview.InsertColumn( 0, pc_str, LVCFMT_RIGHT, 65 , 0); // Parameter

	LoadString(AfxGetInstanceHandle(),IDS_STRING_PARAMETER_VALUE,pc_str,STR_LAENGE_STRING_TABLE);
	m_dom_param_listview.InsertColumn( 1, pc_str, LVCFMT_LEFT, 455 , 1); // Wert des Parameters

	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_PARAM_BITLENGTH,pc_str,STR_LAENGE_STRING_TABLE);
	m_dom_param_listview.InsertColumn( 2, pc_str, LVCFMT_LEFT, 50 , 2); // Bitlänge

	// m_pubKey_listview aufbauen
	m_pubKey_listview.DeleteAllItems(); // Delete all data in the listview
	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_PARAM_PUBLIC_KEY,pc_str,STR_LAENGE_STRING_TABLE);
	m_pubKey_listview.InsertColumn( 0, pc_str, LVCFMT_RIGHT, 520 , 0);
	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_PARAM_BITLENGTH,pc_str,STR_LAENGE_STRING_TABLE);
	m_pubKey_listview.InsertColumn( 1, pc_str, LVCFMT_LEFT, 50 , 1); // Bitlänge

	// m_privKey_listview aufbauen
	m_privKey_listview.DeleteAllItems(); // Delete all data in the listview
	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_PARAM_PRIVATE_KEY,pc_str,STR_LAENGE_STRING_TABLE);
	m_privKey_listview.InsertColumn( 0, pc_str, LVCFMT_LEFT, 520 , 0);
	LoadString(AfxGetInstanceHandle(),IDS_STRING_EC_PARAM_BITLENGTH,pc_str,STR_LAENGE_STRING_TABLE);
	m_privKey_listview.InsertColumn( 1, pc_str, LVCFMT_LEFT, 50 , 1); // Bitlänge

	// Daten ausgeben
	int error = EcDomParamAcToString(&ecParamString, curveParameter, base);
	if (error > 0)
	{
		// Fehler. Umwandlung der Domain Parameter in String nicht möglich.
		Message(IDS_STRING_ERR_EC_ON_CONVERT_PARAM,MB_ICONSTOP);
		return TRUE;
	}

	UpdateEcListBox();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
} 
Exemple #30
0
//游戏场景
bool CGameClientDlg::OnGameSceneMessage(BYTE cbGameStation, bool bLookonOther, const void * pBuffer, WORD wDataSize)
{
	switch (cbGameStation)
	{
	case GS_MJ_FREE:	//空闲状态
		{
			//效验数据
			if (wDataSize!=sizeof(CMD_S_StatusFree)) return false;
			CMD_S_StatusFree * pStatusFree=(CMD_S_StatusFree *)pBuffer;

			//设置数据
			m_wBankerUser=pStatusFree->wBankerUser;
			m_GameClientView.SetCellScore(pStatusFree->lCellScore);
			m_GameClientView.m_HandCardControl.SetDisplayItem(true);
			//托管设置
			for (WORD i=0;i<GAME_PLAYER;i++)
			{
				m_GameClientView.SetTrustee(SwitchViewChairID(i),pStatusFree->bTrustee[i]);
			}


			//设置界面
			for (WORD i=0;i<GAME_PLAYER;i++)
			{
				m_cbHeapCardInfo[i][0]=0;
				m_cbHeapCardInfo[i][1]=HEAP_FULL_COUNT-(((i==m_wBankerUser)||((i+2)%4==m_wBankerUser))?34:34);
				m_GameClientView.m_HeapCard[SwitchViewChairID(i)].SetCardData(m_cbHeapCardInfo[i][0],m_cbHeapCardInfo[i][1],HEAP_FULL_COUNT);
			}

			//设置控件
			if (IsLookonMode()==false)
			{
				m_GameClientView.m_btStart.ShowWindow(SW_SHOW);
				m_GameClientView.m_btStart.SetFocus();
				m_GameClientView.m_btStusteeControl.EnableWindow(TRUE);
				SetGameTimer(GetMeChairID(),IDI_START_GAME,TIME_START_GAME);
			}

			//丢弃效果
			m_GameClientView.SetDiscUser(INVALID_CHAIR);
			m_GameClientView.SetTimer(IDI_DISC_EFFECT,250,NULL);

			//更新界面
			m_GameClientView.UpdateGameView(NULL);

			return true;
		}
	case GS_MJ_PLAY:	//游戏状态
		{
			//效验数据
			if (wDataSize!=sizeof(CMD_S_StatusPlay)) return false;
			CMD_S_StatusPlay * pStatusPlay=(CMD_S_StatusPlay *)pBuffer;

			//设置变量
			m_wBankerUser=pStatusPlay->wBankerUser;
			m_wCurrentUser=pStatusPlay->wCurrentUser;
			m_cbLeftCardCount=pStatusPlay->cbLeftCardCount;
			m_bStustee=pStatusPlay->bTrustee[GetMeChairID()];

			//旁观
			if( IsLookonMode()==true )
				m_GameClientView.m_HandCardControl.SetDisplayItem(IsAllowLookon()||IsAllowUserLookon());

			//托管设置
			for (WORD i=0;i<GAME_PLAYER;i++)
			{
				m_GameClientView.SetTrustee(SwitchViewChairID(i),pStatusPlay->bTrustee[i]);
			}

			m_wTimeOutCount=0;
			if(pStatusPlay->bTrustee[GetMeChairID()])
				m_GameClientView.m_btStusteeControl.SetButtonImage(IDB_BT_STOP_TRUSTEE,AfxGetInstanceHandle(),false);
			else
				m_GameClientView.m_btStusteeControl.SetButtonImage(IDB_BT_START_TRUSTEE,AfxGetInstanceHandle(),false);
			
			//听牌状态
			WORD wMeChairID=GetMeChairID();
			m_bHearStatus=(pStatusPlay->cbHearStatus[wMeChairID]==TRUE)?true:false;

			//历史变量
			m_wOutCardUser=pStatusPlay->wOutCardUser;
			m_cbOutCardData=pStatusPlay->cbOutCardData;
			CopyMemory(m_cbDiscardCard,pStatusPlay->cbDiscardCard,sizeof(m_cbDiscardCard));
			CopyMemory(m_cbDiscardCount,pStatusPlay->cbDiscardCount,sizeof(m_cbDiscardCount));

			//丢弃效果
			if(m_wOutCardUser != INVALID_CHAIR)
				m_GameClientView.SetDiscUser(SwitchViewChairID(m_wOutCardUser));
			m_GameClientView.SetTimer(IDI_DISC_EFFECT,250,NULL);

			//扑克变量
			CopyMemory(m_cbWeaveCount,pStatusPlay->cbWeaveCount,sizeof(m_cbWeaveCount));
			CopyMemory(m_WeaveItemArray,pStatusPlay->WeaveItemArray,sizeof(m_WeaveItemArray));
			m_GameLogic.SwitchToCardIndex(pStatusPlay->cbCardData,pStatusPlay->cbCardCount,m_cbCardIndex);

			//辅助变量
			WORD wViewChairID[GAME_PLAYER]={0,0,0,0};
			for (WORD i=0;i<GAME_PLAYER;i++) wViewChairID[i]=SwitchViewChairID(i);

			//界面设置
			m_GameClientView.SetCellScore(pStatusPlay->lCellScore);
			m_GameClientView.SetBankerUser(wViewChairID[m_wBankerUser]);

			//组合扑克
			BYTE cbWeaveCard[4]={0,0,0,0};
			for (WORD i=0;i<GAME_PLAYER;i++)
			{
				WORD wOperateViewID = SwitchViewChairID(i);
				for (BYTE j=0;j<m_cbWeaveCount[i];j++)
				{
					BYTE cbWeaveKind=m_WeaveItemArray[i][j].cbWeaveKind;
					BYTE cbCenterCard=m_WeaveItemArray[i][j].cbCenterCard;
					BYTE cbWeaveCardCount=m_GameLogic.GetWeaveCard(cbWeaveKind,cbCenterCard,cbWeaveCard);
					m_GameClientView.m_WeaveCard[wViewChairID[i]][j].SetCardData(cbWeaveCard,cbWeaveCardCount);
					if ((cbWeaveKind&WIK_GANG)&&(m_WeaveItemArray[i][j].wProvideUser==i)) 
						m_GameClientView.m_WeaveCard[wViewChairID[i]][j].SetDisplayItem(false);
					WORD wProviderViewID = SwitchViewChairID(m_WeaveItemArray[i][j].wProvideUser);
					m_GameClientView.m_WeaveCard[wOperateViewID][j].SetDirectionCardPos(3-(wOperateViewID-wProviderViewID+4)%4);

				}

				//听牌状态
				if (pStatusPlay->cbHearStatus[i]==TRUE) 
				{
					WORD wViewChairID=SwitchViewChairID(i);
					m_GameClientView.SetUserListenStatus(wViewChairID,true);
				}
			}

			//用户扑克
			if (m_wCurrentUser==GetMeChairID())
			{
				//调整扑克
				if (pStatusPlay->cbSendCardData!=0x00)
				{
					//变量定义
					BYTE cbCardCount=pStatusPlay->cbCardCount;
					BYTE cbRemoveCard[]={pStatusPlay->cbSendCardData};

					//调整扑克
					m_GameLogic.RemoveCard(pStatusPlay->cbCardData,cbCardCount,cbRemoveCard,1);
					pStatusPlay->cbCardData[pStatusPlay->cbCardCount-1]=pStatusPlay->cbSendCardData;
				}
				//设置扑克
				BYTE cbCardCount=pStatusPlay->cbCardCount;
				m_GameClientView.m_HandCardControl.SetCardData(pStatusPlay->cbCardData,cbCardCount-1,pStatusPlay->cbCardData[cbCardCount-1]);

			}
			else 
				m_GameClientView.m_HandCardControl.SetCardData(pStatusPlay->cbCardData,pStatusPlay->cbCardCount,0); 

			//扑克设置
			for (WORD i=0;i<GAME_PLAYER;i++)
			{
				//用户扑克
				if (i!=GetMeChairID())
				{
					BYTE cbCardCount=13-m_cbWeaveCount[i]*3;
					WORD wUserCardIndex=(wViewChairID[i]<2)?wViewChairID[i]:2;
					m_GameClientView.m_UserCard[wUserCardIndex].SetCardData(cbCardCount,(m_wCurrentUser==i));
				}

				//丢弃扑克
				WORD wViewChairID=SwitchViewChairID(i);
				m_GameClientView.m_DiscardCard[wViewChairID].SetCardData(m_cbDiscardCard[i],m_cbDiscardCount[i]);
			}

			//控制设置
			if (IsLookonMode()==false) 
			{
				m_GameClientView.m_HandCardControl.SetPositively(true);
				m_GameClientView.m_HandCardControl.SetDisplayItem(true);
				m_GameClientView.m_btStusteeControl.EnableWindow(TRUE);
			}

			//堆立扑克
			for (WORD i=0;i<GAME_PLAYER;i++)
			{
				m_cbHeapCardInfo[i][0]=0;
				m_cbHeapCardInfo[i][1]=HEAP_FULL_COUNT-(((i==m_wBankerUser)||((i+2)%4==m_wBankerUser))?34:34);
			}

			//分发扑克
			BYTE cbTakeCount=MAX_REPERTORY-m_cbLeftCardCount;
			BYTE cbSiceFirst=HIBYTE(pStatusPlay->wSiceCount);
			BYTE cbSiceSecond=LOBYTE(pStatusPlay->wSiceCount);
			WORD wTakeChairID=(m_wBankerUser+7-cbSiceFirst)%GAME_PLAYER;
			for (WORD i=0;i<GAME_PLAYER;i++)
			{
				//计算数目
				BYTE cbValidCount=HEAP_FULL_COUNT-m_cbHeapCardInfo[wTakeChairID][1]-((i==0)?(cbSiceSecond-1)*2:0);
				BYTE cbRemoveCount=__min(cbValidCount,cbTakeCount);

				//提取扑克
				cbTakeCount-=cbRemoveCount;
				m_cbHeapCardInfo[wTakeChairID][(i==0)?1:0]+=cbRemoveCount;

				//完成判断
				if (cbTakeCount==0)
				{
					m_wHeapHand=wTakeChairID;
					m_wHeapTail=(m_wBankerUser+7-cbSiceFirst)%GAME_PLAYER;
					break;
				}

				//切换索引
				wTakeChairID=(wTakeChairID+1)%GAME_PLAYER;
			}

			//堆立界面
			for (WORD i=0;i<GAME_PLAYER;i++)
			{
				m_GameClientView.m_HeapCard[wViewChairID[i]].SetCardData(m_cbHeapCardInfo[i][0],m_cbHeapCardInfo[i][1],HEAP_FULL_COUNT);
			}

			//历史扑克
			if (m_wOutCardUser!=INVALID_CHAIR)
			{
				WORD wOutChairID=SwitchViewChairID(m_wOutCardUser);
				m_GameClientView.SetOutCardInfo(wOutChairID,m_cbOutCardData);
			}


			//操作界面
			if ((IsLookonMode()==false)&&(pStatusPlay->cbActionMask!=WIK_NULL))
			{
				//获取变量
				BYTE cbActionMask=pStatusPlay->cbActionMask;
				BYTE cbActionCard=pStatusPlay->cbActionCard;

				//变量定义
				tagGangCardResult GangCardResult;
				ZeroMemory(&GangCardResult,sizeof(GangCardResult));

				//杠牌判断
				if ((cbActionMask&WIK_GANG)!=0)
				{
					//桌面杆牌
					if ((m_wCurrentUser==INVALID_CHAIR)&&(cbActionCard!=0))
					{
						GangCardResult.cbCardCount=1;
						GangCardResult.cbCardData[0]=cbActionCard;
					}

					//自己杆牌
					if ((m_wCurrentUser==GetMeChairID())||(cbActionCard==0))
					{
						WORD wMeChairID=GetMeChairID();
						m_GameLogic.AnalyseGangCard(m_cbCardIndex,m_WeaveItemArray[wMeChairID],m_cbWeaveCount[wMeChairID],GangCardResult);
					}
				}

				//设置界面
				if (m_wCurrentUser==INVALID_CHAIR)
					SetGameTimer(GetMeChairID(),IDI_OPERATE_CARD,TIME_OPERATE_CARD);
				if (IsLookonMode()==false) 
					m_GameClientView.m_ControlWnd.SetControlInfo(cbActionCard,cbActionMask,GangCardResult);
			}

			//设置时间
			if (m_wCurrentUser!=INVALID_CHAIR)
			{
				//计算时间
				WORD wTimeCount=TIME_OPERATE_CARD;
				if ((m_bHearStatus==true)&&(m_wCurrentUser==GetMeChairID()))
					wTimeCount=TIME_HEAR_STATUS;
				//ASSERT(FALSE);

				//设置时间
				SetGameTimer(m_wCurrentUser,TIME_OPERATE_CARD,wTimeCount);
			}

			//丢弃效果
			m_GameClientView.SetDiscUser(SwitchViewChairID(m_wOutCardUser));
			m_GameClientView.SetTimer(IDI_DISC_EFFECT,250,NULL);

			//更新界面
			m_GameClientView.UpdateGameView(NULL);

			return true;
		}
	}

	return false;
}