Ejemplo n.º 1
0
void COption::Apply()
{
	// Reflect changes
	CSusie susie;
	susie.Apply();

	// Save ini
	m_option = m_option_tmp;
	SaveIni();

	m_pListView->SetBkColor();
	m_pListView->SetTextColor();
	m_pListView->Update();

	m_pToolBar->SetCheckSearch();
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
		// read an INI.  If file doesn't exist, that's OK.
		INIFile ini = LoadIni("test.ini");
		if(ini.size())
		{
			// Note that existing INIs will be added to, though if any of the keys
			// listed below already exist, this program will modify them.
			cout << "About to modify test.ini, which presently contains:\n";
			DumpIni(ini);
		}
	   
		cout << "\nLoading INI with the following information, plus comments\n\n";
		cout <<"[Favorites]\ncolor=blue\nfood=pizza\nbeer=homebrew\n\n";
		cout << "[Computing]\nOperating System=Linux\nToolkit=FLTK\nComment=Now isn't this fun?\n\n";

		PutIniSetting(ini, "", "; This is a comment about the whole INI file");
		PutIniSetting(ini, "Favorites", "; This is a list of favorites");
		PutIniSetting(ini, "Favorites", "color", "blue");
		PutIniSetting(ini, "Favorites", "food", "pizza");
		PutIniSetting(ini, "Favorites", "beer", "homebrew");
		PutIniSetting(ini, "Computing", "; Information about computing preferences");
		PutIniSetting(ini, "Computing", "Operating System", "Linux");
		PutIniSetting(ini, "Computing", "Toolkit", "FLTK");
		PutIniSetting(ini, "Computing", "Comment", "This will be replaced in next line.");
		PutIniSetting(ini, "Computing", "Comment", "Now isn't this fun?");

		cout << "\nINI Ready, saving to disk\n\n";
		SaveIni(ini, "test.ini");

		cout << "Loading from disk to verify.\n\n";
		INIFile ini2 = LoadIni("test.ini");
		
		cout << "Contents of ini just read\n\n";
		DumpIni(ini2);
		
		cout << "\nChecking single value for section Computing, key Comment:\n";
		cout << "Value is: " << GetIniSetting(ini2, "Computing", "Comment") << std::endl;
		
		cout << "\nChecking unset value for section Computing, \nkey Distribution, with default of \"RedHat\"\n";
		cout << "Value is: " << GetIniSetting(ini2, "Computing", "Distribution",  "RedHat") << "\n\nDone\n\n";
		return (0);
}
Ejemplo n.º 3
0
// Window Procedure
LRESULT CWinMain::WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp)
{
	static CMainToolBar main_tool_bar;
	static CSearchToolBar search_tool_bar;
	static CMainListView list_view;
	static CStatusBar status_bar;
	static CExtractData extract;
	static COption option;
	static CVersionInfo version;
	static CLastDir last_dir;
	static TCHAR readme_file_name[MAX_PATH];
	static TCHAR history_file_name[MAX_PATH];
	static TCHAR state_file_name[MAX_PATH];
	INITCOMMONCONTROLSEX ic;

	switch (msg)
	{
	case WM_CREATE:
		{
			// Allow D&D (Drag & Drop)
			DragAcceptFiles(window, TRUE);

			option.Init(search_tool_bar, list_view);

			// Initialization of the common installation configuration
			ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
			ic.dwICC = ICC_WIN95_CLASSES;
			InitCommonControlsEx(&ic);

			// Create main toolbar
			main_tool_bar.Create(window);
			search_tool_bar.Create(window);

			// Create list view
			list_view.Create(window, option.GetOpt());

			// Create status bar
			status_bar.Create(window, option.GetOpt(), list_view);

			// Get full path
			TCHAR ModulePath[MAX_PATH];
			GetModuleFileName(nullptr, ModulePath, MAX_PATH);
			PathRemoveFileSpec(ModulePath);

			// Retrieves full path of the location of Readme.txt
			lstrcpy(readme_file_name, ModulePath);
			PathAppend(readme_file_name, _T("Readme.txt"));

			// Retrieves full path of the location of History.txt
			lstrcpy(history_file_name, ModulePath);
			PathAppend(history_file_name, _T("History.txt"));

			// Retrieves full path of the location of State.txt
			lstrcpy(state_file_name, ModulePath);
			PathAppend(state_file_name, _T("State.txt"));

			extract.Init(window, option.GetOpt(), list_view);
			break;
		}

	case WM_DROPFILES:
		extract.OpenDrop(wp);
		main_tool_bar.AddOpenHistory(extract.GetArcList());
		status_bar.SetCount();
		break;

	case WM_COMMAND:
		switch (LOWORD(wp))
		{
		case IDM_OPEN: // Open a file to load
			extract.Open(last_dir.GetOpen());
			main_tool_bar.AddOpenHistory(extract.GetArcList());
			status_bar.SetCount();
			last_dir.SaveIni();
			break;

		case IDM_CLOSE: // Close the opened file
			extract.Close();
			status_bar.SetCount();
			break;

		// Open a file from history
		case ID_TOOLBAR_OPEN_HISTORY:
		case ID_TOOLBAR_OPEN_HISTORY+1:
		case ID_TOOLBAR_OPEN_HISTORY+2:
		case ID_TOOLBAR_OPEN_HISTORY+3:
		case ID_TOOLBAR_OPEN_HISTORY+4:
		case ID_TOOLBAR_OPEN_HISTORY+5:
		case ID_TOOLBAR_OPEN_HISTORY+6:
		case ID_TOOLBAR_OPEN_HISTORY+7:
		case ID_TOOLBAR_OPEN_HISTORY+8:
		case ID_TOOLBAR_OPEN_HISTORY+9:
			extract.OpenHistory(main_tool_bar.GetHistory()[LOWORD(wp)-ID_TOOLBAR_OPEN_HISTORY]);
			main_tool_bar.AddOpenHistory(extract.GetArcList());
			status_bar.SetCount();
			break;

		// Search button configuration file
		case IDM_AHX:
		case IDM_BMP:
		case IDM_JPG:
		case IDM_MID:
		case IDM_MPG:
		case IDM_OGG:
		case IDM_PNG:
		case IDM_WAV:
		case IDM_WMV:
			search_tool_bar.SetSearch(LOWORD(wp));
			break;

		// Quick settings
		case IDM_QUICKSET_STD_SEARCHOGG:
		case IDM_QUICKSET_EXTRACT_CREATEFOLDER:
		case IDM_QUICKSET_EXTRACT_FIXOGG:
		case IDM_QUICKSET_EXTRACT_EASYDECRYPT:
		case IDM_QUICKSET_EXTRACT_DSTPNG:
		case IDM_QUICKSET_EXTRACT_ALPHABLEND:
		case IDM_QUICKSET_SUSIE_USE:
		case IDM_QUICKSET_SUSIE_FIRST:
			SetQuickMenuItem(LOWORD(wp));
			break;

		case IDM_EXIT: // Exit
			SendMessage(window, WM_CLOSE, 0, 0);
			break;

		case IDM_EXTRACT: // Extract the selected range
			if (list_view.GetCountSel() > 0)
			{
				extract.SaveSel(last_dir.GetSave(), true);
			}
			last_dir.SaveIni();
			break;

		case IDM_EXTRACTALL: // Extract all
			if( list_view.GetCount() > 0 )
			{
				extract.SaveAll(last_dir.GetSave(), true);
			}
			last_dir.SaveIni();
			break;

		case IDM_EXTRACT_NOTCONVERT: // Extracts the selection without converting it
			if (list_view.GetCountSel() > 0)
			{
				extract.SaveSel(last_dir.GetSave(), false);
			}
			last_dir.SaveIni();
			break;

		case IDM_EXTRACTALL_NOTCONVERT: // Extracts all without conversion
			if (list_view.GetCount() > 0)
			{
				extract.SaveAll(last_dir.GetSave(), false);
			}
			last_dir.SaveIni();
			break;

		case IDM_SELECTALL: // Select all
			list_view.SetItemSelAll(LVIS_SELECTED);
			break;

		case IDM_OPTION: // Options
			option.DoModal(window);
			break;

		case IDM_README: // Open Readme.txt
			ShellExecute(nullptr, _T("open"), readme_file_name, nullptr, nullptr, SW_SHOWNORMAL);
			break;

		case IDM_HISTORY: // Open History.txt
			ShellExecute(nullptr, _T("open"), history_file_name, nullptr, nullptr, SW_SHOWNORMAL);
			break;

		case IDM_STATE: // Open State.txt
			ShellExecute(nullptr, _T("open"), state_file_name, nullptr, nullptr, SW_SHOWNORMAL);
			break;

		case IDM_VERSION: // Version info
			version.DoModal(window);
			break;
		}
		break;

	// Right-click Menu
	case WM_CONTEXTMENU:
		CreateMenu(lp);
		break;

	case WM_MOUSEWHEEL:
		{
			POINT pos;
			GetCursorPos(&pos);
			HWND point_window = WindowFromPoint(pos);
			if (point_window == list_view.GetHandle())
				SendMessage(point_window, WM_MOUSEWHEEL, wp, lp);
			break;
		}

	case WM_NOTIFY:
		{
			// Toolbar
			if (wp == ID_TOOLBAR)
			{
				LPNMTOOLBAR nm = reinterpret_cast<LPNMTOOLBAR>(lp);
				switch (nm->hdr.code)
				{
					// File History
					case TBN_DROPDOWN:
						main_tool_bar.CreateMenuHistory(nm->iItem);
						break;
				}
			}

			// List view
			if (wp == idsMainList)
			{
				LPNMLISTVIEW nm = reinterpret_cast<LPNMLISTVIEW>(lp);
				switch (nm->hdr.code)
				{
				// Sort
				case LVN_COLUMNCLICK:
					list_view.Sort(nm->iSubItem);
					break;
				// Show Tooltips
				case LVN_GETINFOTIP:
					list_view.ShowTip(reinterpret_cast<LPNMLVGETINFOTIP>(lp));
					break;
				// View
				case LVN_GETDISPINFO:
					list_view.Show(reinterpret_cast<NMLVDISPINFO*>(lp));
					break;
				// D&D (Drag & Drop)
				case LVN_BEGINDRAG:
				{
					//extract.SaveDrop();
					LRESULT result;
					list_view.OnBeginDrag(reinterpret_cast<NMHDR*>(lp), &result);
					break;
				}
				// Playback / Viewing by double-clicking
				case NM_DBLCLK:
					if (list_view.GetCountSel() > 0)
					{
						extract.DecodeTmp();
						extract.OpenRelate();
					}
					break;
				}
			}
			break;
		}

	case WM_SIZE:
		main_tool_bar.SetWindowPos(0, 0, 100, 26);
		search_tool_bar.SetWindowPos(100, 0, LOWORD(lp), 26);
		list_view.SetWindowPos(0, 28, LOWORD(lp), HIWORD(lp) - 48);
		status_bar.SetWindowPos(LOWORD(lp));
		break;

	case WM_CLOSE:
		// Save
		SaveIni();
		list_view.SaveIni();
		// Clean up
		extract.Close();
		DestroyWindow(window);
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;

	default:
		return DefWindowProc(window, msg, wp, lp);
	}

	return 0;
}
Ejemplo n.º 4
0
// ---------------------------------------------------------------------------
void __fastcall TForm1::btnApplyClick(TObject *Sender) {
	SaveIni();
	LoadIni();
	InitMenu();
}