Exemple #1
0
BOOL CCP_MainApp::InitInstance()
{
	AfxEnableControlContainer();
	AfxOleInit();
	AfxInitRichEditEx();

	DittoCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);
	if(cmdInfo.m_strFileName.IsEmpty() == FALSE)
	{
		try
		{
			g_Opt.m_bEnableDebugLogging = g_Opt.GetEnableDebugLogging();

			CClip_ImportExport Clip;
			CppSQLite3DB db;
			db.open(cmdInfo.m_strFileName);

			CClip_ImportExport clip;
			if(clip.ImportFromSqliteDB(db, false, true))
			{
				ShowCommandLineError("Ditto", theApp.m_Language.GetString("Importing_Good", "Clip placed on clipboard"));
			}
			else
			{
				ShowCommandLineError("Ditto", theApp.m_Language.GetString("Error_Importing", "Error importing exported clip"));
			}
		}
		catch (CppSQLite3Exception& e)
		{
			ASSERT(FALSE);

			CString csError;
			csError.Format(_T("%s - Exception - %d - %s"), theApp.m_Language.GetString("Error_Parsing", "Error parsing exported clip"), e.errorCode(), e.errorMessage());
			ShowCommandLineError("Ditto", csError);
		}	

		return FALSE;
	}
	else if(cmdInfo.m_bConnect || cmdInfo.m_bDisconnect)
	{
		HWND hWnd = (HWND)CGetSetOptions::GetMainHWND();
		if(hWnd)
			::SendMessage(hWnd, WM_SET_CONNECTED, cmdInfo.m_bConnect, cmdInfo.m_bDisconnect);

		return FALSE;
	}

	//if starting from a u3 device we will pass in -U3Start
	if(cmdInfo.m_bU3)
		g_Opt.m_bU3 = cmdInfo.m_bU3 ? TRUE : FALSE;

	g_Opt.LoadSettings();

	CInternetUpdate update;

	long lRunningVersion = update.GetRunningVersion();
	CString cs = update.GetVersionString(lRunningVersion);
	cs.Insert(0, _T("InitInstance  -  Running Version - "));
	Log(cs);

	CString csMutex("Ditto Is Now Running");
	if(g_Opt.m_bU3)
	{
		//If running from a U3 device then allow other ditto's to run
		//only prevent Ditto from running from the same device
		csMutex += " ";
		csMutex += GETENV(_T("U3_DEVICE_SERIAL"));
	}
	else if(g_Opt.GetIsPortableDitto())
	{
		csMutex += " ";
		csMutex += g_Opt.GetExeFileName();
	}

	m_hMutex = CreateMutex(NULL, FALSE, csMutex);
	DWORD dwError = GetLastError();
	if(dwError == ERROR_ALREADY_EXISTS)
	{
		HWND hWnd = (HWND)CGetSetOptions::GetMainHWND();
		if(hWnd)
			::SendMessage(hWnd, WM_SHOW_TRAY_ICON, TRUE, TRUE);

		return TRUE;
	}

	CString csFile = CGetSetOptions::GetLanguageFile();
	if(csFile.GetLength() > 0 && !m_Language.LoadLanguageFile(csFile))
	{
		CString cs;
		cs.Format(_T("Error loading language file - %s - \n\n%s"), csFile, m_Language.m_csLastError);
		Log(cs);
	}

	//The first time we run Ditto on U3 show a web page about ditto
	if(g_Opt.m_bU3)
	{
		if(FileExists(CGetSetOptions::GetDBPath()) == FALSE)
		{
			CString csFile = CGetSetOptions::GetPath(PATH_HELP);
			csFile += "U3_Install.htm";
			CHyperLink::GotoURL(csFile, SW_SHOW);
		}
	}

	int nRet = CheckDBExists(CGetSetOptions::GetDBPath());
	if(nRet == FALSE)
	{
		AfxMessageBox(theApp.m_Language.GetString("Error_Opening_Database", "Error Opening Database."));
		return FALSE;
	}

	CMainFrame* pFrame = new CMainFrame;
	m_pMainWnd = m_pMainFrame = pFrame;

	// prevent no one having focus on startup
	TargetActiveWindow();

	pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL);
	pFrame->ShowWindow(SW_SHOW);
	pFrame->UpdateWindow();

	// prevent no one having focus on startup
	ReleaseFocus();

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

	CWinApp::InitInstance();


	// 初始化 OLE 库
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	EnableTaskbarInteraction(FALSE);

	// 使用 RichEdit 控件需要  AfxInitRichEdit2()	
	// AfxInitRichEdit2();

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


	// 若要创建主窗口,此代码将创建新的框架窗口
	// 对象,然后将其设置为应用程序的主窗口对象
	CMainFrame* pFrame = new CMainFrame;
	if (!pFrame)
		return FALSE;
	m_pMainWnd = pFrame;
	// 创建并加载框架及其资源
	pFrame->LoadFrame(IDR_MAINFRAME,
		WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);






	// 唯一的一个窗口已初始化,因此显示它并对其进行更新
	pFrame->ShowWindow(SW_SHOW);
	pFrame->UpdateWindow();
	// 仅当具有后缀时才调用 DragAcceptFiles
	//  在 SDI 应用程序中,这应在 ProcessShellCommand 之后发生
	int nPort = 9527;
	int nMaxConnection = 10000;
	((CMainFrame*) m_pMainWnd)->Activate(nPort, nMaxConnection);
	return TRUE;
}
Exemple #3
0
BOOL CTestCBotApp::InitInstance()
{
//////////////////////////////////////////////
//	défini les mots clefs supplémentaires
// -------------------------------------------

	CBotProgram::Init();
 
//////////////////////////////////////////////
//	défini les fonctions "show()" et "print()"
// -------------------------------------------

	CBotProgram::AddFunction("show", rShow, cShow);
	CBotProgram::AddFunction("print", rPrint, cPrint);
	CBotProgram::AddFunction("println", rPrintLn, cPrint);


///////////////////////////////////
// définie la classe globale CPoint
// --------------------------------

	m_pClassPoint	= new CBotClass("CPoint", NULL);
	// ajoute le composant ".x"
	m_pClassPoint->AddItem("x", CBotTypFloat);
	// ajoute le composant ".y"
	m_pClassPoint->AddItem("y", CBotTypFloat);

	// ajoute le constructeur pour cette classe
	m_pClassPoint->AddFunction("CPoint", rCPoint, cCPoint);

	m_pClassPointIntr	= new CBotClass("point", NULL, TRUE);
	// ajoute le composant ".x"
	m_pClassPointIntr->AddItem("x", CBotTypFloat);
	// ajoute le composant ".y"
	m_pClassPointIntr->AddItem("y", CBotTypFloat);
	// ajoute le composant ".z"
	m_pClassPointIntr->AddItem("z", CBotTypFloat);

	// ajoute le constructeur pour cette classe
	m_pClassPointIntr->AddFunction("point", rCPoint, cCPoint);

	// défini la classe "object"
	CBotClass*	pClassObject = new CBotClass( "object", NULL ) ;
	pClassObject->AddItem( "xx", CBotTypFloat );
	pClassObject->AddItem( "position", CBotTypResult( CBotTypIntrinsic, "point" ) );
	pClassObject->AddItem( "transport", CBotTypResult( CBotTypPointer, "object" ) );
	pClassObject->AddUpdateFunc( rMajObject );

	InitClassFILE();
	
	AfxEnableControlContainer();

	// Standard initialization

#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.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register document templates

	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_TESTCBTYPE,
		RUNTIME_CLASS(CTestCBotDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CTestCBotView));
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	if (m_lpCmdLine[0] == 0)
	{
		CString Filename = GetProfileString(szSection, szFilename);
		if (Filename.IsEmpty()) Filename = "TstCbot.txt";
		else OpenDocumentFile(Filename);
	}
	else
		// Dispatch commands specified on the command line
		if (!ProcessShellCommand(cmdInfo))
			return FALSE;
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();


	return TRUE;
}
BOOL CRadiantApp::InitInstance()
{
  //g_hOpenGL32 = ::LoadLibrary("opengl32.dll");
	// AfxEnableControlContainer();

	// 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.
  //AfxEnableMemoryTracking(FALSE);

#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.
	// You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey("QERadiant");

	LoadStdProfileSettings(_AFX_MRU_MAX_COUNT);  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

//	CMultiDocTemplate* pDocTemplate;
//	pDocTemplate = new CMultiDocTemplate(
//		IDR_RADIANTYPE,
//		RUNTIME_CLASS(CRadiantDoc),
//		RUNTIME_CLASS(CMainFrame), // custom MDI child frame
//		RUNTIME_CLASS(CRadiantView));
//	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window

  g_PrefsDlg.LoadPrefs();

  CString strOpenGL = (g_PrefsDlg.m_bSGIOpenGL) ? "opengl.dll" : "opengl32.dll";
  CString strGLU = (g_PrefsDlg.m_bSGIOpenGL) ? "glu.dll" : "glu32.dll";
  
  if (!QGL_Init(strOpenGL, strGLU))
  {
    g_PrefsDlg.m_bSGIOpenGL ^= 1;
    strOpenGL = (g_PrefsDlg.m_bSGIOpenGL) ? "opengl.dll" : "opengl32.dll";
    strGLU = (g_PrefsDlg.m_bSGIOpenGL) ? "glu.dll" : "glu32.dll";
    if (!QGL_Init(strOpenGL, strGLU))
    {
      AfxMessageBox("Failed to load OpenGL libraries. \"OPENGL32.DLL\" and \"OPENGL.DLL\" were tried");
      return FALSE;
    }
    g_PrefsDlg.SavePrefs();
  }


  CString strTemp = m_lpCmdLine;
  strTemp.MakeLower();
  if (strTemp.Find("builddefs") >= 0)
    g_bBuildList = true;



	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;

  if (pMainFrame->m_hAccelTable)
	{
    ::DestroyAcceleratorTable(pMainFrame->m_hAccelTable);
		pMainFrame->m_hAccelTable=NULL;
	}
  
  pMainFrame->LoadAccelTable(MAKEINTRESOURCE(IDR_MINIACCEL));


	m_pMainWnd = pMainFrame;

  // Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	if (cmdInfo.m_strFileName.CompareNoCase("builddefs")==-1)
	{
		// Dispatch commands specified on the command line..... if command line was not "builddefs"
//		if (!ProcessShellCommand(cmdInfo))
//			return FALSE;
	}

	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	return TRUE;
}
Exemple #5
0
BOOL CPrssrApp::InitInstance() {
	LOG0(1, "CPrssrApp::InitInstance()");

	LoadSSL();
	// init win sock
	WSADATA wsaData;
	WSAStartup(0x0101, &wsaData);

	// Change the registry key under which our settings are stored.
	SetRegistryKey(_T("DaProfik"));

	// register wnd class
	WNDCLASS wc = { 0 };
	wc.lpfnWndProc = ::DefWindowProc;
	wc.hInstance = AfxGetInstanceHandle();
	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = PRSSR_CLASS_NAME;
	if (!AfxRegisterClass(&wc))
		return FALSE;

	CFeedView::Register();
	CGroupView::Register();
	CTextProgressCtrl::Register();
	CInfoBar::Register();

	// get DPI
	HDC hdcScreen = ::GetDC(NULL);
	int nSystemDPI = ::GetDeviceCaps(hdcScreen, LOGPIXELSX);
	::ReleaseDC(NULL, hdcScreen);

	// load the resource library according to the system DPI
	CString resLibName;
	resLibName.Format(_T("res.%03d.dll"), nSystemDPI);
	m_hResDLL = LoadLibrary(resLibName);
	if (m_hResDLL == NULL) return Error(IDS_INTERNAL_ERROR, 0x00000002);

	if (!InitHTMLControl(AfxGetInstanceHandle()))
		return 0;

	// Initialize the control
	INITCOMMONCONTROLSEX icce;
	icce.dwSize = sizeof(icce);
	icce.dwICC = ICC_DATE_CLASSES | ICC_LISTVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_UPDOWN_CLASS | ICC_TREEVIEW_CLASSES | ICC_TOOLTIP_CLASSES | ICC_TAB_CLASSES;
	InitCommonControlsEx(&icce);

	SHInitExtraControls();

	// frame
	CMainFrame* pFrame = new CMainFrame();
	m_pMainWnd = pFrame;

	// create and load the frame with its resources
	pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW, NULL, NULL);

	// process cmd line
	CString strCmdLine = m_lpCmdLine;

	// minimized ?
	if (strCmdLine.Find(_T("/minimized")) != -1) {
		pFrame->ShowWindow(SW_MINIMIZE);
	}
	else {
		pFrame->ShowWindow(m_nCmdShow);
		pFrame->UpdateWindow();
	}

	if (strCmdLine.Find(_T("/updateall")) != -1) {
		pFrame->PostMessage(UWM_UPDATE_ALL);
	}

	int npos;
	if ((npos = strCmdLine.Find(_T("/opensite"))) != -1) {
		CString strSite = strCmdLine.Mid(npos + 10);
		int site;
		if (swscanf(strSite.GetBuffer(strSite.GetLength()), _T("%d"), &site) == 1) {
			// after sites are loaded, site with this value is opened
			pFrame->PostMessage(UWM_OPEN_SITE, site, 0);
		}
	}

	if ((npos = strCmdLine.Find(_T("/openitem"))) != -1) {
		CString sPar = strCmdLine.Mid(npos + 10);

		int site, feedIdx;
		if (swscanf(sPar.GetBuffer(sPar.GetLength()), _T("%d %d"), &site, &feedIdx) == 2) {
			pFrame->PostMessage(UWM_OPEN_FEEDITEM, site, (LPARAM) feedIdx);
		}
		sPar.ReleaseBuffer();
	}

	return TRUE;
}
void CNNfunction::NNeval(float *inputs, float* outputs, int no_sample)
{
	CMainFrame* main = (CMainFrame*)AfxGetMainWnd();

	int i, j;
	float *result = new float[no_output];
	float maxval = -1.0f;
	int maxid, maxid2;

	int cmat[7][7];
	for (i=0; i<7; i++)
		for (j=0; j<7; j++)
			cmat[i][j] = 0;

	float rr = 0.0f;

	for (j=0; j<no_sample; j++)
	{
		RLsEvalMLPFeedForward(psNN, (inputs +j*no_input), no_input, result, no_output);

		maxval = -1.0f;
		for (i=0; i<no_output; i++)
		{
			if (result[i] > maxval)
			{
				maxval = result[i];
				maxid = i;
			}
		}

		for (i=0; i<no_output; i++)
		{
			if (outputs[j*no_output + i] == 0.8f)
			{
				maxid2 = i;
				break;
			}
		}

		cmat[maxid2][maxid]++;
	}

	int sum = 0;
	for (i=0; i<no_output; i++)
	{
		sum += cmat[i][i];
	}

	rr = (float)sum/(float)no_sample*100.0f;

	CString str;
	str.Format("\r\nRec. Rate for Set[%.2f]", rr);
	(main->GetDJMessage())->AddLine(str);

	CString str2;
	str2.Format("");
	for (i=0; i<no_output; i++)
	{
		str.Format("%d ", cmat[i][i]);
		str2 += str;
	}
	(main->GetDJMessage())->AddLine(str2);


	delete [] result;	result = NULL;
}
BOOL CDanmoojiPaintApp::InitInstance()
{
	CWinAppEx::InitInstance();

	GdiplusStartupInput gdiplusStartupInput;	// GDI+를 위한 환경설정
	GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

	EnableTaskbarInteraction();

	// RichEdit 컨트롤을 사용하려면  AfxInitRichEdipointer_aft()가 있어야 합니다.	
	// AfxInitRichEdipointer_aft();
	// RichEdit 컨트롤을 사용하려면  AfxInitRichEdit2()가 있어야 합니다.	
	// AfxInitRichEdit2();

	// 표준 초기화
	// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
	// 아래에서 필요 없는 특정 초기화
	// 루틴을 제거해야 합니다.
	// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
	// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
	// 적절한 내용으로 수정해야 합니다.
	SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));
	LoadStdProfileSettings(4);  // MRU를 포함하여 표준 INI 파일 옵션을 로드합니다.


	InitContextMenuManager();

	InitKeyboardManager();

	InitTooltipManager();
	CMFCToolTipInfo ttParams;
	ttParams.m_bVislManagerTheme = TRUE;
	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

	// 응용 프로그램의 문서 템플릿을 등록합니다.  문서 템플릿은
	//  문서, 프레임 창 및 뷰 사이의 연결 역할을 합니다.
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(IDR_DanmoojiPaintTYPE,
		RUNTIME_CLASS(CDanmoojiPaintDoc),
		RUNTIME_CLASS(CChildFrame), // 사용자 지정 MDI 자식 프레임입니다.
		RUNTIME_CLASS(CDanmoojiPaintView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);

	// 주 MDI 프레임 창을 만듭니다.
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
	{
		delete pMainFrame;
		return FALSE;
	}
	m_pMainWnd = pMainFrame;


	// 표준 셸 명령, DDE, 파일 열기에 대한 명령줄을 구문 분석합니다.
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);



	// 명령줄에 지정된 명령을 디스패치합니다.
	// 응용 프로그램이 /RegServer, /Register, /Unregserver 또는 /Unregister로 시작된 경우 FALSE를 반환합니다.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// 주 창이 초기화되었으므로 이를 표시하고 업데이트합니다.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	m_pMainWnd->DragAcceptFiles();

	return TRUE;
}
BOOL CSketcherApp::InitInstance()
{
	CWinApp::InitInstance();


	// 初始化 OLE 库
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	EnableTaskbarInteraction(FALSE);

	// 使用 RichEdit 控件需要  AfxInitRichEdit2()	
	// AfxInitRichEdit2();

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


	// 注册应用程序的文档模板。  文档模板
	// 将用作文档、框架窗口和视图之间的连接
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(IDR_SketcherTYPE,
		RUNTIME_CLASS(CSketcherDoc),
		RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架
		RUNTIME_CLASS(CSketcherView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);

	// 创建主 MDI 框架窗口
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
	{
		delete pMainFrame;
		return FALSE;
	}
	m_pMainWnd = pMainFrame;

	// 仅当具有后缀时才调用 DragAcceptFiles
	//  在 MDI 应用程序中,这应在设置 m_pMainWnd 之后立即发生
	// 启用拖/放
	m_pMainWnd->DragAcceptFiles();

	// 分析标准 shell 命令、DDE、打开文件操作的命令行
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// 启用“DDE 执行”
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);


	// 调度在命令行中指定的命令。  如果
	// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// 主窗口已初始化,因此显示它并对其进行更新
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	return TRUE;
}
Exemple #9
0
BOOL CUAVSoftApp::InitInstance()
{
	// InitCommonControlsEx() 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.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	AfxEnableControlContainer();

	globalData.SetDPIAware ();

	// 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("BCGP AppWizard-Generated Applications"));
	LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)

	SetRegistryBase (_T("Settings"));

	// Initialize all Managers for usage. They are automatically constructed
	// if not yet present
	InitContextMenuManager();
	InitKeyboardManager();

	// TODO: Remove this if you don't want extended tooltips:
	InitTooltipManager();

	CBCGPToolTipParams params;
	params.m_bVislManagerTheme = TRUE;

	theApp.GetTooltipManager ()->SetTooltipParams (
		BCGP_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS (CBCGPToolTipCtrl),
		&params);

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CUAVSoftDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CUAVSoftView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);



	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);


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

	//设置文档连接地图管理控件
	CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd();

	CUAVSoftDoc *pDoc =dynamic_cast<CUAVSoftDoc*>(pMainFrame->GetActiveDocument());
	pDoc->SetLinkMapTree(pMainFrame->GetTOC());
	pMainFrame->GetTOC()->RefreshFromDoc();

	POSITION pos=pDoc->GetFirstViewPosition();
	CUAVSoftView* pView=(CUAVSoftView*)pDoc->GetNextView(pos);
    pView->SetStatusControl();

	m_pMainWnd->SetWindowText("无人机数据处理系统");//无人机数据处理系统

	// The one and only window has been initialized, so show and update it
	m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
	m_pMainWnd->UpdateWindow();
	// call DragAcceptFiles only if there's a suffix
	//  In an SDI app, this should occur after ProcessShellCommand
	return TRUE;
}
Exemple #10
0
BOOL CCtrlPatterns::OnInitDialog()
//--------------------------------
{
    CWnd::EnableToolTips(true);
    CRect rect, rcOrderList;
    CMainFrame *pMainFrm = CMainFrame::GetMainFrame();
    CModControlDlg::OnInitDialog();

    if ((!m_pModDoc) || (!m_pSndFile) || (!pMainFrm)) return TRUE;
    LockControls();
    // Order List
    m_BtnNext.GetWindowRect(&rect);
    ScreenToClient(&rect);
    rcOrderList.left = rect.right + 4;
    rcOrderList.top = rect.top;
    rcOrderList.bottom = rect.bottom + GetSystemMetrics(SM_CYHSCROLL);
    GetClientRect(&rect);
    rcOrderList.right = rect.right - 4;
    m_OrderList.Init(rcOrderList, this, m_pModDoc, pMainFrm->GetGUIFont());
    // Toolbar buttons
    m_ToolBar.Init();
    m_ToolBar.AddButton(IDC_PATTERN_NEW, TIMAGE_PATTERN_NEW);
    m_ToolBar.AddButton(IDC_PATTERN_PLAY, TIMAGE_PATTERN_PLAY);
    m_ToolBar.AddButton(IDC_PATTERN_PLAYFROMSTART, TIMAGE_PATTERN_RESTART);
    m_ToolBar.AddButton(IDC_PATTERN_STOP, TIMAGE_PATTERN_STOP);
    m_ToolBar.AddButton(ID_PATTERN_PLAYROW, TIMAGE_PATTERN_PLAYROW);
    m_ToolBar.AddButton(IDC_PATTERN_RECORD, TIMAGE_PATTERN_RECORD, TBSTYLE_CHECK, ((m_bRecord) ? TBSTATE_CHECKED : 0)|TBSTATE_ENABLED);
    m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP);
    m_ToolBar.AddButton(ID_PATTERN_VUMETERS, TIMAGE_PATTERN_VUMETERS, TBSTYLE_CHECK, ((m_bVUMeters) ? TBSTATE_CHECKED : 0)|TBSTATE_ENABLED);
    m_ToolBar.AddButton(ID_VIEWPLUGNAMES, TIMAGE_PATTERN_PLUGINS, TBSTYLE_CHECK, ((m_bPluginNames) ? TBSTATE_CHECKED : 0)|TBSTATE_ENABLED); //rewbs.patPlugNames
    m_ToolBar.AddButton(ID_PATTERN_CHANNELMANAGER, TIMAGE_CHANNELMANAGER);
    m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP);
    m_ToolBar.AddButton(ID_PATTERN_MIDIMACRO, TIMAGE_MACROEDITOR);
    m_ToolBar.AddButton(ID_PATTERN_CHORDEDIT, TIMAGE_CHORDEDITOR);
    m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP);
    m_ToolBar.AddButton(ID_EDIT_UNDO, TIMAGE_UNDO);
    m_ToolBar.AddButton(ID_PATTERN_PROPERTIES, TIMAGE_PATTERN_PROPERTIES);
    m_ToolBar.AddButton(ID_PATTERN_EXPAND, TIMAGE_PATTERN_EXPAND);
    m_ToolBar.AddButton(ID_PATTERN_SHRINK, TIMAGE_PATTERN_SHRINK);
    //        m_ToolBar.AddButton(ID_PATTERN_AMPLIFY, TIMAGE_SAMPLE_AMPLIFY);
    m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP);
    m_ToolBar.AddButton(ID_PATTERNDETAIL_LO, TIMAGE_PATTERN_DETAIL_LO, TBSTYLE_CHECK, TBSTATE_ENABLED);
    m_ToolBar.AddButton(ID_PATTERNDETAIL_MED, TIMAGE_PATTERN_DETAIL_MED, TBSTYLE_CHECK, TBSTATE_ENABLED);
    m_ToolBar.AddButton(ID_PATTERNDETAIL_HI, TIMAGE_PATTERN_DETAIL_HI, TBSTYLE_CHECK, TBSTATE_ENABLED|TBSTATE_CHECKED);
    m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP);
    m_ToolBar.AddButton(ID_OVERFLOWPASTE, TIMAGE_PATTERN_OVERFLOWPASTE, TBSTYLE_CHECK, ((CMainFrame::m_dwPatternSetup & PATTERN_OVERFLOWPASTE) ? TBSTATE_CHECKED : 0) | TBSTATE_ENABLED);

    // Special edit controls -> tab switch to view
    m_EditSequence.SetParent(this);
    m_EditSpacing.SetParent(this);
    m_EditPatName.SetParent(this);
    m_EditPatName.SetLimitText(MAX_PATTERNNAME - 1);
    m_EditOrderListMargins.SetParent(this);
    m_EditOrderListMargins.SetLimitText(3);
    // Spin controls
    m_SpinSpacing.SetRange(0, MAX_SPACING);
    m_SpinSpacing.SetPos(CMainFrame::gnPatternSpacing);

    m_SpinInstrument.SetRange(-1, 1);
    m_SpinInstrument.SetPos(0);

    if(CMainFrame::gbShowHackControls == true)
    {
            m_SpinOrderListMargins.ShowWindow(SW_SHOW);
            m_EditOrderListMargins.ShowWindow(SW_SHOW);
            m_SpinOrderListMargins.SetRange(0, m_OrderList.GetMarginsMax());
            m_SpinOrderListMargins.SetPos(m_OrderList.GetMargins());
    }
    else
    {
            m_SpinOrderListMargins.ShowWindow(SW_HIDE);
            m_EditOrderListMargins.ShowWindow(SW_HIDE);
    }

    SetDlgItemInt(IDC_EDIT_SPACING, CMainFrame::gnPatternSpacing);
    SetDlgItemInt(IDC_EDIT_ORDERLIST_MARGINS, m_OrderList.GetMargins());
    CheckDlgButton(IDC_PATTERN_FOLLOWSONG, !(CMainFrame::m_dwPatternSetup & PATTERN_FOLLOWSONGOFF));                //rewbs.noFollow - set to unchecked

    m_SpinSequence.SetRange(0, m_pSndFile->Order.GetNumSequences() - 1);
    m_SpinSequence.SetPos(m_pSndFile->Order.GetCurrentSequenceIndex());
    SetDlgItemText(IDC_EDIT_SEQUENCE_NAME, m_pSndFile->Order.m_sName.c_str());

    m_OrderList.SetFocus();

    UpdateView(HINT_MODTYPE|HINT_PATNAMES, NULL);
    RecalcLayout();

    m_bInitialized = TRUE;
    UnlockControls();

    return FALSE;
}
BOOL CMWEditApp::InitInstance() {
  AfxEnableControlContainer();
  AfxInitRichEdit();
  SystemLog.Open("mwedit.log");

/*  int Index;
  int RandomValue;
  int RandCount[101];
  memset(RandCount, 0, sizeof(int)*101);
  
  for (Index = 0; Index < 1000000; Index++) {
    RandomValue = Random(100);
    RandCount[RandomValue]++;
   }

  int Total = 0;
  for (Index = 0; Index < 101; Index++) {
    SystemLog.Printf ("%3d = %d", Index, RandCount[Index]);
    Total += RandCount[Index];
   }

  SystemLog.Printf ("Total = %d", Total); //*/

	/* Attempt to load the default function help definitions */
  m_FunctionArray.LoadDefault();

	/* Attempt to load the custom function definitions */
  ReadMwCustomFunctions(g_CustomFunctions, MWEDIT_DEFAULT_CUSTOMFUNCS);

#ifdef _AFXDLL
  Enable3dControls();
#else
  Enable3dControlsStatic();
#endif

	/* Initialize the image list */
  m_IconBitmap[ESMLIST_IMAGE_ARMOR].LoadBitmap(IDB_ARMOR);
  m_IconBitmap[ESMLIST_IMAGE_ALCHEMY].LoadBitmap(IDB_ALCHEMY);
  m_IconBitmap[ESMLIST_IMAGE_ACTIVATOR].LoadBitmap(IDB_ACTIVATOR);
  m_IconBitmap[ESMLIST_IMAGE_APPARATUS].LoadBitmap(IDB_APPARATUS);
  m_IconBitmap[ESMLIST_IMAGE_BODYPART].LoadBitmap(IDB_BODYPART);
  m_IconBitmap[ESMLIST_IMAGE_BOOK].LoadBitmap(IDB_BOOK);
  m_IconBitmap[ESMLIST_IMAGE_CLOTHING].LoadBitmap(IDB_CLOTHING);
  m_IconBitmap[ESMLIST_IMAGE_CONTAINER].LoadBitmap(IDB_CONTAINER);
  m_IconBitmap[ESMLIST_IMAGE_CREATURE].LoadBitmap(IDB_CREATURE);
  m_IconBitmap[ESMLIST_IMAGE_DOOR].LoadBitmap(IDB_DOOR);
  m_IconBitmap[ESMLIST_IMAGE_ENCHANT].LoadBitmap(IDB_ENCHANT);
  m_IconBitmap[ESMLIST_IMAGE_INGREDIANT].LoadBitmap(IDB_INGREDIANT);
  m_IconBitmap[ESMLIST_IMAGE_LEVELCREA].LoadBitmap(IDB_LEVELCREA);
  m_IconBitmap[ESMLIST_IMAGE_LEVELITEM].LoadBitmap(IDB_LEVELITEM);
  m_IconBitmap[ESMLIST_IMAGE_LIGHT].LoadBitmap(IDB_LIGHT);
  m_IconBitmap[ESMLIST_IMAGE_LOCKPICK].LoadBitmap(IDB_LOCKPICK);
  m_IconBitmap[ESMLIST_IMAGE_MISC].LoadBitmap(IDB_MISC);
  m_IconBitmap[ESMLIST_IMAGE_NPC].LoadBitmap(IDB_NPC);
  m_IconBitmap[ESMLIST_IMAGE_PROBE].LoadBitmap(IDB_PROBE);
  m_IconBitmap[ESMLIST_IMAGE_REPAIR].LoadBitmap(IDB_REPAIR);
  m_IconBitmap[ESMLIST_IMAGE_SPELL].LoadBitmap(IDB_SPELL);
  m_IconBitmap[ESMLIST_IMAGE_STATIC].LoadBitmap(IDB_STATIC);
  m_IconBitmap[ESMLIST_IMAGE_WEAPON].LoadBitmap(IDB_WEAPON);
  m_IconBitmap[ESMLIST_IMAGE_GLOBAL].LoadBitmap(IDB_GLOBAL);
  m_IconBitmap[ESMLIST_IMAGE_SOUND].LoadBitmap(IDB_SOUND);
  m_IconBitmap[ESMLIST_IMAGE_EFFECT].LoadBitmap(IDB_MAGICEFFECT);
  m_IconBitmap[ESMLIST_IMAGE_DIALOG].LoadBitmap(IDB_DIALOG);
  m_IconBitmap[ESMLIST_IMAGE_SETTING].LoadBitmap(IDB_GAMESETTING);
  m_IconBitmap[ESMLIST_IMAGE_CLASS].LoadBitmap(IDB_CLASS);
  m_IconBitmap[ESMLIST_IMAGE_FACTION].LoadBitmap(IDB_FACTION);
  m_IconBitmap[ESMLIST_IMAGE_RACE].LoadBitmap(IDB_RACE);
  m_IconBitmap[ESMLIST_IMAGE_SKILL].LoadBitmap(IDB_SKILL);
  m_IconBitmap[ESMLIST_IMAGE_SCRIPT].LoadBitmap(IDB_SCRIPT);
  m_IconBitmap[ESMLIST_IMAGE_BIRTHSIGN].LoadBitmap(IDB_BIRTHSIGN);
  m_IconBitmap[ESMLIST_IMAGE_SOUNDGEN].LoadBitmap(IDB_SOUNDGEN);
  m_IconBitmap[ESMLIST_IMAGE_REGION].LoadBitmap(IDB_REGION);
  m_IconBitmap[ESMLIST_IMAGE_CELL].LoadBitmap(IDB_CELL);
  m_IconBitmap[ESMLIST_IMAGE_STARTSCRIPT].LoadBitmap(IDB_STARTSCRIPT);
  
  CEsmListCtrl::m_ImageList.Create(16, 16, ILC_COLOR16, 64, 8);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_ACTIVATOR], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_ALCHEMY], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_APPARATUS], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_ARMOR], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_BODYPART], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_BOOK], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_CLOTHING], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_CONTAINER], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_CREATURE], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_DOOR], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_ENCHANT], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_INGREDIANT], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_LEVELCREA], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_LEVELITEM], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_LIGHT], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_LOCKPICK], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_MISC], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_NPC], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_PROBE], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_REPAIR], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_SPELL], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_STATIC], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_WEAPON], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_GLOBAL], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_SOUND], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_EFFECT], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_DIALOG], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_SETTING], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_CLASS], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_FACTION], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_RACE], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_SKILL], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_SCRIPT], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_BIRTHSIGN], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_SOUNDGEN], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_REGION], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_CELL], (CBitmap *)NULL);
  CEsmListCtrl::m_ImageList.Add(&m_IconBitmap[ESMLIST_IMAGE_STARTSCRIPT], (CBitmap *)NULL);

	/* Initialize the TGA/DDS image library */
  ilInit();

	/* Change the registry key under which our settings are stored. */
  SetRegistryKey(_T("MWEdit"));
  FindMWRegistryPath();

	/* Load standard INI file options (including MRU) */
  LoadStdProfileSettings(0); 

	/* Load the options from the registry */
  m_Options.ReadFromRegistry();

	/* Attempt to initialize the extra file for the script compiler */
  if (m_Options.GetExtraFile()[0] != NULL_CHAR) {
    CEsmScriptCompile::GetExtraFile().Read(m_Options.GetExtraFile());
    CEsmScriptCompile::InitializeExtraRecords();
  }
  
	/* Register document templates */
  CMultiDocTemplate* pDocTemplate;
  pDocTemplate = new CMultiDocTemplate(IDR_MWEDITTYPE,
		RUNTIME_CLASS(CMWEditDoc),
		RUNTIME_CLASS(CChildFrame), /* Custom MDI child frame */
		RUNTIME_CLASS(CMWEditView));
  AddDocTemplate(pDocTemplate);

	/* Create main MDI Frame window */
  CMainFrame* pMainFrame = new CMainFrame;
  if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE;
  m_pMainWnd = pMainFrame;

	/* Enable drag/drop open */
  m_pMainWnd->DragAcceptFiles();

	/* Enable DDE Execute open */
  EnableShellOpen();
  RegisterShellFileTypes(TRUE);

	/* Parse command line for standard shell commands, DDE, file open */
  CCommandLineInfo cmdInfo;
  ParseCommandLine(cmdInfo);

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

	/* The main window has been initialized, so show and update it. */
  pMainFrame->ShowWindow(m_nCmdShow);
  pMainFrame->UpdateWindow();

	/* Display warning dialog */
  pMainFrame->MessageBox(_T("WARNING: This version of MWEdit is a BETA version and still\nhas not been thoroughly tested. Please use caution and backup any\nplugins while editting. View the README.TXT file for more information."), _T("MWEdit Warning"), MB_OK | MB_ICONWARNING);

  return TRUE;
 }
Exemple #12
0
void CSubtitleDlDlg::OnOK()
{
	SetStatus(ResStr(IDS_SUBDL_DLG_DOWNLOADING));

	for (int i = 0; i < m_list.GetItemCount(); ++i) {
		if (m_list.GetCheck(i)) {
			m_selsubs.AddTail(*reinterpret_cast<isdb_subtitle*>(m_list.GetItemData(i)));
		}
	}

	m_fReplaceSubs = IsDlgButtonChecked(IDC_CHECK1) == BST_CHECKED;

	CMainFrame* pMF = static_cast<CMainFrame*>(GetParentFrame());

	if (m_fReplaceSubs) {
		pMF->m_pSubStreams.RemoveAll();
	}

	CComPtr<ISubStream> pSubStreamToSet;

	POSITION pos = m_selsubs.GetHeadPosition();

	while (pos) {
		const isdb_subtitle& sub = m_selsubs.GetNext(pos);
		AppSettings& s = AfxGetAppSettings();
		CInternetSession is;
		CStringA url = "http://" + s.strISDb + "/dl.php?";
		CStringA args, ticket, str;
		args.Format("id=%d&ticket=%s", sub.id, UrlEncode(ticket));
		url.Append(args);

		if (OpenUrl(is, CString(url), str)) {

			if (pMF->b_UseVSFilter) {
				if (CComQIPtr<IDirectVobSub> pDVS = pMF->GetVSFilter()) {
					TCHAR lpszTempPath[_MAX_PATH] = { 0 };
					if (::GetTempPath(_MAX_PATH, lpszTempPath)) {
						CString subFileName(lpszTempPath);
						subFileName.Append(CString(sub.name));
						if (::PathFileExists(subFileName)) {
							::DeleteFile(subFileName);
						}

						CFile cf;
						if (cf.Open(subFileName, CFile::modeCreate|CFile::modeWrite|CFile::shareDenyNone)) {
							cf.Write(str.GetString(), str.GetLength());
							cf.Close();

							if (SUCCEEDED(pDVS->put_FileName((LPWSTR)(LPCWSTR)subFileName))) {
								pDVS->put_SelectedLanguage(0);
								pDVS->put_HideSubtitles(true);
								pDVS->put_HideSubtitles(false);
							}

							::DeleteFile(subFileName);
						}
					}

					__super::OnOK();
					return;
				}
			}

			CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&pMF->m_csSubLock, &s.subdefstyle, s.fUseDefaultSubtitlesStyle));
			if (pRTS && pRTS->Open((BYTE*)(LPCSTR)str, str.GetLength(), DEFAULT_CHARSET, CString(sub.name)) && pRTS->GetStreamCount() > 0) {
				CComPtr<ISubStream> pSubStream = pRTS.Detach();
				pMF->m_pSubStreams.AddTail(pSubStream);

				if (!pSubStreamToSet) {
					pSubStreamToSet = pSubStream;
				}
			}
		}
	}

	if (pSubStreamToSet) {
		pMF->SetSubtitle(pSubStreamToSet);

		AfxGetAppSettings().fEnableSubtitles = true;
	}

	__super::OnOK();
}
Exemple #13
0
BOOL CModelerApp::SubInitInstance()
{
  char strIni[ 128];
	// 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.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

  // settings will be saved into registry instead of ini file
  SetRegistryKey( "LastChaos");

	LoadStdProfileSettings(8);  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CMultiDocTemplate* pDocTemplate;
	m_pdtModelDocTemplate = pDocTemplate = new CMultiDocTemplate(
		IDR_MDLDOCTYPE,
		RUNTIME_CLASS(CModelerDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CModelerView));
	AddDocTemplate(pDocTemplate);
  
  m_pdtScriptTemplate = pDocTemplate = new CMultiDocTemplate(
		IDR_SCRIPTDOCTYPE,
		RUNTIME_CLASS(CScriptDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CScriptView));
	AddDocTemplate(pDocTemplate);

  // initialize engine, without network
  SE_InitEngine("");  // DO NOT SPECIFY NAME HERE!
  SE_LoadDefaultFonts();

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if( !pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE;
  m_pMainWnd = pMainFrame;
  
  // set main window for engine
  SE_UpdateWindowHandle( m_pMainWnd->m_hWnd);

	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);

  // load startup script
  _pShell->Execute( "include \"Scripts\\Modeler_startup.ini\"");
  
//안태훈 수정 시작	//(Modify Default API to D3D)(0.1)
  m_iApi=GAT_D3D;
  m_iApi=GetProfileInt("Display modes", "SED Gfx API", GAT_D3D);
//안태훈 수정 끝	//(Modify Default API to D3D)(0.1)
  // (re)set default display mode
  _pGfx->ResetDisplayMode((enum GfxAPIType) m_iApi);

  m_Preferences.ReadFromIniFile();

  // load background textures
  INDEX iWorkingTexturesCt = theApp.GetProfileInt( "Modeler prefs", 
                                                   "Modeler working textures count", -1);
  if( iWorkingTexturesCt != -1) {
    char strWTName[ 128];
    for( INDEX i=0; i<iWorkingTexturesCt; i++) {
      sprintf( strWTName, "Working texture %02d", i);
      INI_READ( strWTName, "Error in INI .file!");
      AddModelerWorkingTexture( CTString(strIni));
    }
  }
  // load working patches
  INDEX iWorkingPatchesCt = theApp.GetProfileInt( "Modeler prefs", 
                                                 "Modeler working patches count", -1);
  char strWPName[ 128];
  for( INDEX i=0; i<iWorkingPatchesCt; i++) {
    sprintf( strWPName, "Working patch %02d", i);
    INI_READ( strWPName, "Error in INI .file!");
    AddModelerWorkingPatch( CTString(strIni));
  }
  pMainFrame->m_StainsComboBox.Refresh();

  // create temporary directory to contain copy/paste mapping all
  CreateDirectory( _fnmApplicationPath + "Temp\\", NULL);
  
  // try to
  try
  { // load lamp model
    DECLARE_CTFILENAME( fnLampName, "Data\\Models\\Editor\\Lamp.mdl");
    m_pLampModelData = _pModelStock->Obtain_t( fnLampName);
    m_LampModelObject = new CModelObject;
    m_LampModelObject->SetData(m_pLampModelData);
    m_LampModelObject->SetAnim( 0);
    // load lamp's texture
    DECLARE_CTFILENAME( fnLampTex, "Data\\Models\\Editor\\SpotLight.tex");
    m_ptdLamp = _pTextureStock->Obtain_t( fnLampTex);
    m_LampModelObject->mo_toTexture.SetData( m_ptdLamp); 

    // load collision box model
    DECLARE_CTFILENAME( fnCollisionBox, "Data\\Models\\Editor\\CollisionBox.mdl");
    m_pCollisionBoxModelData = _pModelStock->Obtain_t( fnCollisionBox);
    m_pCollisionBoxModelObject = new CModelObject;
    m_pCollisionBoxModelObject->SetData(m_pCollisionBoxModelData);
    m_pCollisionBoxModelObject->SetAnim( 0);
    // load collision box's texture
    DECLARE_CTFILENAME( fnCollisionBoxTex, "Data\\Models\\Editor\\CollisionBox.tex");
    m_ptdCollisionBoxTexture = _pTextureStock->Obtain_t( fnCollisionBoxTex);
    m_pCollisionBoxModelObject->mo_toTexture.SetData( m_ptdCollisionBoxTexture); 

    // load floor model
    DECLARE_CTFILENAME( fnFloor, "Data\\Models\\Editor\\Floor.mdl");
    m_pFloorModelData = _pModelStock->Obtain_t( fnFloor);
    m_pFloorModelObject = new CModelObject;
    m_pFloorModelObject->SetData(m_pFloorModelData);
    m_pFloorModelObject->SetAnim( 0);
    // load collision box's texture
    DECLARE_CTFILENAME( fnFloorTex, "Data\\Models\\Editor\\Floor.tex");
    m_ptdFloorTexture = _pTextureStock->Obtain_t( fnFloorTex);
    m_pFloorModelObject->mo_toTexture.SetData( m_ptdFloorTexture); 

    DECLARE_CTFILENAME( fnShadowTex, "Data\\Textures\\Effects\\Shadow\\SimpleModelShadow.tex");
    // setup simple model shadow texture
    _toSimpleModelShadow.SetData_t( fnShadowTex);
  }
  catch( char *err_str)
  { // report error and continue without models
    AfxMessageBox( err_str);

    // if we allocated model object for collision box
    if( m_pCollisionBoxModelObject != NULL) {
      // delete it
      delete m_pCollisionBoxModelObject;
      m_pCollisionBoxModelObject = NULL;
    }
    // if we loaded collision box's texture
    if( m_ptdCollisionBoxTexture != NULL) {
      // release it and
      _pTextureStock->Release( m_ptdCollisionBoxTexture);
      m_ptdCollisionBoxTexture = NULL;
    }

    // if we loaded lamp's texture
    if( m_ptdLamp != NULL) {
      // release it and
      _pTextureStock->Release( m_ptdLamp);
      m_ptdLamp = NULL;
    }

    // if we allocated model object for floor
    if( m_pFloorModelObject != NULL) {
      // delete it
      delete m_pFloorModelObject;
      m_pFloorModelObject = NULL;
    }
    // if we loaded floor's texture
    if( m_ptdFloorTexture != NULL) {
      // release it and
      _pTextureStock->Release( m_ptdFloorTexture);
      m_ptdFloorTexture = NULL;
    }
  }

  // assign system font
  m_pfntFont = _pfdDisplayFont;

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

  if(CTString("")==CTString(cmdInfo.m_strFileName))
  {
    cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
  }
  else
  {
    cmdInfo.m_nShellCommand = CCommandLineInfo::FileOpen;
  }
  // Dispatch commands specified on the command line
	if( !ProcessShellCommand(cmdInfo)) return FALSE;

	// The main window has been initialized, so show and update it.
  m_nCmdShow = SW_SHOWMAXIMIZED; // maximize main frame !!!
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

  // if stating modeler for the first time
  if( m_bFirstTimeStarted) {
    // call preferences
    OnFilePreferences();
  }
  
  return TRUE;
}
Exemple #14
0
BOOL CRaytraceApp::OnIdle(LONG lCount)
{
	CWinApp::OnIdle (lCount);
	CMainFrame* main = (CMainFrame*) AfxGetMainWnd ();
	return main->ProcessIdle (lCount);
}
//另存被试者信息
void CTesterView::OnSaveas() 
{
	SetCurrentDirectory(g_szExePath);
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_TesterNo=="")
	{
		MessageBox("请输入受试者编号!");
		return;
	}
	if(m_TesterName=="")
	{
		MessageBox("请输入受试者姓名!");
		return;
	}
	if(m_TesterAge<0)
	{
		MessageBox("请输入受试者年龄!");
		return;
	}
	if(m_Session<0)
	{
		MessageBox("请输入第N次!");
		return;
	}
	CMainFrame*   pMain   =(CMainFrame*)AfxGetMainWnd();
    CTaskControlDoc* pDoc = (CTaskControlDoc*)pMain->GetActiveDocument();

	sprintf_s(pDoc->m_PartInfo.m_TesterNo, m_TesterNo);
	sprintf_s(pDoc->m_PartInfo.m_TesterName, m_TesterName);
	sprintf_s(pDoc->m_PartInfo.m_TesterSex, m_TesterSex);
	pDoc->m_PartInfo.m_TesterAge = m_TesterAge;
	pDoc->m_PartInfo.m_Session = m_Session;

	_mkdir("PartInfo");
	CString m_FileName;
	m_FileName.Format("%s-%s.txt",m_TesterNo,m_TesterName);
	CFileDialog Dlg(FALSE,NULL,m_FileName,NULL,"Part Info Files (*.txt)",this); 
    DWORD nBufferLength=256; 
	char lpBuffer[256];  
//	char lpSaveBuffer[256];

	GetCurrentDirectory(nBufferLength,lpBuffer);
//	sprintf(lpSaveBuffer,"%s\\PartInfo",lpBuffer);
	CString dlgpath;
	dlgpath.Format("%s\\PartInfo",lpBuffer);
	Dlg.m_ofn.lpstrInitialDir=dlgpath.GetBuffer(dlgpath.GetLength());	
	if(Dlg.DoModal()==IDOK)
	{
		CString filepathall = Dlg.GetPathName();
		m_FileName.Format("%s",filepathall.GetBuffer(filepathall.GetLength()));
    	FILE *fp;
		fopen_s(&fp, m_FileName,"wt");
		if(fp!=NULL)
		{
			fprintf(fp,"编号\t%s\n",m_TesterNo);
			fprintf(fp,"姓名\t%s\n",m_TesterName);
			fprintf(fp,"性别\t%s\n",m_TesterSex);
			fprintf(fp,"年龄\t%d\n",m_TesterAge);
		    fprintf(fp,"第N次\t%d\n",m_Session);
			fclose(fp);
		}
		MessageBox("保存完毕!","提示");
	}
	SetCurrentDirectory(lpBuffer);
	
}
void conschk_exists_notu_dlg::InitDialog(wxInitDialogEvent& WXUNUSED(event)) // InitDialog is method of wxWindow
{
	//InitDialog() is not virtual, no call needed to a base class
	m_bDoAutoFix = FALSE; // default

	m_pStatTxtMsg = (wxStaticText*)FindWindowById(ID_TEXT_EXISTS_STR);
	wxASSERT(m_pStatTxtMsg != NULL);
	wxString itsLabel = m_pStatTxtMsg->GetLabel();
	wxString s;
	if (m_msgNumber == 1)
	{
		s = gpApp->m_consCheck_msg1;
		
	}
	else
	{
		s = gpApp->m_consCheck_msg2;
		s = s.Format(s, gpApp->m_strNotInKB.c_str());
	}
	wxString finalLabel;
	finalLabel = finalLabel.Format(itsLabel,s.c_str());
	m_pStatTxtMsg->SetLabel(finalLabel); // get the appropriate message shown

	m_pAutoFixChkBox = (wxCheckBox*)FindWindowById(ID_CHECK_DO_SAME2);
	wxASSERT(m_pAutoFixChkBox != NULL);
	m_pAutoFixChkBox->SetValue(FALSE); // start with it turned off

	actionTaken = no_GUI_needed; // temporary default, OnOK() will set it

	m_pTextCtrlSrcText = (wxTextCtrl*)FindWindowById(ID_TEXTCTRL_SOURCE_PHRASE_2);
	wxASSERT(m_pTextCtrlSrcText != NULL);
	// put the passed in source phrase value into the wxTextCtrl, then make it read only
	m_pTextCtrlSrcText->ChangeValue(m_sourcePhrase);
	m_pTextCtrlSrcText->SetEditable(FALSE); // now it's read-only

	m_pTextCtrlTgtText = (wxTextCtrl*)FindWindowById(ID_TEXTCTRL_TARGET_PHRASE_2);
	wxASSERT(m_pTextCtrlTgtText != NULL);
	// put the passed in source phrase value into the wxTextCtrl, then make it read only
	m_pTextCtrlTgtText->ChangeValue(m_targetPhrase);
	m_pTextCtrlTgtText->SetEditable(FALSE); // now it's read-only

	m_pStaticCtrl = (wxStaticText*)FindWindowById(ID_TEXT_EXISTS_STR);
	wxASSERT(m_pStaticCtrl != NULL);

	m_pStoreNormallyRadioBtn = (wxRadioButton*)FindWindowById(ID_RADIO_STORE_NORMALLY);
	wxASSERT(m_pStoreNormallyRadioBtn != NULL);

	m_pNotInKBRadioBtn = (wxRadioButton*)FindWindowById(ID_RADIO_NOT_IN_KB_LEAVEINDOC);
	wxASSERT(m_pNotInKBRadioBtn != NULL);
	m_radioNotInKBLabelStr.Empty();
	// put in the correct string, for this radio button label;  "<Not In KB>" 
	wxString msg2 = m_pNotInKBRadioBtn->GetLabel();
	m_radioNotInKBLabelStr = m_radioNotInKBLabelStr.Format(msg2, m_notInKBStr.c_str());
	m_pNotInKBRadioBtn->SetLabel(m_radioNotInKBLabelStr);
	// get the pixel difference in the label's changed text
	int difference = CalcLabelWidthDifference(msg2, m_radioNotInKBLabelStr, m_pNotInKBRadioBtn);

	// make the fonts show user-defined font point size in the dialog
	#ifdef _RTL_FLAGS
	gpApp->SetFontAndDirectionalityForDialogControl(gpApp->m_pSourceFont, m_pTextCtrlSrcText, NULL,
								NULL, NULL, gpApp->m_pDlgSrcFont, gpApp->m_bSrcRTL);
	gpApp->SetFontAndDirectionalityForDialogControl(gpApp->m_pTargetFont, m_pTextCtrlTgtText, NULL,
								NULL, NULL, gpApp->m_pDlgTgtFont, gpApp->m_bTgtRTL);
	#else // Regular version, only LTR scripts supported, so use default FALSE for last parameter
	gpApp->SetFontAndDirectionalityForDialogControl(gpApp->m_pSourceFont, m_pTextCtrlSrcText, NULL, 
								NULL, NULL, gpApp->m_pDlgSrcFont);
	gpApp->SetFontAndDirectionalityForDialogControl(gpApp->m_pTargetFont, m_pTextCtrlTgtText, NULL, 
								NULL, NULL, gpApp->m_pDlgTgtFont);
	#endif

	// get the dialog to resize to the new label string lengths
	int width = 0;
	int myheight = 0;
	this->GetSize(&width, &myheight);
	// use the difference value calculated above to widen the dialog window and then call
	// Layout() to get the attached sizer hierarchy recalculated and laid out
	int sizeFlags = 0;
	sizeFlags |= wxSIZE_USE_EXISTING;
	int clientWidth = 0;
	int clientHeight = 0;
	CMainFrame *pFrame = gpApp->GetMainFrame();
	pFrame->GetClientSize(&clientWidth,&clientHeight);
    // ensure the adjusted width of the dialog won't exceed the client area's width for the
    // frame window
    if (difference < clientWidth - width)
	{
		this->SetSize(wxDefaultCoord, wxDefaultCoord, width + difference, wxDefaultCoord);
	}else
	{
		this->SetSize(wxDefaultCoord, wxDefaultCoord, clientWidth - 2, wxDefaultCoord);
	}
	this->Layout(); // automatically calls Layout() on top level sizer

	if (m_bShowItCentered)
	{
		this->Centre(wxHORIZONTAL);
	}

	{ // reused local var names here, so need a new scope in order to hide them
	// get the dialog to resize to the new label string lengths
	int width = 0;
	int myheight = 0;
	this->GetSize(&width, &myheight);
	// use the difference value calculated above to widen the dialog window and then call
	// Layout() to get the attached sizer hierarchy recalculated and laid out
	int sizeFlags = 0;
	sizeFlags |= wxSIZE_USE_EXISTING;
	int clientWidth = 0;
	int clientHeight = 0;
	CMainFrame *pFrame = gpApp->GetMainFrame();
	pFrame->GetClientSize(&clientWidth,&clientHeight);
    // ensure the adjusted width of the dialog won't exceed the client area's width for the
    // frame window
    if (difference < clientWidth - width)
	{
		this->SetSize(wxDefaultCoord, wxDefaultCoord, width + difference, wxDefaultCoord);
	}else
	{
		this->SetSize(wxDefaultCoord, wxDefaultCoord, clientWidth - 2, wxDefaultCoord);
	}
	this->Layout(); // automatically calls Layout() on top level sizer

	if (m_bShowItCentered)
	{
		this->Centre(wxHORIZONTAL);
	}
	// work out where to place the dialog window
	int myTopCoord, myLeftCoord, newXPos, newYPos;
	wxRect rectDlg;
	GetSize(&rectDlg.width, &rectDlg.height); // dialog's window frame
	wxClientDC dc(gpApp->GetMainFrame()->canvas);
	gpApp->GetMainFrame()->canvas->DoPrepareDC(dc);// adjust origin
	// wxWidgets' drawing.cpp sample calls PrepareDC on the owning frame
	gpApp->GetMainFrame()->PrepareDC(dc); 
	// CalcScrolledPosition translates logical coordinates to device ones, m_ptBoxTopLeft
	// has been initialized to the topleft of the cell (from m_pActivePile) where the
	// phrase box currently is
	gpApp->GetMainFrame()->canvas->CalcScrolledPosition(m_ptBoxTopLeft.x, m_ptBoxTopLeft.y,&newXPos,&newYPos);
	gpApp->GetMainFrame()->canvas->ClientToScreen(&newXPos, &newYPos); // now it's screen coords
	RepositionDialogToUncoverPhraseBox(gpApp, 0, 0, rectDlg.width, rectDlg.height,
										newXPos, newYPos, myTopCoord, myLeftCoord);
	SetSize(myLeftCoord, myTopCoord, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING);
	}
	// It's a simple dialog, I'm not bothering with validators and TransferDataTo/FromWindow calls
	//TransferDataToWindow();
}
//设为当前被试者信息
void CTesterView::OnMakesure() 
{
	
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_TesterNo=="")
	{
		MessageBox("请输入受试者编号!");
		return;
	}
	if(m_TesterName=="")
	{
		MessageBox("请输入受试者姓名!");
		return;
	}
	if(m_TesterAge<0)
	{
		MessageBox("请输入受试者年龄!");
		return;
	}
	if(m_Session<0)
	{
		MessageBox("请输入第N次!");
		return;
	}
	CTaskControlApp*   pApp =(CTaskControlApp*)AfxGetApp();
	CMainFrame*   pMain   =(CMainFrame*)AfxGetMainWnd();
    CTaskControlDoc* pDoc = (CTaskControlDoc*)pMain->GetActiveDocument();

	sprintf_s(pDoc->m_PartInfo.m_TesterNo, m_TesterNo);
	sprintf_s(pDoc->m_PartInfo.m_TesterName, m_TesterName);
	sprintf_s(pDoc->m_PartInfo.m_TesterSex, m_TesterSex);
	pDoc->m_PartInfo.m_TesterAge = m_TesterAge;
	pDoc->m_PartInfo.m_Session = m_Session;

	_mkdir("PartInfo");
    DWORD nBufferLength=256; 
//	char lpBuffer[256];  
//	char lpSaveBuffer[256];  
	CString m_FileName;
//	GetCurrentDirectory(nBufferLength,lpBuffer);
//	sprintf(lpSaveBuffer,"%s\\PartInfo",lpBuffer);
    m_FileName.Format("PartInfo\\%s-%s.txt",m_TesterNo,m_TesterName);
//    m_FileName.Format("%s\\%s-%s.txt",lpSaveBuffer,m_TesterNo,m_TesterName);
	FILE *fp;
	fopen_s(&fp, m_FileName,"wt");
	if(fp!=NULL)
	{
        fprintf_s(fp,"编号\t%s\n",m_TesterNo);
		fprintf_s(fp,"姓名\t%s\n",m_TesterName);
        fprintf_s(fp,"性别\t%s\n",m_TesterSex);
		fprintf_s(fp,"年龄\t%d\n",m_TesterAge);
		fprintf_s(fp,"第N次\t%d\n",m_Session);
		fclose(fp);
	}	
//	SetCurrentDirectory(lpBuffer);	

	sprintf_s(pDoc->m_CurPartInfo.m_TesterNo, m_TesterNo);
	sprintf_s(pDoc->m_CurPartInfo.m_TesterName, m_TesterName);
	sprintf_s(pDoc->m_CurPartInfo.m_TesterSex, m_TesterSex);
	pDoc->m_CurPartInfo.m_TesterAge = m_TesterAge;	
	pDoc->m_CurPartInfo.m_Session = m_Session;
	CButton* m_Button;
	m_Button = (CButton*)GetDlgItem(IDC_MAKESURE); 
    m_Button->EnableWindow(FALSE);
	m_bSetting = TRUE;

	pApp->SaveExe(); 
			

		
}
Exemple #18
0
BOOL CPPagePlayer::OnApply()
{
	UpdateData();

	AppSettings& s = AfxGetAppSettings();

	s.iMultipleInst = m_iMultipleInst;
	s.iTitleBarTextStyle = m_iTitleBarTextStyle;
	s.fTitleBarTextTitle = !!m_bTitleBarTextTitle;
	s.fTrayIcon = !!m_fTrayIcon;
	s.fRememberWindowPos = !!m_fRememberWindowPos;
	s.fRememberWindowSize = !!m_fRememberWindowSize;
	s.fSavePnSZoom = !!m_fSavePnSZoom;
	s.fSnapToDesktopEdges = !!m_fSnapToDesktopEdges;
	s.fKeepHistory = !!m_fKeepHistory;
	s.fHideCDROMsSubMenu = !!m_fHideCDROMsSubMenu;
	s.dwPriority = !m_bPriority ? NORMAL_PRIORITY_CLASS : ABOVE_NORMAL_PRIORITY_CLASS;
	BOOL bShowOSDChanged = (s.fShowOSD != !!m_fShowOSD);
	s.fShowOSD = !!m_fShowOSD;
	if (bShowOSDChanged) {
		CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
		if (m_fShowOSD) {
			pFrame->m_OSD.Start(pFrame->m_pOSDWnd);
			pFrame->OSDBarSetPos();
			pFrame->m_OSD.ClearMessage(false);
		} else {
			pFrame->m_OSD.Stop();
		}
	}
	s.fLimitWindowProportions = !!m_fLimitWindowProportions;
	s.fRememberDVDPos = !!m_fRememberDVDPos;
	s.fRememberFilePos = !!m_fRememberFilePos;
	s.bRememberPlaylistItems = !!m_bRememberPlaylistItems;

	if (!m_fKeepHistory) {
		for (int i = s.MRU.GetSize() - 1; i >= 0; i--) {
			s.MRU.Remove(i);
		}

		for (int i = s.MRUDub.GetSize() - 1; i >= 0; i--) {
			s.MRUDub.Remove(i);
		}

		s.MRU.WriteList();
		s.MRUDub.WriteList();

		// Empty the "Recent" jump list
		CComPtr<IApplicationDestinations> pDests;
		HRESULT hr = pDests.CoCreateInstance(CLSID_ApplicationDestinations, NULL, CLSCTX_INPROC_SERVER);
		if (SUCCEEDED(hr)) {
			hr = pDests->RemoveAllDestinations();
		}
	}
	if (!m_fKeepHistory || !m_fRememberDVDPos) {
		s.ClearDVDPositions();
	}
	if (!m_fKeepHistory || !m_fRememberFilePos) {
		s.ClearFilePositions();
	}

	m_nRecentFiles = min(max(MIN_RECENT_FILES, m_nRecentFiles), MAX_RECENT_FILES);
	s.iRecentFilesNumber = m_nRecentFiles;
	s.MRU.SetSize(s.iRecentFilesNumber);
	s.MRUDub.SetSize(s.iRecentFilesNumber);

	// Check if the settings location needs to be changed
	if (AfxGetMyApp()->IsIniValid() != !!m_fUseIni) {
		AfxGetMyApp()->ChangeSettingsLocation(!!m_fUseIni);
	}

	((CMainFrame*)AfxGetMainWnd())->ShowTrayIcon(s.fTrayIcon);

	::SetPriorityClass(::GetCurrentProcess(), s.dwPriority);

	GetDlgItem(IDC_FILE_POS)->EnableWindow(s.fKeepHistory);
	GetDlgItem(IDC_DVD_POS)->EnableWindow(s.fKeepHistory);
	m_RecentFilesCtrl.EnableWindow(s.fKeepHistory);

	return __super::OnApply();
}
BOOL Copencv_winApp::InitInstance()
{
	// 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을
	// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다. 
	// InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록
	// 이 항목을 설정하십시오.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	// OLE 라이브러리를 초기화합니다.
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	AfxEnableControlContainer();
	// 표준 초기화
	// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
	// 아래에서 필요 없는 특정 초기화
	// 루틴을 제거해야 합니다.
	// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
	// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
	// 적절한 내용으로 수정해야 합니다.
	SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));
	LoadStdProfileSettings(4);  // MRU를 포함하여 표준 INI 파일 옵션을 로드합니다.
	// 응용 프로그램의 문서 템플릿을 등록합니다. 문서 템플릿은
	//  문서, 프레임 창 및 뷰 사이의 연결 역할을 합니다.
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(IDR_opencv_winTYPE,
		RUNTIME_CLASS(Copencv_winDoc),
		RUNTIME_CLASS(CChildFrame), // 사용자 지정 MDI 자식 프레임입니다.
		RUNTIME_CLASS(Copencv_winView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);

	// 주 MDI 프레임 창을 만듭니다.
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
	{
		delete pMainFrame;
		return FALSE;
	}
	m_pMainWnd = pMainFrame;
	// 접미사가 있을 경우에만 DragAcceptFiles를 호출합니다.
	//  MDI 응용 프로그램에서는 m_pMainWnd를 설정한 후 바로 이러한 호출이 발생해야 합니다.


	// 표준 셸 명령, DDE, 파일 열기에 대한 명령줄을 구문 분석합니다.
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);


	// 명령줄에 지정된 명령을 디스패치합니다.
	// 응용 프로그램이 /RegServer, /Register, /Unregserver 또는 /Unregister로 시작된 경우 FALSE를 반환합니다.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// 주 창이 초기화되었으므로 이를 표시하고 업데이트합니다.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	return TRUE;
}
BOOL Cp11pensApp::InitInstance()
{
	// 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을
	// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다. 
	// InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록
	// 이 항목을 설정하십시오.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();


	// OLE 라이브러리를 초기화합니다.
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	EnableTaskbarInteraction(FALSE);

	// RichEdit 컨트롤을 사용하려면  AfxInitRichEdit2()가 있어야 합니다.	
	// AfxInitRichEdit2();

	// 표준 초기화
	// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
	// 아래에서 필요 없는 특정 초기화
	// 루틴을 제거해야 합니다.
	// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
	// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
	// 적절한 내용으로 수정해야 합니다.
	SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));


	// 주 창을 만들기 위해 이 코드에서는 새 프레임 창 개체를
	// 만든 다음 이를 응용 프로그램의 주 창 개체로 설정합니다.
	CMainFrame* pFrame = new CMainFrame;
	if (!pFrame)
		return FALSE;
	m_pMainWnd = pFrame;
	// 프레임을 만들어 리소스와 함께 로드합니다.
	pFrame->LoadFrame(IDR_MAINFRAME,
		WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);






	// 창 하나만 초기화되었으므로 이를 표시하고 업데이트합니다.
	pFrame->ShowWindow(SW_SHOW);
	pFrame->UpdateWindow();
	// 접미사가 있을 경우에만 DragAcceptFiles를 호출합니다.
	//  SDI 응용 프로그램에서는 ProcessShellCommand 후에 이러한 호출이 발생해야 합니다.
	return TRUE;
}
Exemple #21
0
BOOL CGuiApp::InitInstance()
{
  // 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
  
#if defined(TARGET_SH)
  target_name = "sh";
#elif defined(TARGET_H8300)
  target_name = "h8300";
#elif defined(TARGET_M68K)
  target_name = "m68k";
#elif defined(TARGET_SPARCLITE)
  target_name = "sparclite";
#elif defined(TARGET_MIPS)
  target_name = "mips";
#elif defined(TARGET_A29K)
  target_name = "a29k";
#elif defined(TARGET_I386)
   target_name = "i386";
#else
  HELP ME
#endif
     
   
    //  bpt_here_icon = LoadIcon(ID_SYM_FRAME_BPTHEREMARK);
    //  bpt_here_disabled_icon = LoadIcon(ID_SYM_FRAME_BPTHEREDISABLEDMARK);
    // pc_here_icon = LoadIcon(ID_ICON_PC_HERE);
    Enable3dControls();
  LoadStdProfileSettings();	
  CBrowserList::Initialize();
  //  CFlash::Initialize();
  CSrcB::Initialize();  
  CFrameDialog::Initialize();
  CIOLogView::Initialize();
   CCmdLogView::Initialize();
  CRegView::Initialize();
//  CSrcBrowser::Initialize();
  CSrcSplit::Initialize();
  CGnuInfoFrame::Initialize();
  CExpView::Initialize();
  CSrcSel::Initialize();
  CGlobalOptions::Initialize();  
  CBpt::Initialize();  


//  CMem::Initialize();



  m_IOLogTemplate 
    = new CMultiDocTemplate(
			    ID_SYM_FRAME_IOLOGTYPE,
			    RUNTIME_CLASS(CRegDoc),
			    RUNTIME_CLASS(CMDIChildWnd),
			    RUNTIME_CLASS(CIOLogView));
  AddDocTemplate(m_IOLogTemplate);
  

  m_CmdLogTemplate 
    = new CMultiDocTemplate(
			    ID_SYM_FRAME_LOGTYPE,
			    RUNTIME_CLASS(CRegDoc),
			    RUNTIME_CLASS(CMDIChildWnd),
			    RUNTIME_CLASS(CCmdLogView));
  AddDocTemplate(m_CmdLogTemplate);
  
  
  m_srcTemplate 
    = new CMultiDocTemplate(ID_SYM_FRAME_SRCTYPE,
			    RUNTIME_CLASS(CSrcD),
			    RUNTIME_CLASS(CSrcSplit),
			    RUNTIME_CLASS(CSrcScroll1));
  
  AddDocTemplate(m_srcTemplate);
  
  
  
  m_srcbrowserTemplate  
    = new CMultiDocTemplate(ID_SYM_FRAME_SRCBROWSER,
			    RUNTIME_CLASS(CGdbDoc),
			    RUNTIME_CLASS(CMiniMDIChildWnd),
			    RUNTIME_CLASS(CSrcB));
  AddDocTemplate(m_srcbrowserTemplate);

	   #if 0
  m_memTemplate  
    = new CMultiDocTemplate(ID_SYM_FRAME_MEMTYPE,
			    RUNTIME_CLASS(CRegDoc),
			    RUNTIME_CLASS(CMemFrame),
			    RUNTIME_CLASS(CMem));
  AddDocTemplate(m_memTemplate);
  #endif
  
  m_localTemplate  
    = new CMultiDocTemplate(ID_SYM_FRAME_LOCALTYPE,
			    RUNTIME_CLASS(CRegDoc),
			    RUNTIME_CLASS(CMiniMDIChildWnd),
			    RUNTIME_CLASS(CFrameDialog));
  AddDocTemplate(m_localTemplate);
  
  
  
  m_infoTemplate  
    = new CMultiDocTemplate(ID_SYM_FRAME_INFOTYPE,
			    RUNTIME_CLASS(CGnuInfoDoc),
			    RUNTIME_CLASS(CGnuInfoFrame),
			    RUNTIME_CLASS(CGnuInfoSView));
  AddDocTemplate(m_infoTemplate);
  
  
  
  m_regTemplate
    = new CMultiDocTemplate(ID_SYM_FRAME_REGTYPE,
			    RUNTIME_CLASS(CRegDoc),
			    RUNTIME_CLASS(CMiniMDIChildWnd),	// standard MDI child frame
			    RUNTIME_CLASS(CRegView));
  
  AddDocTemplate(m_regTemplate);
  
  
  
  m_expTemplate
    = new CMultiDocTemplate(ID_SYM_FRAME_EXPTYPE,
			    RUNTIME_CLASS(CExpDoc),
			    RUNTIME_CLASS(CMDIChildWnd),	
			    RUNTIME_CLASS(CExpView));
  
  AddDocTemplate(m_expTemplate);
  
  
  m_bptTemplate
    = new CMultiDocTemplate(ID_SYM_FRAME_BPTTYPE,
			    RUNTIME_CLASS(CBptDoc),
			    RUNTIME_CLASS(CMiniMDIChildWnd),	
			    RUNTIME_CLASS(CBpt));
  
  AddDocTemplate(m_bptTemplate);
  
  // Register our clipboard format names
  m_uiMyListClipFormat = ::RegisterClipboardFormat("My Object List");
  
  // create main MDI Frame window
  
  CMainFrame* pMainFrame = new CMainFrame;
  if (!pMainFrame->LoadFrame(ID_SYM_FRAME_MAINFRAME))
    return FALSE;
  m_pMainWnd = pMainFrame;
  
  /* Splash window */
  int nCmdShow = m_nCmdShow;
  //	BOOL bRunEmbedded = RunEmbedded();
  BOOL bRunEmbedded = FALSE;
  // setup main window
  nCmdShow = !bRunEmbedded ? m_nCmdShow : SW_HIDE;
  nCmdShow |= SW_SHOWMAXIMIZED;
  m_nCmdShow = SW_HIDE | SW_SHOWMAXIMIZED;
  pMainFrame->ShowWindow(nCmdShow);
  
  if (!bRunEmbedded)
    {
      m_pMainWnd->UpdateWindow();
      
      if (!m_pMainWnd->IsIconic() && m_lpCmdLine[0] == 0 &&
	  m_splash.Create(m_pMainWnd))
	{
	  m_splash.ShowWindow(SW_SHOW);
	  m_splash.UpdateWindow();
	  m_splash.SetTimer(1, 500, NULL);
	}
      m_dwSplashTime = ::GetCurrentTime();
    }
  
  
  /* end of splah window */
  
  // Create a command log window
  
  //	m_logTemplate->OpenDocumentFile(NULL);
  OnNewSrcwin();
  OnNewCmdwin();
  
  
  if (m_lpCmdLine[0] != '\0')
    {
      // TODO: add command line processing here
    }
  
  // The main window has been initialized, so show and update it.
  m_nCmdShow = nCmdShow ;
  pMainFrame->ShowWindow(m_nCmdShow);
  pMainFrame->UpdateWindow();
  
  main(0,0);
  
  /* Run the global options after main, cause
     we override some of the things main does */
CWinApp::Enable3dControls();
  
  COptionsSheet::Initialize();
  return TRUE;
}
Exemple #22
0
/////////////////////////////////////////////////////////////////////////////
// 加载DockingPane
// nID = -1表示加载所有自动加载的
/////////////////////////////////////////////////////////////////////////////
BOOL CPlugIn::LoadDockingPane(int nID, BOOL bProjectLoad)
{
	CMainFrame* pMainFrame = (CMainFrame*)(AfxGetMainWnd());
	if(nID == -1)
	{
		// 2007-09-09修改,不需要事先加载OWM,在窗口要显示时候会自动加载
		// 此段代码取消--如果组件尚未加载就先加载--
		//if((m_arDockingPane.GetSize() > 0) && (m_pVciObj == NULL))
		//{
		//	LoadOwmPlugIn();
		//}

		for(int i=0; i<m_arDockingPane.GetSize(); i++)
		{
			CXTPDockingPane* pPane = pMainFrame->GetPaneManager()->FindPane(m_arDockingPane[i].m_nId);
			// 如果需要自动创建,或者工程打开时创建(并且工程正在打开),或者Pane已经存在,则执行创建动作
			if(m_arDockingPane[i].m_bAutoCreate || (m_arDockingPane[i].m_bProjectCreate && bProjectLoad) || pPane)
			{
				CString strIconPath = m_arDockingPane[i].m_strIcon;
				if(strIconPath.Find(":") == -1)
				{
					strIconPath = m_strPath+"\\"+m_arDockingPane[i].m_strIcon;
				}
				WORD wIndex = 0;
				HICON hIcon = ::ExtractAssociatedIcon(theApp.m_hInstance,
					strIconPath.GetBuffer(0), &wIndex);
				strIconPath.ReleaseBuffer();
				if(m_arDockingPane[i].m_bAutoCreate || (m_arDockingPane[i].m_bProjectCreate && bProjectLoad))
				{
					pMainFrame->CreateDockingBar(m_arDockingPane[i].m_nId,
						m_arDockingPane[i].m_nDirection, hIcon);
				}else
				if(hIcon)
				{
					pMainFrame->GetPaneManager()->SetIcon(m_arDockingPane[i].m_nId,
						CXTPImageManagerIconHandle(hIcon));
				}
			}
		}
	}else
	{
		for(int i=0; i<m_arDockingPane.GetSize(); i++)
		{
			if(m_arDockingPane[i].m_nId == nID)
			{
				if(m_pVciObj == NULL)
				{
					LoadOwmPlugIn();
				}

				CString strIconPath = m_arDockingPane[i].m_strIcon;
				if(strIconPath.Find(":") == -1)
				{
					strIconPath = m_strPath+"\\"+m_arDockingPane[i].m_strIcon;
				}
				WORD wIndex = 0;
				HICON hIcon = ::ExtractAssociatedIcon(theApp.m_hInstance,
					strIconPath.GetBuffer(0), &wIndex);
				strIconPath.ReleaseBuffer();
				pMainFrame->CreateDockingBar(m_arDockingPane[i].m_nId,
					m_arDockingPane[i].m_nDirection, hIcon);
				return TRUE;
			}
		}
	}
	return TRUE;
}
BOOL CYPaintEditApp::InitInstance()
{
	CWinAppEx::InitInstance();


	// OLE 라이브러리를 초기화합니다.
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	EnableTaskbarInteraction(FALSE);

	// RichEdit 컨트롤을 사용하려면  AfxInitRichEdit2()가 있어야 합니다.	
	// AfxInitRichEdit2();

	// 표준 초기화
	// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
	// 아래에서 필요 없는 특정 초기화
	// 루틴을 제거해야 합니다.
	// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
	// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
	// 적절한 내용으로 수정해야 합니다.
	SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));
	LoadStdProfileSettings(4);  // MRU를 포함하여 표준 INI 파일 옵션을 로드합니다.


	InitContextMenuManager();

	InitKeyboardManager();

	InitTooltipManager();
	CMFCToolTipInfo ttParams;
	ttParams.m_bVislManagerTheme = TRUE;
	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

	// 응용 프로그램의 문서 템플릿을 등록합니다.  문서 템플릿은
	//  문서, 프레임 창 및 뷰 사이의 연결 역할을 합니다.
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(IDR_YPaintEditTYPE,
		RUNTIME_CLASS(CYPaintEditDoc),
		RUNTIME_CLASS(CChildFrame), // 사용자 지정 MDI 자식 프레임입니다.
		RUNTIME_CLASS(CYPaintEditView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);

	// 주 MDI 프레임 창을 만듭니다.
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
	{
		delete pMainFrame;
		return FALSE;
	}
	m_pMainWnd = pMainFrame;

	// 접미사가 있을 경우에만 DragAcceptFiles를 호출합니다.
	//  MDI 응용 프로그램에서는 m_pMainWnd를 설정한 후 바로 이러한 호출이 발생해야 합니다.
	// 끌어서 놓기에 대한 열기를 활성화합니다.
	m_pMainWnd->DragAcceptFiles();

	// 표준 셸 명령, DDE, 파일 열기에 대한 명령줄을 구문 분석합니다.
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// DDE Execute 열기를 활성화합니다.
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);


	// 명령줄에 지정된 명령을 디스패치합니다.
	// 응용 프로그램이 /RegServer, /Register, /Unregserver 또는 /Unregister로 시작된 경우 FALSE를 반환합니다.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// 주 창이 초기화되었으므로 이를 표시하고 업데이트합니다.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	return TRUE;
}
Exemple #24
0
/////////////////////////////////////////////////////////////////////////////
// 加载扩展菜单
/////////////////////////////////////////////////////////////////////////////
BOOL CPlugIn::AddOwmSubMenu(CString strMainMenu, CString strSubMenu, CString strAction)
{
	CMainFrame* pMainFrame = (CMainFrame*)(theApp.GetMainWnd());
	CXTPCommandBars* pCommandBars = pMainFrame->GetCommandBars();
	if(!pCommandBars)
	{
		return FALSE;		
	}
	CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar();
	if(!pMenuBar)
	{
		return FALSE;
	}

	CXTPControls* pControls = pMenuBar->GetControls();
	CXTPControl* pControl = pControls->GetFirst();
	CXTPCommandBar* pMenuBarSub = NULL;
	CXTPControl* pControlExtSub = NULL;
	while(pControl)
	{
		if(pControl->GetCaption() == strMainMenu)
		{
			pMenuBarSub = pControl->GetCommandBar();
			CXTPControls* pControlsSub = pMenuBarSub->GetControls();
			pControl = pControlsSub->GetFirst();
			while(pControl)
			{
				if(pControl->GetCaption() == strSubMenu)
				{
					pControlExtSub = pControl;
					break;
				}
				pControlsSub->GetNext(pControl);
			}			
			break;
		}
		pControls->GetNext(pControl);
	}
	if(pMenuBarSub && !pControlExtSub)
	{
		CExtMenuInfo extMenuInfo;
		extMenuInfo.m_strVciId = m_strId;
		extMenuInfo.m_strMainMenu = strMainMenu;
		extMenuInfo.m_strSubMenu = strSubMenu;
		extMenuInfo.pProc = (TYPEOF_ClientMenu*)OnOwmExtMenuProc;
		extMenuInfo.pUpdateProc = NULL;
		extMenuInfo.nProcType = MENU_PROC_TYPE_PARAM_ID;
		
		int nExMenuId = IDM_OWMCMD+g_nIdOwmExMenu;
		extMenuInfo.m_strAction = strAction;
		extMenuInfo.nId = nExMenuId-IDM_OWMCMD;
		pMainFrame->m_arExtMenuInfo.Add(extMenuInfo);

		CXTPControls* pControlsSub = pMenuBarSub->GetControls();
		CMenu* pMenu = new CMenu();
		pMenu->CreatePopupMenu();
		pMenu->AppendMenu(MF_STRING, nExMenuId, strSubMenu);
		pControlsSub->AddMenuItem(pMenu, 0);
		delete pMenu;

		g_nIdOwmExMenu++;
	}

	return TRUE;
}
Exemple #25
0
//
// strName is the script name, with out the .sc.
// e.g. "rm050"
//
void AppState::OpenScript(std::string strName, const ResourceBlob *pData, WORD wScriptNum)
{
    if (_pScriptTemplate && _pApp)
    {
        ScriptId scriptId = _resourceMap.Helper().GetScriptId(strName);
        if (!scriptId.IsNone())
        {
            if (wScriptNum == InvalidResourceNumber)
            {
                if (pData)
                {
                    wScriptNum = pData->GetNumber();
                }
                else
                {
                    if (FAILED(GetResourceMap().GetScriptNumber(scriptId, wScriptNum)))
                    {
                        LogInfo("Couldn't get script number for %s", scriptId.GetFullPath());
                    }
                }
            }
            scriptId.SetResourceNumber(wScriptNum);

            // If it's already open, just activate it.
            CMainFrame *pMainWnd = static_cast<CMainFrame*>(_pApp->m_pMainWnd);
            CScriptDocument *pDocAlready = pMainWnd->Tabs().ActivateScript(scriptId);
            if (pDocAlready == nullptr)
            {
                std::string fullPath = scriptId.GetFullPath();
                bool fOpened = false;
                // Do an extra check first here - we don't want MFC to put up error UI if the path
                // can not be found, since we're going to do that.
                if (PathFileExists(fullPath.c_str()))
                {
                    CScriptDocument *pDocument =
                        static_cast<CScriptDocument*>(_pScriptTemplate->OpenDocumentFile(fullPath.c_str(), TRUE));
                    fOpened = (pDocument != nullptr);
                    if (pDocument)
                    {
                        pDocument->SetTitle(scriptId.GetFileNameOrig().c_str());
                        pDocument->SetDependencyTracker(GetResourceMap().GetDependencyTracker());
                        // We lost context...
                        pDocument->SetScriptNumber(scriptId.GetResourceNumber());
                    }
                }
                if (!fOpened)
                {
                    std::string message = scriptId.GetFullPath();
                    message += " could not be opened.";
                    if (pData)
                    {
                        message += "\nWould you like to see the disassembly instead?";
                        if (IDYES == AfxMessageBox(message.c_str(), MB_YESNO | MB_APPLMODAL))
                        {
                            // Show the disassembly.
                            DisassembleScript((WORD)pData->GetNumber());
                        }
                    }
                    else
                    {
                        AfxMessageBox(message.c_str(), MB_OK | MB_ICONEXCLAMATION);
                    }
                }
            }
        }
    }
}
void CPlayerPlaylistBar::OnContextMenu(CWnd* /*pWnd*/, CPoint p)
{
    LVHITTESTINFO lvhti;
    lvhti.pt = p;
    m_list.ScreenToClient(&lvhti.pt);
    m_list.SubItemHitTest(&lvhti);

    POSITION pos = FindPos(lvhti.iItem);
    //bool fSelected = (pos == m_pl.GetPos());
    bool fOnItem = !!(lvhti.flags & LVHT_ONITEM);

    CMenu m;
    m.CreatePopupMenu();

    enum {
        M_OPEN = 1, M_ADD, M_REMOVE, M_CLEAR, M_CLIPBOARD, M_SAVEAS,
        M_SORTBYNAME, M_SORTBYPATH, M_RANDOMIZE, M_SORTBYID,
        M_SHUFFLE, M_HIDEFULLSCREEN
    };

    CAppSettings& s = AfxGetAppSettings();

    m.AppendMenu(MF_STRING | (!fOnItem ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_OPEN, ResStr(IDS_PLAYLIST_OPEN));
    if (((CMainFrame*)AfxGetMainWnd())->GetPlaybackMode() == PM_CAPTURE) {
        m.AppendMenu(MF_STRING | MF_ENABLED, M_ADD, ResStr(IDS_PLAYLIST_ADD));
    }
    m.AppendMenu(MF_STRING | (/*fSelected||*/!fOnItem ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_REMOVE, ResStr(IDS_PLAYLIST_REMOVE));
    m.AppendMenu(MF_SEPARATOR);
    m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_CLEAR, ResStr(IDS_PLAYLIST_CLEAR));
    m.AppendMenu(MF_SEPARATOR);
    m.AppendMenu(MF_STRING | (!fOnItem ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_CLIPBOARD, ResStr(IDS_PLAYLIST_COPYTOCLIPBOARD));
    m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SAVEAS, ResStr(IDS_PLAYLIST_SAVEAS));
    m.AppendMenu(MF_SEPARATOR);
    m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SORTBYNAME, ResStr(IDS_PLAYLIST_SORTBYLABEL));
    m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SORTBYPATH, ResStr(IDS_PLAYLIST_SORTBYPATH));
    m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_RANDOMIZE, ResStr(IDS_PLAYLIST_RANDOMIZE));
    m.AppendMenu(MF_STRING | (!m_pl.GetCount() ? (MF_DISABLED | MF_GRAYED) : MF_ENABLED), M_SORTBYID, ResStr(IDS_PLAYLIST_RESTORE));
    m.AppendMenu(MF_SEPARATOR);
    m.AppendMenu(MF_STRING | MF_ENABLED | (s.bShufflePlaylistItems ? MF_CHECKED : MF_UNCHECKED), M_SHUFFLE, ResStr(IDS_PLAYLIST_SHUFFLE));
    m.AppendMenu(MF_SEPARATOR);
    m.AppendMenu(MF_STRING | MF_ENABLED | (s.bHidePlaylistFullScreen ? MF_CHECKED : MF_UNCHECKED), M_HIDEFULLSCREEN, ResStr(IDS_PLAYLIST_HIDEFS));

    CMainFrame* pMainFrm = (CMainFrame*)AfxGetMainWnd();

    int nID = (int)m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, this);
    switch (nID) {
        case M_OPEN:
            m_pl.SetPos(pos);
            m_list.Invalidate();
            pMainFrm->OpenCurPlaylistItem();
            break;
        case M_ADD:
            pMainFrm->AddCurDevToPlaylist();
            m_pl.SetPos(m_pl.GetTailPosition());
            break;
        case M_REMOVE:
            if (m_pl.RemoveAt(pos)) {
                pMainFrm->CloseMedia();
            }
            m_list.DeleteItem(lvhti.iItem);
            SavePlaylist();
            break;
        case M_CLEAR:
            if (Empty()) {
                pMainFrm->CloseMedia();
            }
            break;
        case M_SORTBYID:
            m_pl.SortById();
            SetupList();
            SavePlaylist();
            break;
        case M_SORTBYNAME:
            m_pl.SortByName();
            SetupList();
            SavePlaylist();
            break;
        case M_SORTBYPATH:
            m_pl.SortByPath();
            SetupList();
            SavePlaylist();
            break;
        case M_RANDOMIZE:
            m_pl.Randomize();
            SetupList();
            SavePlaylist();
            break;
        case M_CLIPBOARD:
            if (OpenClipboard() && EmptyClipboard()) {
                CString str;

                CPlaylistItem& pli = m_pl.GetAt(pos);
                POSITION pos2 = pli.m_fns.GetHeadPosition();
                while (pos2) {
                    str += _T("\r\n") + pli.m_fns.GetNext(pos2);
                }
                str.Trim();

                if (HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, (str.GetLength() + 1) * sizeof(TCHAR))) {
                    if (TCHAR* cp = (TCHAR*)GlobalLock(h)) {
                        _tcscpy_s(cp, str.GetLength() + 1, str);
                        GlobalUnlock(h);
                        SetClipboardData(CF_UNICODETEXT, h);
                    }
                }
                CloseClipboard();
            }
            break;
        case M_SAVEAS: {
            CSaveTextFileDialog fd(
                CTextFile::ASCII, NULL, NULL,
                _T("Media Player Classic playlist (*.mpcpl)|*.mpcpl|Playlist (*.pls)|*.pls|Winamp playlist (*.m3u)|*.m3u|Windows Media playlist (*.asx)|*.asx||"),
                this);

            if (fd.DoModal() != IDOK) {
                break;
            }

            CTextFile::enc encoding = (CTextFile::enc)fd.GetEncoding();
            if (encoding == CTextFile::ASCII) {
                encoding = CTextFile::ANSI;
            }

            int idx = fd.m_pOFN->nFilterIndex;

            CPath path(fd.GetPathName());

            switch (idx) {
                case 1:
                    path.AddExtension(_T(".mpcpl"));
                    break;
                case 2:
                    path.AddExtension(_T(".pls"));
                    break;
                case 3:
                    path.AddExtension(_T(".m3u"));
                    break;
                case 4:
                    path.AddExtension(_T(".asx"));
                    break;
                default:
                    break;
            }

            bool fRemovePath = true;

            CPath p(path);
            p.RemoveFileSpec();
            CString base = (LPCTSTR)p;

            pos = m_pl.GetHeadPosition();
            while (pos && fRemovePath) {
                CPlaylistItem& pli = m_pl.GetNext(pos);

                if (pli.m_type != CPlaylistItem::file) {
                    fRemovePath = false;
                } else {
                    POSITION pos;

                    pos = pli.m_fns.GetHeadPosition();
                    while (pos && fRemovePath) {
                        CString fn = pli.m_fns.GetNext(pos);

                        CPath p(fn);
                        p.RemoveFileSpec();
                        if (base != (LPCTSTR)p) {
                            fRemovePath = false;
                        }
                    }

                    pos = pli.m_subs.GetHeadPosition();
                    while (pos && fRemovePath) {
                        CString fn = pli.m_subs.GetNext(pos);

                        CPath p(fn);
                        p.RemoveFileSpec();
                        if (base != (LPCTSTR)p) {
                            fRemovePath = false;
                        }
                    }
                }
            }

            if (idx == 1) {
                SaveMPCPlayList(path, encoding, fRemovePath);
                break;
            }

            CTextFile f;
            if (!f.Save(path, encoding)) {
                break;
            }

            if (idx == 2) {
                f.WriteString(_T("[playlist]\n"));
            } else if (idx == 4) {
                f.WriteString(_T("<ASX version = \"3.0\">\n"));
            }

            pos = m_pl.GetHeadPosition();
            CString str;
            int i;
            for (i = 0; pos; i++) {
                CPlaylistItem& pli = m_pl.GetNext(pos);

                if (pli.m_type != CPlaylistItem::file) {
                    continue;
                }

                CString fn = pli.m_fns.GetHead();

                /*
                            if (fRemovePath)
                            {
                                CPath p(path);
                                p.StripPath();
                                fn = (LPCTSTR)p;
                            }
                */

                switch (idx) {
                    case 2:
                        str.Format(_T("File%d=%s\n"), i + 1, fn);
                        break;
                    case 3:
                        str.Format(_T("%s\n"), fn);
                        break;
                    case 4:
                        str.Format(_T("<Entry><Ref href = \"%s\"/></Entry>\n"), fn);
                        break;
                    default:
                        break;
                }
                f.WriteString(str);
            }

            if (idx == 2) {
                str.Format(_T("NumberOfEntries=%d\n"), i);
                f.WriteString(str);
                f.WriteString(_T("Version=2\n"));
            } else if (idx == 4) {
                f.WriteString(_T("</ASX>\n"));
            }
        }
        break;
        case M_SHUFFLE:
            s.bShufflePlaylistItems = !s.bShufflePlaylistItems;
            break;
        case M_HIDEFULLSCREEN:
            s.bHidePlaylistFullScreen = !s.bHidePlaylistFullScreen;
            break;
        default:
            break;
    }
}
Exemple #27
0
void CShapePropSheetFrame::OnClose()
{
    // Instead of closing the modeless property sheet, just hide it.
    CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
    pMainFrame->HideModelessPropSheet();
}
void CSearchView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class

	m_listSearch.m_nType = SEARCHVIEW;	// 리스트가 지신의 기능만을 처리할수 있는 타입값

	// 접속되어있는 클라이언트의 목록을 추가
	m_comboFilter.AddString("전체");
	int count = ((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_nClntCount;
	char szClntName[256];
	char szClntIP[20];
	for(int i=0; i<count; i++){
		strcpy(szClntName, ((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_clntSock[i].clntName);
		strcpy(szClntIP, inet_ntoa(((CMainFrame *)AfxGetMainWnd())->m_myIOCPSocket.m_clntSock[i].pClntData->clntAddr.sin_addr));
		sprintf(szClntName, "%s [%s]", szClntName, szClntIP);
		m_comboFilter.AddString(szClntName);
	}
	
	m_comboFilter.SetCurSel(0);

	InsertColumn();	// 컬럼 추가

	// 처음에 탭내용이 하나도 없으면 탭컨트롤이 안보이게(처음부터 보이면 모양이 이상해짐)
	if(m_nTabCnt == 0){
		m_tabSearch.ShowWindow(FALSE);
	}

	CMainFrame *pMain = ((CMainFrame *)AfxGetMainWnd());

	pMain->GetSysImgList(m_listSearch, m_imgSmallList);	// 시스템아이콘얻기


	// 다른메뉴를 선택했다가 다시 이뷰를 선택하면 다시 초기화가 되므로 생성되었던 탭을 생성	
	if(m_nTabCnt != 0){
		
		UINT cnt = 0;	
		CString strName;	// 검색된 파일이름
		UINT nFileCnt;	// 검색된 파일수
		UINT nImage;	// 아이콘 이미지
		while(cnt != m_nTabCnt){		
			strName = pMain->m_searchListData[cnt].strSearchListFileName;
			nFileCnt = pMain->m_searchListData[cnt].nSearchListSize;
			nImage = 0;
			if(nFileCnt > 5){	// 검색된게 많으면 아이콘을 바꿈
				nImage = 1;
			}
			CreateTab(strName, nFileCnt, nImage);	// 동적으로 탭추가, 두번째 파라미터로 마지막 생성되는것만 리스트에 데이타를 넣는다		
			cnt ++;
		}
		CString strFileName;	// 파일명
		UINT nSize;		// 파일사이즈
		CString strServerName;	// 서버이름
		CString strServerIP;	// 서버아이피
		CString strServerInfo;	// 서버정보
		for(UINT i=0; i<nFileCnt; i++){	// 리스트 내용
			strFileName = pMain->m_searchListData[m_nTabCnt - 1].searchListData[i].strFileName;
			nSize = pMain->m_searchListData[m_nTabCnt - 1].searchListData[i].nByte;
			strServerName.Format("%s", pMain->m_searchListData[m_nTabCnt - 1].strServerName[i]);	// 서버이름
			strServerIP.Format("%s", pMain->m_searchListData[m_nTabCnt - 1].strServerIP[i]);	// 서버아이피
			strServerInfo.Format("%s [%s]", strServerName, strServerIP);
			AddItem(strFileName, nSize, strServerInfo, FALSE);
		}
	}
	
	GetDlgItem(IDC_EDIT_SEARCHKEY)->SetFocus();

	
}
Exemple #29
0
CFGMeshViewView * GetCFGMeshView()
{
	CMainFrame *pFrame = (CMainFrame *) AfxGetApp()->m_pMainWnd;
	return (CFGMeshViewView *) pFrame->GetSafeHwnd(); 
};
Exemple #30
0
BOOL CDComDoc::OnOpenDocument(SDialingDir *psDialingDir)
{
    char *pRet;
    BOOL bRet = FALSE;
    CMainFrame *pMainFrm = (CMainFrame *)AfxGetMainWnd();

    if (pMainFrm == NULL)
    {
        return FALSE;
    }
    memcpy(&m_sDialingDir, psDialingDir, sizeof(SDialingDir));

    if (m_sDialingDir.nType == DCOM_DD_SERIAL)
    {
        m_nContextMenuId = IDR_SERIAL_CONTEXT;
        m_pTgtIntf = new TgtSerialIntf;
        if (m_pTgtIntf)
        {
            ((TgtSerialIntf*)m_pTgtIntf)->TgtSetConfig(
                m_sDialingDir.szAddress,
                m_sDialingDir.m_dwBaudRate,
                m_sDialingDir.m_byParity,
                m_sDialingDir.m_byStopBits,
                m_sDialingDir.m_byByteSize);
        }
    }
    else if (m_sDialingDir.nType == DCOM_DD_SSH)
    {
        m_pTgtIntf = new TgtSshIntf;
        if (m_pTgtIntf)
        {
            ((TgtSshIntf*)m_pTgtIntf)->TgtSetConfig(
                m_sDialingDir.szAddress,
                m_sDialingDir.nPort,
                m_sDialingDir.szDescription);
        }
    }
    else if (m_sDialingDir.nType == DCOM_DD_TELNET)
    {
        m_pTgtIntf = new TgtTelnetIntf;
        if (m_pTgtIntf)
        {
            ((TgtTelnetIntf*)m_pTgtIntf)->TgtSetConfig(
                m_sDialingDir.szAddress,
                m_sDialingDir.nPort,
                m_sDialingDir.szDescription);
        }
    }
    else if (m_sDialingDir.nType == DCOM_DD_DEBUG)
    {
        m_pTgtIntf = new TgtFileIntf;
        if (m_pTgtIntf)
        {
            ((TgtFileIntf*)m_pTgtIntf)->TgtSetConfig(
                m_sDialingDir.szAddress);
        }
    }

    if (m_pTgtIntf)
    {
        SetConfig(pMainFrm->GetConfig());
        pRet = m_pTgtIntf->TgtConnect();
        if (pRet == NULL)
        {
            m_hThreadTerminated = CreateEvent(0,0,0,0);
            m_hThreadTerm = CreateEvent(0,0,0,0);
            m_cTgtIntfThread = AfxBeginThread(&CDComDoc::TgtIntfThread, (LPVOID)this, THREAD_PRIORITY_IDLE);
            bRet = TRUE;
        }
        else
        {
            AfxMessageBox(pRet);
        }
    }
    return bRet;
}