Пример #1
0
	virtual HWND init(HookProc_t hook)
	{
		{
			OSVERSIONINFOEX osvi;
			memset(&osvi, 0, sizeof(osvi));
			osvi.dwOSVersionInfoSize = sizeof(osvi);
			if (GetVersionEx((LPOSVERSIONINFO)&osvi))
			{
				if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 && osvi.wServicePackMajor == 0)
				{
					pfc::string_formatter message;
					message << "Sorry, your operating system Windows XP ";
					if (!osvi.wServicePackMajor)
						message << "(no service pack installed)";
					else
						message << "Service Pack " << osvi.wServicePackMajor;
					message << " is not supported by Columns UI. Please upgrade to Service Pack 1 or newer and try again.\n\nOtherwise, uninstall the Columns UI component to return to the Default User Interface.",
						MessageBox(NULL, uT(message), _T("Columns UI - Unsupported operating system"), MB_OK | MB_ICONEXCLAMATION);
					return NULL;

				}
			}
		}
		//		performance_counter startup;

		if (main_window::config_get_is_first_run())
		{
			if (!cfg_layout.get_presets().get_count())
				cfg_layout.reset_presets();
		}

		main_window::g_hookproc = hook;


		WNDCLASS  wc;
		memset(&wc, 0, sizeof(wc));

		create_icon_handle();

		wc.lpfnWndProc = (WNDPROC)g_MainWindowProc;
		wc.style = CS_DBLCLKS;
		wc.hInstance = core_api::get_my_instance();
		wc.hIcon = static_api_ptr_t<ui_control>()->get_main_icon();//g_main_icon;
		wc.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
		wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
		wc.lpszClassName = main_window_class_name;

		ATOM cls = RegisterClass(&wc);

		RECT rc_work;
		SystemParametersInfo(SPI_GETWORKAREA, NULL, &rc_work, NULL);

		const unsigned cx = (rc_work.right - rc_work.left) * 80 / 100;
		const unsigned cy = (rc_work.bottom - rc_work.top) * 80 / 100;

		unsigned left = (rc_work.right - rc_work.left - cx) / 2;
		unsigned top = (rc_work.bottom - rc_work.top - cy) / 2;

		if (main_window::config_get_is_first_run())
		{
			cfg_plist_width = cx * 10 / 100;
		}
		else if (!g_colours_fonts_imported)
		{
			g_import_pv_colours_to_unified_global();
			g_import_fonts_to_unified();
		}

		g_colours_fonts_imported = true;

		g_main_window = CreateWindowEx(main_window::config_get_transparency_enabled() ? WS_EX_LAYERED : 0 /*WS_EX_TOOLWINDOW*/, main_window_class_name, _T("foobar2000"), WS_OVERLAPPED | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
			WS_THICKFRAME, left, top, cx, cy, 0, 0, core_api::get_my_instance(), NULL);

		main_window::on_transparency_enabled_change();

		bool rem_pos = remember_window_pos();

		if (rem_pos && !main_window::config_get_is_first_run())
		{
			SetWindowPlacement(g_main_window, &cfg_window_placement_columns.get_value());
			size_windows();
			ShowWindow(g_main_window, cfg_window_placement_columns.get_value().showCmd);

			if (g_icon_created && (cfg_window_placement_columns.get_value().showCmd == SW_SHOWMINIMIZED) && cfg_minimise_to_tray)
				ShowWindow(g_main_window, SW_HIDE);
		}
		else
		{
			size_windows();
			ShowWindow(g_main_window, SW_SHOWNORMAL);
		}

		if (g_rebar) ShowWindow(g_rebar, SW_SHOWNORMAL);
		if (g_status) ShowWindow(g_status, SW_SHOWNORMAL);
		if (g_status_pane.get_wnd()) ShowWindow(g_status_pane.get_wnd(), SW_SHOWNORMAL);
		g_layout_window.show_window();

		RedrawWindow(g_main_window, 0, 0, RDW_UPDATENOW | RDW_ALLCHILDREN);

		if (main_window::config_get_is_first_run())
			SendMessage(g_main_window, MSG_RUN_INITIAL_SETUP, NULL, NULL);

		main_window::config_set_is_first_run();

		return g_main_window;
	}
Пример #2
0
	static BOOL CALLBACK ConfigProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
	{

		switch (msg)
		{
		case WM_INITDIALOG:
		{
			refresh_me(wnd);
			initialised = true;
		}

		break;
		case WM_DESTROY:
		{
			initialised = false;
		}
		break;
		case WM_COMMAND:
			switch (wp)
			{


			case (EN_CHANGE << 16) | IDC_STRING:
				main_window::config_notification_icon_script.set(string_utf8_from_window((HWND)lp));
				break;

			case IDC_NOWPL:
			{
				cfg_np = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0);
			}
			break;
			case IDC_USE_CUSTOM_ICON:
			{
				cfg_custom_icon = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0);
				create_icon_handle(); create_systray_icon();
			}
			break;
			case IDC_BROWSE_ICON:
			{
				pfc::string8 path = cfg_tray_icon_path;
				if (uGetOpenFileName(wnd, "Icon Files (*.ico)|*.ico|All Files (*.*)|*.*", 0, "ico", "Choose Icon", NULL, path, FALSE))
				{
					cfg_tray_icon_path = path;
					if (cfg_custom_icon) { create_icon_handle(); create_systray_icon(); }
				}
			}
			break;


			case IDC_MINIMISE_TO_SYSTRAY:
			{
				cfg_minimise_to_tray = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0);
			}
			break;
			case IDC_SHOW_SYSTRAY:
			{
				cfg_show_systray = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0);
				//				EnableWindow(GetDlgItem(wnd, IDC_MINIMISE_TO_SYSTRAY), cfg_show_systray);

				if (g_main_window)
				{
					auto is_iconic = IsIconic(g_main_window) != 0;
					if (cfg_show_systray && !g_icon_created)
					{
						create_systray_icon();
					}
					else if (!cfg_show_systray && g_icon_created && (!is_iconic || !cfg_minimise_to_tray))
					{
						destroy_systray_icon();
						if (is_iconic)
							standard_commands::main_activate();
					}
					if (g_status) update_systray();
				}
			}
			break;
			case IDC_BALLOON:
			{
				cfg_balloon = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0);
			}
			break;
			}
		}
		return 0;
	}