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

📄 visualjava.cpp

📁 用bcg库编写的java IDE 源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	}
	if (!AfxSocketInit())
	{
		AfxMessageBox("Socket intialization failed");
		return FALSE;
	}
	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.

#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(_T("MY COMAPNY"));

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

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

	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_VISUALJAVATYPE,
		RUNTIME_CLASS(CVisualJavaDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CVisualJavaView));
	AddDocTemplate(pDocTemplate);

	pDocTemplate = new CMultiDocTemplate(
		IDR_VISUALJAVATYPE,
		RUNTIME_CLASS(CPopUpDocument),
		RUNTIME_CLASS(CPopUpFrameWnd), // custom MDI child frame
		RUNTIME_CLASS(CPopUpView));
	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);

	//Surpresses creation of child initial child window
	if(CCommandLineInfo::FileNew == cmdInfo.m_nShellCommand)
		cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;


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

	LoadCustomState ();

	//loads code template for project creation wizard.
	m_pCodeTemplates = new CCodeTemplate;
	m_pCodeTemplates->SetPath(CString("C:\\My Documents\\codetemplates__1.txt"));
	m_pCodeTemplates->LoadCodeTemplates();

    //load tool settings, so u can use the sdk.
	m_pToolRunner->LoadToolSettings();
    CReg reg;
    LPCTSTR lszpBase = REGISTRY_ROOT;
    if(reg.Create(HKEY_CURRENT_USER,lszpBase,KEY_READ))
    {
       CReg rgSDK;
       if(rgSDK.Create(reg.hKey,"JAVA_SDK",KEY_READ))
	   {
	     rgSDK.LoadString("API Path",m_strAPIPath);
	     rgSDK.Close();
	   }reg.Close();	 
    }
	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();
	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
		// No message handlers
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CVisualJavaApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// Customization load/save methods

#define KEYBOARD_ENTRY		_T("Keyboard")
#define MOUSE_ENTRY			_T("Mouse")
#define CONTEXT_MENU_ENTRY	_T("ContextMenus")

void CVisualJavaApp::LoadCustomState ()
{
	CString strKbdEntry = REGISTRY_ROOT;
	strKbdEntry += KEYBOARD_ENTRY;

	m_KeyboardManager.LoadState (strKbdEntry);
	m_MouseManager.AddView (IDR_MAINFRAME, _T("My view"), IDR_MAINFRAME);

	CString strMenuEntry = REGISTRY_ROOT;
	strMenuEntry += CONTEXT_MENU_ENTRY;


	// TODO: add another context menus here
	m_ContextMenuManager.AddMenu("Workspace Menu",IDR_WORKSPC_MENU);
	m_ContextMenuManager.AddMenu("Project Menu",IDR_PROJECT_MENU);
	m_ContextMenuManager.AddMenu("Folder Menu",IDR_FOLDER_MENU);
	m_ContextMenuManager.AddMenu("File Menu",IDR_FILE_MENU);
	m_ContextMenuManager.AddMenu("Output Menu",IDR_OUTPUT_MENU);

	m_ContextMenuManager.LoadState (strMenuEntry);
}

void CVisualJavaApp::SaveCustomState ()
{
	CString strKbdEntry = REGISTRY_ROOT;
	strKbdEntry += KEYBOARD_ENTRY;

	m_KeyboardManager.SaveState (strKbdEntry);

	CString strMouseEntry = REGISTRY_ROOT;
	strMouseEntry += MOUSE_ENTRY;

	m_MouseManager.SaveState (strMouseEntry);

	CString strMenuEntry = REGISTRY_ROOT;
	strMenuEntry += CONTEXT_MENU_ENTRY;

	m_ContextMenuManager.SaveState (strMenuEntry);
}


BOOL CVisualJavaApp::ShowPopupMenu (UINT uiMenuResId, const CPoint& point, CWnd* pWnd)
{
	return m_ContextMenuManager.ShowPopupMenu(uiMenuResId,point.x,point.y,pWnd);
}
/////////////////////////////////////////////////////////////////////////////
// CVisualJavaApp message handlers


int CVisualJavaApp::ExitInstance() 
{
  FreeLibrary (GetModuleHandle (_T ("RICHED32.DLL")));
  if(m_dwFlags & EP_SAVE_SETS_ON_EXIT)
  {
      SaveSettings ();
  }
  BOOL result = CWinApp::ExitInstance ();	

  return CWinApp::ExitInstance();
}

void CVisualJavaApp::ParseCommandLine(CCommandLineInfo &rCmdInfo) //  by Serge Weinstock
{
  // notepad receive only one argument, so we have to merge all the args
  m_OneArg.Empty();
  for(int i = 1; i < __argc; i++)
  {
    if(i > 1)
     m_OneArg += _T(' ');
    m_OneArg += __targv[i];
  }
  rCmdInfo.ParseParam(m_OneArg, false, true);
}



void CVisualJavaApp::OnFileNew()
{
	//CWinApp::OnFileNew();
  /*if (m_pDocManager != NULL)
    {
      CDocTemplate *pBinTempl = (CDocTemplate*) ((CPubDocManager*) m_pDocManager)->m_templateList.GetTail ();
      if (((CPubDocManager*) m_pDocManager)->m_templateList.GetCount () > 1)
        {
          ((CPubDocManager*) m_pDocManager)->m_templateList.RemoveTail ();
          CWinApp::OnFileNew();
          ((CPubDocManager*) m_pDocManager)->m_templateList.AddTail (pBinTempl);
        }
      else
        CWinApp::OnFileNew();
    }*/

//	POSITION nPos = GetFirstDocTemplatePosition();
	//GetNextDocTemplate(nPos);
//    GetNextDocTemplate(nPos)->OpenDocumentFile(NULL);

}

void CVisualJavaApp::OnFileOpen()
{
	static char BASED_CODE szFilter[]="JavaJam WorkSpace Files (*.dsw)|*.dsw| All Files (*.*)|*.*||";
	DWORD flags = OFN_CREATEPROMPT|OFN_ALLOWMULTISELECT;
	CFileOpenDlgEx open(TRUE,NULL,NULL,flags,szFilter);

	if(open.DoModal() == IDOK)
	{




	}

  //ASSERT(m_pDocManager != NULL);
  /*
  DWORD flags = OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST|OFN_EXPLORER|OFN_ENABLEHOOK;

  static char BASED_CODE szFilter[]=
		"Java Source Files (*.java)|*.java| All Files (*.*)|*.*||";

  CExFileOpen dlgFile (TRUE, _T (""), _T (""),flags, _T("Supported Documents (...)|*.lsp;*.bas;*.vb;*.vbs;*.frm;*.dsm;*.bat;*.btm;*.cmd;*.c;*.cc;*.cpp;*.cxx;*.h;*.hpp;*.hxx;*.hm;*.inl;*.rh;*.tlh;*.tli;*.xs;*.dcl;*.dcc;*.f;*.f90;*.f9p;*.fpp;*.html;*.htm;*.shtml;*.ihtml;*.ssi;*.rul;*.java;*.jav;*.pas;*.pl;*.txt;*.doc;*.diz;*.py;*.rc;*.dlg;*.rex;*.rexx;*.sgml;*.sh;*.conf;*.scm;*.sql;*.tcl;*.text;*.sty;*.cls;*.clo;*.ltx;*.fd;*.dtx|All Files (*.*)|*.*||"), AfxGetMainWnd ());
  static TCHAR szFileListBuffer[8192];
  CString title;
  VERIFY (title.LoadString (AFX_IDS_OPENFILE));


  *szFileListBuffer = _T ('\0');
  dlgFile.m_ofn.lpstrFile = szFileListBuffer;
  dlgFile.m_ofn.nMaxFile = countof (szFileListBuffer);
  dlgFile.m_ofn.lpstrTitle = title;
  static TCHAR szPath[_MAX_PATH];
  dlgFile.m_ofn.lpstrInitialDir = szPath;

  if (dlgFile.DoModal() == IDOK)
    {
      POSITION pos = dlgFile.GetStartPosition ();
      CVisualJavaDoc *pDoc;
      int oldEncoding = CCrystalTextBuffer::m_nDefaultEncoding;
      CCrystalTextBuffer::m_nDefaultEncoding = -1;//dlgFile.m_nEncoding;
      while (pos)
        {
          pDoc = (CVisualJavaDoc*) OpenDocumentFileEx (dlgFile.GetNextPathName (pos), dlgFile.m_nFormat);
          if (pDoc && dlgFile.GetReadOnlyPref())
            pDoc->OnReadOnly ();
        }
      CCrystalTextBuffer::m_nDefaultEncoding = oldEncoding;
    }
*/
}


void CVisualJavaApp::OnTipOfTheDay ()
{
	//CTipDlg dlg;
	//dlg.DoModal();
}

void CVisualJavaApp::OnFileSaveAll ()
{
  POSITION pos = GetFirstDocTemplatePosition ();
  ASSERT (pos);
  CDocTemplate *pDocTempl = GetNextDocTemplate (pos);
  pos = pDocTempl->GetFirstDocPosition ();
  while (pos)
    {
      CVisualJavaDoc *pDoc = (CVisualJavaDoc*) pDocTempl->GetNextDoc (pos);
      ASSERT (pDoc);
      CString sDocPath = pDoc->GetPathName ();
      if (pDoc->IsModified ())
        pDoc->DoSave (sDocPath);
    }
  // SaveAllModified ();
}


#include <..\src\afximpl.h>

CDocument *CVisualJavaApp::OpenDocumentFileEx(LPCTSTR lpszFileName, int nType)
{
	TCHAR szPath[_MAX_PATH];
	ASSERT (_tcslen (lpszFileName) < countof (szPath));

	TCHAR szTemp[_MAX_PATH];
	if(lpszFileName[0] == '\"')
		++lpszFileName;

	_tcsncpy (szTemp, lpszFileName, _MAX_PATH);
	LPTSTR lpszLast = _tcsrchr (szTemp, '\"');

	if(lpszLast != NULL)
		*lpszLast = 0;

	AfxFullPath (szPath, szTemp);
	TCHAR szLinkName[_MAX_PATH];

	if(AfxResolveShortcut(AfxGetMainWnd(),szPath,szLinkName,_MAX_PATH))
		_tcscpy(szPath,szLinkName);

  POSITION pos = GetFirstDocTemplatePosition();
  CDocTemplate *pTempl, *pBestTemplate = NULL;

  CDocument *pOpenDocument = NULL;
  CDocTemplate::Confidence match;
  int nIndex = 0;

  if(nType == 1)
    nType = 0;

  while(pos)
  {
      pTempl = GetNextDocTemplate (pos);
  		ASSERT_KINDOF(CDocTemplate, pTempl);
		  ASSERT (pOpenDocument == NULL);
		  match = pTempl->MatchDocType (szPath, pOpenDocument);
      if (match == CDocTemplate::yesAlreadyOpen)
        break;
      if (nIndex++ == nType)
        pBestTemplate = pTempl;
  }

  ASSERT(pTempl);

  if(pOpenDocument != NULL)
  {
		  POSITION pos = pOpenDocument->GetFirstViewPosition();
		  if(pos)
		  {
			    CView* pView = pOpenDocument->GetNextView(pos); // get first one
			    ASSERT_VALID(pView);
			    CFrameWnd* pFrame = pView->GetParentFrame();
			    if(pFrame != NULL)
				    pFrame->ActivateFrame();
			    else
				TRACE0("Error: Can not find a frame for document to activate.\n");
			    CFrameWnd* pAppFrame;
			    
				if(pFrame != (pAppFrame = (CFrameWnd*)AfxGetApp()->m_pMainWnd))
				{
				   ASSERT_KINDOF(CFrameWnd, pAppFrame);
				   pAppFrame->ActivateFrame();
				}
		  }
		  else
		  {
			    TRACE0("Error: Can not find a view for document to activate.\n");
		  }
		  return pOpenDocument;
  }

  if(pBestTemplate == NULL)
  {
	  AfxMessageBox(AFX_IDP_FAILED_TO_OPEN_DOC);
	  return NULL;
  }
  return pBestTemplate->OpenDocumentFile(szPath/*,FALSE*/);
}

void CVisualJavaApp::OpenDocumentFileEx(CJavaTextBuffer* pBuf,
										 LPCTSTR lpszFileName,
										 int nType)
{/*
	TCHAR szPath[_MAX_PATH];
	ASSERT (_tcslen (lpszFileName) < countof (szPath));

	TCHAR szTemp[_MAX_PATH];
	if(lpszFileName[0] == '\"')
		++lpszFileName;

	_tcsncpy (szTemp, lpszFileName, _MAX_PATH);
	LPTSTR lpszLast = _tcsrchr (szTemp, '\"');

	if(lpszLast != NULL)
		*lpszLast = 0;

	AfxFullPath (szPath, szTemp);
	TCHAR szLinkName[_MAX_PATH];

	if(AfxResolveShortcut(AfxGetMainWnd(),szPath,szLinkName,_MAX_PATH))
		_tcscpy(szPath,szLinkName);

  POSITION pos = GetFirstDocTemplatePosition();
  CDocTemplate *pTempl, *pBestTemplate = NULL;

  CDocument *pOpenDocument = NULL;
  CDocTemplate::Confidence match;
  int nIndex = 0;

  if(nType == 1)
    nType = 0;

  while(pos)
  {
      pTempl = GetNextDocTemplate (pos);
  		ASSERT_KINDOF(CDocTemplate, pTempl);
		  ASSERT (pOpenDocument == NULL);
		  match = pTempl->MatchDocType (szPath, pOpenDocument);
      if (match == CDocTemplate::yesAlreadyOpen)
        break;
      if (nIndex++ == nType)
        pBestTemplate = pTempl;
  }

  ASSERT(pTempl);

  if(pOpenDocument != NULL)
  {
	 POSITION pos = pOpenDocument->GetFirstViewPosition();
	 if(pos)
	 {
		CView* pView = pOpenDocument->GetNextView(pos); // get first one
		ASSERT_VALID(pView);
		CFrameWnd* pFrame = pView->GetParentFrame();
		if(pFrame != NULL)
			pFrame->ActivateFrame();
	    else
		   TRACE0("Error: Can not find a frame for document to activate.\n");
		CFrameWnd* pAppFrame;
			    
		if(pFrame != (pAppFrame = (CFrameWnd*)AfxGetApp()->m_pMainWnd))
		{
		   ASSERT_KINDOF(CFrameWnd,pAppFrame);
		   pAppFrame->ActivateFrame();

⌨️ 快捷键说明

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