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

📄 jeditinitdlg.h

📁 Java写的文本编辑器
💻 H
字号:
/* * jeditinitDlg.h - part of jEditLauncher package * Copyright (C) 2001 John Gellene * jgellene@nyc.rr.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * Notwithstanding the terms of the General Public License, the author grants * permission to compile and link object code generated by the compilation of * this program with object code and libraries that are not subject to the * GNU General Public License, provided that the executable output of such * compilation shall be distributed with source code on substantially the * same basis as the jEditLauncher package of which this program is a part. * By way of example, a distribution would satisfy this condition if it * included a working makefile for any freely available make utility that * runs on the Windows family of operating systems. This condition does not * require a licensee of this software to distribute any proprietary software * (including header files and libraries) that is licensed under terms * prohibiting redistribution to third parties. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * $Id: jeditinitDlg.h,v 1.2 2001/07/14 21:35:02 jgellene Exp $ */// jeditinitDlg.h : Declaration of the CJeditinitDlg#ifndef __jeditinitDLG_H_#define __jeditinitDLG_H_#include "resource.h"       // main symbols#include "StringPtr.h"#define IDS_COMBO_BEGIN IDS_COMBO_1#define IDS_COMBO_END (IDS_COMBO_6 + 1)// Version-specific defines#define IDD_ABOUTBOX			IDD_ABOUTBOX_3_2#define IDS_MSG_USAGE			IDS_MSG_USAGE_3_2/////////////////////////////////////////////////////////////////////////////// CJeditinitDlgclass CJeditinitDlg :	public CDialogImpl<CJeditinitDlg>{public:	CJeditinitDlg()		: m_bIsExchanging(FALSE), m_bIsDirty(FALSE)	{	}	~CJeditinitDlg()	{	}	enum { IDD = IDD_JEDITINIT_DIALOG };private:	enum { JavaExec, JavaOptions,		JEditTarget, JEditOptions, JEditWorkingDir, CmdLine};	OPENFILENAME m_ofn;	BROWSEINFO m_brinfo;	TCHAR m_szFileName[MAX_PATH];	CString m_strings[6];	HWND m_hwnds[6];	HICON m_hIcon;	BOOL m_bIsExchanging;	BOOL m_bIsDirty;BEGIN_MSG_MAP(CJeditinitDlg)	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)	MESSAGE_HANDLER(WM_SYSCOMMAND, OnSysCommand)	COMMAND_ID_HANDLER(IDOK, OnOK)	COMMAND_ID_HANDLER(IDCANCEL, OnCancel)	COMMAND_ID_HANDLER(IDC_BUTTON_JAVA_EXEC, OnButtonJavaExec)	COMMAND_ID_HANDLER(IDC_BUTTON_JEDIT_TARGET, OnButtonJEditTarget)	COMMAND_ID_HANDLER(IDC_BUTTON_JEDIT_WORKINGDIR, OnButtonJEditWorkingDir)	COMMAND_HANDLER(IDC_EDIT_JAVA_EXEC, EN_CHANGE, OnEditTextChange)	COMMAND_HANDLER(IDC_COMBO_JAVA_OPTIONS, CBN_EDITCHANGE, OnEditTextChange)	COMMAND_HANDLER(IDC_COMBO_JAVA_OPTIONS, CBN_SELCHANGE, OnEditTextChange)	COMMAND_HANDLER(IDC_EDIT_JEDIT_TARGET, EN_CHANGE, OnEditTextChange)	COMMAND_HANDLER(IDC_EDIT_JEDIT_OPTIONS, EN_CHANGE, OnEditTextChange)	COMMAND_HANDLER(IDC_EDIT_JEDIT_WORKING_DIR, EN_CHANGE, OnEditTextChange)END_MSG_MAP()// Handler prototypes://  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);//  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);//  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)	{		InitData();		CenterWindow();		m_bIsExchanging = TRUE;		::SetWindowText(m_hwnds[JavaExec], (LPCTSTR)m_strings[JavaExec]);		SetBatchElements(IsBatchFile());		::SetWindowText(m_hwnds[JEditWorkingDir], (LPCTSTR)m_strings[JEditWorkingDir]);		MakeCmdLine();//		DoDataExchange(TRUE);		m_bIsExchanging = FALSE;		return 1;  // Let the system set the focus	}	LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)	{		if(wParam == IDM_ABOUTBOX)		{			CSimpleDialog<IDD_ABOUTBOX, TRUE> dlg;			dlg.DoModal();		}		else bHandled = FALSE;		return 0;	}	LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)	{		if(m_bIsDirty = FALSE)			EndDialog(wID);		for( int i = 0; i < 5; ++i)		{			CStringBuf<> p(m_strings[i]);			::GetWindowText(m_hwnds[i], p, p.size());		}//		DoDataExchange(FALSE);		if(ValidateData())		{			CString strMsg((LPCTSTR)IDS_MSG_RESTART);			::MessageBox(m_hWnd, strMsg, _T("jEditInit"), MB_ICONINFORMATION);			DoRegistryExchange(FALSE);			EndDialog(wID);		}		return 0;	}	LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)	{		EndDialog(wID);		return 0;	}	LRESULT OnButtonJavaExec(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)	{		m_ofn.lpstrFilter = _T("Executable file (*.exe)\0*.exe\0");		m_ofn.lpstrTitle = _T("Set location of Java executable");		if(GetOpenFileName(&m_ofn))		{			CString& strJE = m_strings[JavaExec];			strJE = CString(m_szFileName);			if(strJE.Find(_T(' ')) && strJE.GetAt(0) != _T('\"'))				strJE = _T("\"") + strJE + _T("\"");			::SetWindowText(m_hwnds[JavaExec], strJE);			MakeCmdLine();		}		ZeroMemory(m_szFileName, sizeof(m_szFileName));		return 0;	}	LRESULT OnButtonJEditTarget(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)	{		m_ofn.lpstrFilter = _T("jEdit Java archive file (jedit.jar)\0jedit.jar\0");		m_ofn.lpstrTitle = _T("Set location of jEdit target");		if(GetOpenFileName(&m_ofn))		{			CString& strJET = m_strings[JEditTarget];			strJET = CString(m_szFileName);			if(strJET.Find(_T(' ')) && strJET.GetAt(0) != _T('\"'))				strJET = _T("\"") + strJET + _T("\"");			::SetWindowText(m_hwnds[JEditTarget], strJET);			MakeCmdLine();		}		ZeroMemory(m_szFileName, sizeof(m_szFileName));		return 0;	}	LRESULT OnButtonJEditWorkingDir(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)	{		LPITEMIDLIST pIDList = SHBrowseForFolder(&m_brinfo);		if(pIDList != 0)		{			SHGetPathFromIDList(pIDList, CStringBuf<>(m_strings[JEditWorkingDir]));			::SetWindowText(m_hwnds[JEditWorkingDir], m_strings[JEditWorkingDir]);			IMalloc *piMalloc = 0;			if(SUCCEEDED(SHGetMalloc(&piMalloc)))			{				piMalloc->Free(pIDList);				piMalloc->Release();			}		}		return 0;	}	LRESULT OnEditTextChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)	{		if(m_bIsExchanging) return 0;		m_bIsDirty = TRUE;		CStringBuf<> strPtr(m_strings[wID - IDC_EDIT_JAVA_EXEC]);		if(wID == IDC_COMBO_JAVA_OPTIONS && wNotifyCode == CBN_SELCHANGE)		{			int nIndex = SendMessage(hWndCtl, CB_GETCURSEL, 0, 0);			if(nIndex != CB_ERR)				nIndex = SendMessage(hWndCtl, CB_GETLBTEXT,					nIndex, (LPARAM)(LPCTSTR)strPtr);		}		else		{			::GetWindowText(hWndCtl, strPtr, MAX_PATH);		}		// reformatting other elements?		if(wID == IDC_EDIT_JAVA_EXEC)			SetBatchElements(IsBatchFile());		else if(wID == IDC_COMBO_JAVA_OPTIONS)			SetJarElements(IsJarFile());		MakeCmdLine();		return 0;	}	void InitData()	{		DoRegistryExchange(TRUE);		ZeroMemory(m_szFileName, sizeof(m_szFileName));		ZeroMemory(&m_ofn, sizeof(OPENFILENAME));		OSVERSIONINFO os;		os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);		GetVersionEx(&os);		// init OPENFILENAME structure		m_ofn.lStructSize 		= os.dwMajorVersion  == 5 ?									sizeof(OPENFILENAME) :									OPENFILENAME_SIZE_VERSION_400;		m_ofn.hwndOwner 		= m_hWnd;		m_ofn.hInstance 		= _Module.GetModuleInstance();//		m_ofn.lpstrFilter 		= NULL;//		m_ofn.lpstrCustomFilter = NULL;//		m_ofn.nMaxCustFilter	= 0;//		m_ofn.nFilterIndex		= 0;		m_ofn.lpstrFile			= m_szFileName;		m_ofn.nMaxFile          = sizeof(m_szFileName);//		m_ofn.lpstrFileTitle    = NULL;//		m_ofn.nMaxFileTitle     = 0;//		m_ofn.lpstrInitialDir   = NULL;//		m_ofn.lpstrTitle        = 0;//		m_ofn.nFileOffset       = 0;//		m_ofn.nFileExtension    = 0;//		m_ofn.lpstrDefExt       = NULL;//		m_ofn.lCustData         = NULL;		m_ofn.lpfnHook 		    = OFNHookProc;//		m_ofn.lpTemplateName    = 0;		m_ofn.Flags             = OFN_EXPLORER | OFN_ENABLEHOOK |								  OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;		m_brinfo.hwndOwner = m_hWnd;		m_brinfo.pidlRoot = 0;		m_brinfo.pszDisplayName = m_szFileName;		m_brinfo.lpszTitle = _T("Set working directory for jEdit");		m_brinfo.ulFlags = BIF_RETURNONLYFSDIRS;		m_brinfo.lpfn = NULL;		m_brinfo.lParam = 0;		m_brinfo.iImage = 0;		// system menu		HMENU hSysMenu = ::GetSystemMenu(m_hWnd, FALSE);		if (hSysMenu != NULL)		{			CString strAboutMenu;			strAboutMenu.LoadString(IDS_ABOUTBOX);			if (!strAboutMenu.IsEmpty())			{				AppendMenu(hSysMenu, MF_SEPARATOR, 0, 0);				AppendMenu(hSysMenu, MF_STRING, IDM_ABOUTBOX, (LPCTSTR)strAboutMenu);			}		}		m_hIcon = LoadIcon(m_ofn.hInstance, MAKEINTRESOURCE(IDI_JEDIT));		SetIcon(m_hIcon, TRUE);			// Set big icon		SetIcon(m_hIcon, FALSE);		// Set small icon		for(UINT i = 0, nID = IDC_EDIT_JAVA_EXEC; i < 6; ++i, ++nID)			m_hwnds[i] = GetDlgItem(nID);		CString strComboText;		for(UINT nComboID = IDS_COMBO_BEGIN; nComboID < IDS_COMBO_END; ++nComboID)		{			strComboText.LoadString(nComboID);			::SendMessage(m_hwnds[JavaOptions], CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)strComboText);		}	}//	BOOL DoDataExchange(BOOL bSendToDialog);	BOOL ValidateData();	BOOL DoRegistryExchange(BOOL bSendToDialog);	BOOL IsJarFile();	BOOL IsBatchFile();	void SetJarElements(BOOL bCheck);	void SetBatchElements(BOOL bCheck);	void MakeCmdLine();	BOOL MakeServerFilePath(CString& strFileName);	static TCHAR* trimcpy(TCHAR* pDest, const TCHAR* pSource);	static UINT CALLBACK OFNHookProc(HWND hdlg,       // handle to child dialog box						  UINT uiMsg,      // message identifier						  WPARAM wParam,   // message parameter						  LPARAM lParam);  // message parameter	void SetControlReadOnly(int nIndex, BOOL bCheck);};#endif //__jeditinitDLG_H_

⌨️ 快捷键说明

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