Ejemplo n.º 1
0
void AppSaveSettings()
{
	// If multiple SaveSettings messages are requested, we want to ignore most of them.
	// Saving settings once when the GUI is idle should be fine. :)

	static u32 isPosted = false;

	if( !wxThread::IsMain() )
	{
		if( !AtomicExchange(isPosted, true) )
			wxGetApp().PostIdleMethod( AppSaveSettings );

		return;
	}

	//Console.WriteLn("Saving ini files...");

	SaveUiSettings();
	SaveVmSettings();
	SaveRegSettings(); // save register because of PluginsFolder change

	AtomicExchange( isPosted, false );
}
Ejemplo n.º 2
0
//
//	Entry-point for text-editor application
//
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int iShowCmd)
{
	MSG			msg;
	HACCEL		hAccel;
	TCHAR		**argv;
	int			argc;
	//TCHAR		*pszCmdlineFile = 0;
	TCHAR		arg[MAX_PATH];

	//
	// get the first commandline argument
	//
	TCHAR *pszCmdline = GetArg(GetCommandLineW(), arg, MAX_PATH);
	argv = GetArgvCommandLine(&argc);

	// check if we have any options
	if(pszCmdline && *pszCmdline == '-')
	{
		pszCmdline = GetArg(pszCmdline, arg, MAX_PATH);

		// do the user-account-control thing
		if(lstrcmpi(arg, _T("-uac")) == 0)
		{
			//return 0;
		}
		// image-file-execute-options
		else if(lstrcmpi(arg, _T("-ifeo")) == 0)
		{
			// skip notepad.exe
			pszCmdline = GetArg(pszCmdline, arg, MAX_PATH);
		}
		// unrecognised option
		else
		{
		}
	}


	// has a prior instance elevated us to admin in order to 
	// modify some system-wide settings in the registry?
	if(argv && argc == 4 && lstrcmpi(argv[1], _T("-uac")) == 0)
	{
		g_fAddToExplorer	= _ttoi(argv[2]);
		g_fReplaceNotepad	= _ttoi(argv[3]);

		if(SetExplorerContextMenu(g_fAddToExplorer) &&
			SetImageFileExecutionOptions(g_fReplaceNotepad))
		{
			SaveRegSysSettings();
			return 0;
		}
		else
		{
			return ERROR_ACCESS_DENIED;
		}
	}

	// default to the built-in resources
	g_hResourceModule = hInst;

	OleInitialize(0);

	// initialize window classes
	InitMainWnd();
	InitTextView();

	LoadRegSettings();

	// create the main window!
	g_hwndMain = CreateMainWnd();

	// open file specified on commmand line
	if(pszCmdline && *pszCmdline)
	{
		// check to see if it's a quoted filename
		if(*pszCmdline == '\"')
		{
			GetArg(pszCmdline, arg, MAX_PATH);
			pszCmdline = arg;
		}

		NeatpadOpenFile(g_hwndMain, pszCmdline);
		LoadFileData(pszCmdline, g_hwndMain);
	}
	// automatically create new document if none specified
	else
	{
		PostMessage(g_hwndMain, WM_COMMAND, IDM_FILE_NEW, 0);
	}

	ApplyRegSettings();
	ShowWindow(g_hwndMain, iShowCmd);

	//
	// load keyboard accelerator table
	//
	hAccel = LoadAccelerators(g_hResourceModule, MAKEINTRESOURCE(IDR_ACCELERATOR1));

	
	//
	// message-loop
	//
	while(GetMessage(&msg, NULL, 0, 0) > 0)
	{
		if(!TranslateAccelerator(g_hwndMain, hAccel, &msg))
		{
			if((!IsWindow(g_hwndSearchDlg) || !IsDialogMessage(g_hwndSearchDlg, &msg)))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
	}

	if(g_fSaveOnExit)
		SaveRegSettings();

	OleUninitialize();
	ExitProcess(0);
	return 0;
}
Ejemplo n.º 3
0
//
//	WM_COMMAND message handler for main window
//
UINT CommandHandler(HWND hwnd, UINT nCtrlId, UINT nCtrlCode, HWND hwndFrom)
{
	RECT rect;

	switch(nCtrlId)
	{
	case IDM_FILE_NEW:
		
		// reset to an empty file
		SetWindowFileName(hwnd, _T("Untitled"), FALSE);
		TextView_Clear(g_hwndTextView);

		g_szFileTitle[0] = '\0';
		g_fFileChanged   = FALSE;
		return 0;
		
	case IDM_FILE_OPEN:
		
		// get a filename to open
		if(ShowOpenFileDlg(hwnd, g_szFileName, g_szFileTitle))
		{
			DoOpenFile(hwnd, g_szFileName, g_szFileTitle);
		}
		
		return 0;

	case IDM_FILE_SAVE:
		MessageBox(hwnd, _T("Not implemented"), APP_TITLE, MB_ICONINFORMATION);
		return 0;

	case IDM_FILE_SAVEAS:

		// does nothing yet
		if(ShowSaveFileDlg(hwnd, g_szFileName, g_szFileTitle))
		{
			MessageBox(hwnd, _T("Not implemented"), APP_TITLE, MB_ICONINFORMATION);
		}

		return 0;
		
	case IDM_FILE_PRINT:
		
		DeleteDC(
			ShowPrintDlg(hwnd)
			);
		
		return 0;

	case IDM_FILE_EXIT:
		PostMessage(hwnd, WM_CLOSE, 0, 0);
		return 0;

	case IDM_EDIT_UNDO:	case WM_UNDO:
		SendMessage(g_hwndTextView, WM_UNDO, 0, 0);
		return 0;
		
	case IDM_EDIT_REDO:
		SendMessage(g_hwndTextView, TXM_REDO, 0, 0);
		return 0;
		
	case IDM_EDIT_COPY: case WM_COPY:	
		SendMessage(g_hwndTextView, WM_COPY, 0, 0);
		return 0;
		
	case IDM_EDIT_CUT: case WM_CUT:
		SendMessage(g_hwndTextView, WM_CUT, 0, 0);
		return 0;
		
	case IDM_EDIT_PASTE: case WM_PASTE:
		SendMessage(g_hwndTextView, WM_PASTE, 0, 0);
		return 0;
			
	case IDM_EDIT_DELETE: case WM_CLEAR:
		SendMessage(g_hwndTextView, WM_CLEAR, 0, 0);
		return 0;

	case IDM_EDIT_FIND:
		ShowFindDlg(hwnd, FIND_PAGE);
		return 0;
		
	case IDM_EDIT_REPLACE:
		ShowFindDlg(hwnd, REPLACE_PAGE);
		return 0;

	case IDM_EDIT_GOTO:
		ShowFindDlg(hwnd, GOTO_PAGE);
		return 0;


	case IDM_EDIT_SELECTALL:
		TextView_SelectAll(g_hwndTextView);
		return 0;
		
	case IDM_VIEW_OPTIONS:
		ShowOptions(hwnd);
		return 0;
		
	case IDM_VIEW_LINENUMBERS:
		g_fLineNumbers = !g_fLineNumbers;
		TextView_SetStyleBool(g_hwndTextView, TXS_LINENUMBERS, g_fLineNumbers);
		return 0;
		
	case IDM_VIEW_LONGLINES:
		g_fLongLines = !g_fLongLines;
		TextView_SetStyleBool(g_hwndTextView, TXS_LONGLINES, g_fLongLines);
		return 0;
		
	case IDM_VIEW_STATUSBAR:
		g_fShowStatusbar = !g_fShowStatusbar;
		ShowWindow(g_hwndStatusbar, SW_HIDE);
		GetClientRect(hwnd, &rect);
		PostMessage(hwnd, WM_SIZE, 0, MAKEWPARAM(rect.right, rect.bottom));
		return 0;
		
	case IDM_VIEW_SAVEEXIT:
		g_fSaveOnExit = !g_fSaveOnExit;
		return 0;
		
	case IDM_VIEW_SAVENOW:
		SaveRegSettings();
		return 0;
		
	case IDM_HELP_ABOUT:
		ShowAboutDlg(hwnd);
		return 0;

	default:
		return 0;
	}
}