示例#1
0
void threaded_process_v2_t::resize()
{
	t_size height = 11 + 11;
	if (m_flags & flag_show_text)
		height += m_titlefont_height + 7;
	if (1)
		height += 15;
	if (m_flags & flag_show_button)
		height += m_textfont_height + 10 + 11 + 11;//23;
	{
		insync(m_sync);
		if (m_detail_entries.get_count())
			height += m_textfont_height*m_detail_entries.get_count() + 5;
	}
	RECT rc = { 0, 0, 450, height };
	AdjustWindowRectEx(&rc, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_CAPTION | WS_SYSMENU, false, NULL);
	int cx = progress_width + 11 * 2 + 11 * 2 + RECT_CX(rc) - 450;
	int cy = RECT_CY(rc);
	RECT rc_current = { 0 };
	GetWindowRect(get_wnd(), &rc_current);
	if (RECT_CX(rc_current) != cx || RECT_CY(rc_current) != cy)
	{
		m_window_cx = cx;
		m_window_cy = cy;
		//SendMessage(get_wnd(), WM_CANCELMODE, NULL, NULL);
		SetWindowPos(get_wnd(), NULL, NULL, NULL, cx, cy, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
	}
}
示例#2
0
void threaded_process_v2_t::run(HWND wnd)
{
	RECT rc1;
	GetClientRect(wnd, &rc1);
	MapWindowPoints(wnd, HWND_DESKTOP, (LPPOINT)(&rc1), 2);
	RECT rc = { 0, 0, 355 + 11 * 4, 11 * 2 + 15 };
	AdjustWindowRectEx(&rc, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_CAPTION | WS_SYSMENU, false, NULL);
	int cx = RECT_CX(rc);
	int cy = RECT_CY(rc);
	int x = (m_flags & flag_position_bottom_right) ? rc1.right - cx : rc1.left;
	int y = (m_flags & flag_position_bottom_right) ? rc1.bottom - cy : rc1.top;

	m_steps.set_size(m_range);
	m_steps.fill(1);

	m_window_cx = cx;
	m_window_cy = cy;

	create(wnd, 0, ui_helpers::window_position_t(x, y, cx, cy));
	create_thread();
}
示例#3
0
LRESULT threaded_process_v2_t::on_message(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
{
	switch (msg)
	{
		case WM_TIMER:
			if (wp == 1)
			{
				ShowWindow(wnd, SW_SHOWNORMAL);
				KillTimer(wnd, 1);
				return 0;
			}
			else if (wp == 667)
			{
				KillTimer(wnd, 667);
				m_timer_active = false;
				RedrawWindow(wnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
				return 0;
			}
			break;
		case WM_NCCREATE:
			modeless_dialog_manager::g_add(wnd);
			break;
		case WM_SYSCOLORCHANGE:
		case WM_THEMECHANGED:
			refresh_title_font();
			resize();
			break;
		case WM_CREATE:
		{
			if (m_flags & flag_show_button)
			{
				m_textfont = uCreateIconFont();
				m_textfont_height = uGetFontHeight(m_titlefont);
			}
			if (m_flags & flag_show_text)
				refresh_title_font();

			uSetWindowText(wnd, m_title);
			//t_size y_progress = 11;
			//if (m_flags & flag_show_text)
			//	y_progress+=5+uGetFontHeight(m_titlefont);
			//RECT rc;
			//GetClientRect(wnd, &rc);
			//m_wnd_caption = CreateWindowEx(0, WC_STATIC, L"STATIC", WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, wnd, (HMENU)1001, core_api::get_my_instance(), NULL);
			m_wnd_progress = CreateWindowEx(0, PROGRESS_CLASS, L"PROGRESS", WS_SYSMENU | WS_CHILD | WS_VISIBLE | ((m_flags & flag_progress_marquee) ? 0x08 : 0) | PBS_SMOOTH | WS_GROUP, 0, 0, 0, 0, wnd, (HMENU)1002, core_api::get_my_instance(), NULL);
			if (0 == (m_flags & flag_progress_marquee))
				SendMessage(m_wnd_progress, PBM_SETRANGE32, 0, progress_width/*m_range*/);
			else
				SendMessage(m_wnd_progress, WM_USER + 10, TRUE, 20);
			if (m_flags & flag_show_button)
			{
				m_wnd_button = CreateWindowEx(0, WC_BUTTON, L"Stop", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON | WS_GROUP, 0, 0, 0, 0, wnd, (HMENU)IDCANCEL, core_api::get_my_instance(), NULL);
				SendMessage(m_wnd_button, WM_SETFONT, (WPARAM)m_textfont.get(), MAKELPARAM(1, 0));
				//SetFocus(m_wnd_button);
			}
			else
			{
				HMENU menu = GetSystemMenu(wnd, FALSE);
				EnableMenuItem(menu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
			}
			resize();
			if (m_flags & flag_no_delay)
			{
				ShowWindow(wnd, SW_SHOWNORMAL);
			}
			else
			{
				SetTimer(wnd, 1, 300, NULL);
			}
			on_init();
		}
		return 0;
		case WM_SHOWWINDOW:
			if (wp == TRUE && lp == 0 && m_wnd_button)
				SetFocus(m_wnd_button);
			break;
		case WM_MOVING:
		{
			LPRECT lprc = (LPRECT)lp;
			lprc->right = lprc->left + m_window_cx;
			lprc->bottom = lprc->top + m_window_cy;
		}
		return TRUE;
		case DM_GETDEFID:
			if (m_flags & flag_show_button)
				return IDCANCEL | (DC_HASDEFID << 16);
			return 0;
		case WM_DESTROY:
			on_destroy_thread();
			m_textfont.release();
			m_titlefont.release();
			return 0;
		case WM_NCDESTROY:
			modeless_dialog_manager::g_remove(wnd);
			break;
		case WM_CLOSE:
			m_abort.abort();
			return 0;
		case WM_SETFOCUS:
			break;
		case WM_COMMAND:
			switch (wp)
			{
				case IDCANCEL:
					if (m_wnd_button)
						EnableWindow(m_wnd_button, FALSE);
					m_abort.abort();
					return 0;
			}
			break;
		case WM_PAINT:
		{
			pfc::string8 p_text;
			pfc::array_t<detail_entry> p_detail_entries;
			{
				insync(m_sync);
				p_text = m_text;
				p_detail_entries = m_detail_entries;
			}
			PAINTSTRUCT ps;
			HDC dc = BeginPaint(wnd, &ps);
			if (dc)
			{
				RECT rc_client, rc_button;
				GetClientRect(wnd, &rc_client);
				RECT rc_fill = rc_client;
				if (m_wnd_button)
				{
					GetWindowRect(m_wnd_button, &rc_button);
					rc_fill.bottom -= RECT_CY(rc_button) + 9;
					rc_fill.bottom -= 11;
				}

				FillRect(dc, &rc_fill, GetSysColorBrush(COLOR_WINDOW));

				if (m_wnd_button)
				{
					rc_fill.top = rc_fill.bottom;
					rc_fill.bottom += 1;
					FillRect(dc, &rc_fill, GetSysColorBrush(COLOR_3DLIGHT));
				}

				rc_fill.top = rc_fill.bottom;
				rc_fill.bottom = rc_client.bottom;
				if (rc_fill.top < rc_fill.bottom)
					FillRect(dc, &rc_fill, GetSysColorBrush(COLOR_3DFACE));

				if (m_flags & flag_show_text)
				{
					SetTextAlign(dc, TA_LEFT);
					SetBkMode(dc, TRANSPARENT);
					//SetTextColor(dc, m_titlecolour);
					RECT rc;
					GetClientRect(wnd, &rc);
					RECT rc2 = { 11 * 2, 11, RECT_CX(rc) - 11 * 2, m_titlefont_height + 11 };
					//FillRect(dc, &rc2, GetSysColorBrush(COLOR_BTNFACE));
					HFONT fnt_old = SelectFont(dc, m_titlefont);
					ui_helpers::text_out_colours_ellipsis(dc, p_text, p_text.get_length(), 0, 11, &rc2, false, false, m_titlecolour, ui_helpers::ALIGN_LEFT);
					//uExtTextOut(dc, 11*2, 11, ETO_CLIPPED, &rc2, m_text, m_text.get_length(), NULL);
					t_size detail_entry_count = 0;
					if (detail_entry_count = p_detail_entries.get_count())
					{
						RECT rc3 = rc2;
						rc3.top = rc2.bottom + 7;
						rc3.bottom = rc3.top + m_textfont_height;
						//SetTextColor(dc, GetSysColor(COLOR_BTNTEXT));
						SelectFont(dc, m_textfont);
						unsigned max_x = 0;
						for (t_size i = 0; i<detail_entry_count; i++)
						{
							unsigned last_x = 0;
							ui_helpers::text_out_colours_ellipsis(dc, p_detail_entries[i].m_label, p_detail_entries[i].m_label.get_length(), 0, rc3.top,
								&rc3, false, false, GetSysColor(COLOR_WINDOWTEXT), ui_helpers::ALIGN_LEFT, NULL, true, &last_x);
							max_x = max(last_x, max_x);
							rc3.top = rc3.bottom;
							rc3.bottom = rc3.top + m_textfont_height;
							//uExtTextOut(dc, 11*2, rc3.top, ETO_CLIPPED, &rc3, m_detail_entries[i].m_label, m_detail_entries[i].m_label.get_length(), NULL);
						}
						rc3.top = rc2.bottom + 7;
						rc3.bottom = rc3.top + m_textfont_height;
						rc3.left = max_x + 5;
						for (t_size i = 0; i<detail_entry_count; i++)
						{
							ui_helpers::text_out_colours_ellipsis(dc, p_detail_entries[i].m_value, p_detail_entries[i].m_value.get_length(), 0, rc3.top,
								&rc3, false, true, GetSysColor(COLOR_WINDOWTEXT), ui_helpers::ALIGN_LEFT);
							rc3.top = rc3.bottom;
							rc3.bottom = rc3.top + m_textfont_height;
						}
					}
					SelectFont(dc, fnt_old);
				}
				EndPaint(wnd, &ps);
			}
		}
		return 0;
		case MSG_REDRAW:
			resize();
			if (!m_timer_active)
			{
				LARGE_INTEGER current = { 0 }, freq = { 0 };
				QueryPerformanceCounter(&current);
				QueryPerformanceFrequency(&freq);
				t_uint64 tenth = 5;
				if (m_time_last_redraw.QuadPart)
				{
					tenth = (current.QuadPart - m_time_last_redraw.QuadPart) / (freq.QuadPart / 100);
				}
				if (tenth < 10)
				{
					SetTimer(get_wnd(), 667, 100 - t_uint32(tenth) * 10, NULL);
					m_timer_active = true;
				}
				else RedrawWindow(wnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
			}
			return 0;
		case MSG_UPDATE_PROGRESS:
			if (abs((int)(wp - SendMessage(m_wnd_progress, PBM_GETPOS, 0, 0))) > 0)
				SendMessage(m_wnd_progress, PBM_SETPOS, wp, 0);
			return 0;
		case MSG_END:
			destroy();
			on_exit();
			return 0;
	}
	return DefWindowProc(wnd, msg, wp, lp);
}
BOOL CALLBACK selection_properties_config_t::on_message(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
{
	switch (msg)
	{
	case WM_INITDIALOG:
	{
		pfc::vartoggle_t<bool> init(m_initialising, true);

		HWND wnd_fields = m_field_list.create_in_dialog_units(wnd, ui_helpers::window_position_t(21, 17, 226, 150));
		SetWindowPos(wnd_fields, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
		ShowWindow(wnd_fields, SW_SHOWNORMAL);

		HWND wnd_lv = GetDlgItem(wnd, IDC_INFOSECTIONS);
		ListView_SetExtendedListViewStyleEx(wnd_lv, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
		g_set_listview_window_explorer_theme(wnd_lv);

		RECT rc;
		GetClientRect(wnd_lv, &rc);
		ListView_InsertColumnText(wnd_lv, 0, L"", RECT_CX(rc));

		t_size i, count = tabsize(g_info_sections);
		for (i = 0; i < count; i++)
		{
			ListView_InsertItemText(wnd_lv, i, 0, g_info_sections[i].name);
			ListView_SetCheckState(wnd_lv, i, (m_info_sections_mask & (1 << g_info_sections[i].id)) ? TRUE : FALSE);
		}

		HWND wnd_combo = GetDlgItem(wnd, IDC_EDGESTYLE);
		ComboBox_AddString(wnd_combo, L"None");
		ComboBox_AddString(wnd_combo, L"Sunken");
		ComboBox_AddString(wnd_combo, L"Grey");
		ComboBox_SetCurSel(wnd_combo, m_edge_style);

		Button_SetCheck(GetDlgItem(wnd, IDC_SHOWCOLUMNS), m_show_columns ? BST_CHECKED : BST_UNCHECKED);
		Button_SetCheck(GetDlgItem(wnd, IDC_SHOWGROUPS), m_show_groups ? BST_CHECKED : BST_UNCHECKED);
	}
	break;
	case WM_DESTROY:
	{
		m_field_list.destroy();
	}
	break;
	case WM_ERASEBKGND:
		SetWindowLongPtr(wnd, DWL_MSGRESULT, TRUE);
		return TRUE;
	case WM_PAINT:
		ui_helpers::innerWMPaintModernBackground(wnd, GetDlgItem(wnd, IDOK));
		return TRUE;
	case WM_CTLCOLORSTATIC:
		SetBkColor((HDC)wp, GetSysColor(COLOR_WINDOW));
		SetTextColor((HDC)wp, GetSysColor(COLOR_WINDOWTEXT));
		return (BOOL)GetSysColorBrush(COLOR_WINDOW);
	case WM_NOTIFY:
	{
		LPNMHDR lpnm = (LPNMHDR)lp;
		switch (lpnm->idFrom)
		{
		case IDC_INFOSECTIONS:
			switch (lpnm->code)
			{
			case LVN_ITEMCHANGED:
			{
				LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lp;
				if (!m_initialising && lpnmlv->iItem < tabsize(g_info_sections) && (lpnmlv->uChanged & LVIF_STATE))
				{
					m_info_sections_mask = m_info_sections_mask & ~(1 << g_info_sections[lpnmlv->iItem].id);

					//if (((((UINT)(lpnmlv->uNewState & LVIS_STATEIMAGEMASK )) >> 12) -1))
					if (ListView_GetCheckState(lpnm->hwndFrom, lpnmlv->iItem))
						m_info_sections_mask = m_info_sections_mask | (1 << g_info_sections[lpnmlv->iItem].id);

				}
			}
			break;
			};
			break;
		};
	}
	break;
	case WM_COMMAND:
		switch (LOWORD(wp))
		{
		case IDOK:
			EndDialog(wnd, 1);
			break;
		case IDCANCEL:
			EndDialog(wnd, 0);
			break;
		case IDC_SHOWCOLUMNS:
			m_show_columns = Button_GetCheck((HWND)lp) != 0;
			break;
		case IDC_SHOWGROUPS:
			m_show_groups = Button_GetCheck((HWND)lp) != 0;
			break;
		case IDC_EDGESTYLE:
			switch (HIWORD(wp))
			{
			case CBN_SELCHANGE:
				m_edge_style = ComboBox_GetCurSel((HWND)lp);
				break;
			}
			break;
		case IDC_UP:
		{
			if (m_field_list.get_selection_count(2) == 1)
			{
				t_size index = 0, count = m_field_list.get_item_count();
				while (!m_field_list.get_item_selected(index) && index < count) index++;
				if (index && m_fields.get_count())
				{
					m_fields.swap_items(index, index - 1);

					pfc::list_t<t_list_view::t_item_insert> items;
					m_field_list.get_insert_items(index - 1, 2, items);
					m_field_list.replace_items(index - 1, items);
					m_field_list.set_item_selected_single(index - 1);
				}
			}
		}
		break;
		case IDC_DOWN:
		{
			if (m_field_list.get_selection_count(2) == 1)
			{
				t_size index = 0, count = m_field_list.get_item_count();
				while (!m_field_list.get_item_selected(index) && index < count) index++;
				if (index + 1 < count && index + 1 < m_fields.get_count())
				{
					m_fields.swap_items(index, index + 1);

					pfc::list_t<t_list_view::t_item_insert> items;
					m_field_list.get_insert_items(index, 2, items);
					m_field_list.replace_items(index, items);
					m_field_list.set_item_selected_single(index + 1);
				}
			}
		}
		break;
		case IDC_NEW:
		{
			field_t temp;
			temp.m_name_friendly = "<enter name here>";
			temp.m_name = "<ENTER FIELD HERE>";
			t_size index = m_fields.add_item(temp);

			pfc::list_t<t_list_view::t_item_insert> items;
			m_field_list.get_insert_items(index, 1, items);
			m_field_list.insert_items(index, 1, items.get_ptr());
			m_field_list.set_item_selected_single(index);
			SetFocus(m_field_list.get_wnd());
			m_field_list.activate_inline_editing();

		}
		break;
		case IDC_REMOVE:
		{
			if (m_field_list.get_selection_count(2) == 1)
			{
				bit_array_bittable mask(m_field_list.get_item_count());
				m_field_list.get_selection_state(mask);
				//bool b_found = false;
				t_size index = 0, count = m_field_list.get_item_count();
				while (index < count)
				{
					if (mask[index]) break;
					index++;
				}
				if (index < count && index < m_fields.get_count())
				{
					m_fields.remove_by_idx(index);
					m_field_list.remove_item(index);
					t_size new_count = m_field_list.get_item_count();
					if (new_count)
					{
						if (index < new_count)
							m_field_list.set_item_selected_single(index);
						else if (index)
							m_field_list.set_item_selected_single(index - 1);
					}
				}
			}
		}
		break;
		}
		break;
	}
	return FALSE;
}
示例#5
0
LRESULT dsp_preset_switcher::on_message( HWND parent_wnd , UINT msg , WPARAM wp , LPARAM lp )
{
	switch( msg )
	{
		case WM_CREATE:
		{
			if( wnd_my_combo_box != NULL )
			{
				console::printf( CONSOLE_HEADER "Error: wnd_my_combo_box != NULL" );
				return -1;
			}
			if( ui_hfont != NULL )
			{
				console::printf( CONSOLE_HEADER "Error: ui_hfont != NULL" );
				return -1;
			}

			// get columns UI font
			ui_hfont = uCreateIconFont();
			if( ui_hfont == NULL )
			{
				console::printf( CONSOLE_HEADER "uCreateIconFont() failed" );
				return -1;
			}

			wnd_my_combo_box = CreateWindowEx( 0 , WC_COMBOBOX , nullptr , ( CBS_DROPDOWNLIST | CBS_SORT | WS_CHILD | WS_VISIBLE | WS_TABSTOP ) , 0 , 0 , INIT_WIDTH , CW_USEDEFAULT , parent_wnd , NULL , core_api::get_my_instance() , nullptr );
			if( wnd_my_combo_box == NULL )
			{
				console::printf( CONSOLE_HEADER "CreateWindowEx() failed" );

				DeleteFont( ui_hfont );
				ui_hfont = NULL;
				return -1;
			}

			dsp_preset_switcher::PARENT_HWND_LIST.remove_item( parent_wnd );
			dsp_preset_switcher::PARENT_HWND_LIST.add_item( parent_wnd );

			// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
			// Sets the font that a control is to use when drawing text.
			uSendMessage( wnd_my_combo_box , WM_SETFONT , ( WPARAM ) ui_hfont , MAKELPARAM( 1 , 0 ) );

			// get metrics
			RECT rc;
			GetWindowRect( wnd_my_combo_box , &rc );
			HEIGHT = RECT_CY( rc );

			// get dsp names and add to combo box
			pfc::list_t<pfc::string8> l;
			initEntries( l );

			// set initial selection
			const bool ret = setEntry( CFG_IDX );
			if( !ret )
				CFG_IDX = -1;

			// determine width
			// MSDN Remarks: After an application has finished drawing with the new font object , it should always replace a new font object with the original font object.
			CONST HDC dc = GetDC( wnd_my_combo_box );
			CONST HFONT font_old = SelectFont( dc , ui_hfont );
			for( t_size i = 0 , imax = l.get_count(); i < imax ; ++i )
			{
				const char *str = l[i].get_ptr();
				const int cx = ui_helpers::get_text_width( dc , str , strlen( str ) );
				min_width = max( min_width , ( t_size ) cx );
			}
			SelectFont( dc , font_old );
			ReleaseDC( parent_wnd , dc );

			// get min width
			COMBOBOXINFO cbi = { 0 };
			cbi.cbSize = sizeof( cbi );
			GetComboBoxInfo( wnd_my_combo_box , &cbi );

			RECT rc_client;
			GetClientRect( wnd_my_combo_box , &rc_client );
			min_width += RECT_CX( rc_client ) - RECT_CX( cbi.rcItem );

			return 0;
		}

		case WM_DESTROY:
		{
			dsp_preset_switcher::PARENT_HWND_LIST.remove_item( GetParent( wnd_my_combo_box ) );
			DestroyWindow( wnd_my_combo_box );
			wnd_my_combo_box = NULL;

			DeleteFont( ui_hfont );
			ui_hfont = NULL;

			return 0;
		}

		case WM_GETMINMAXINFO:
		{
			CONST LPMINMAXINFO ptr = ( LPMINMAXINFO ) lp;
			ptr->ptMinTrackSize.x = min_width;

			ptr->ptMinTrackSize.y = HEIGHT;
			ptr->ptMaxTrackSize.y = HEIGHT;
			return 0;
		}

		case WM_WINDOWPOSCHANGED:
		{
			CONST LPWINDOWPOS ptr = ( LPWINDOWPOS ) lp;
			if( !( ptr->flags & SWP_NOSIZE ) )
			{
				SetWindowPos( wnd_my_combo_box , HWND_TOP , 0 , 0 , ptr->cx , HEIGHT , SWP_NOZORDER );
			}

			return 0;
		}

		case WM_COMMAND:
		{
			if( wp == ( CBN_SELCHANGE << 16 ) )
			{
				int idx;
				pfc::string8 text;
				bool ret = getSelection( idx , text );
				if( !ret )
					break;

				CFG_IDX = idx;
				ret = selDspName( idx , text.get_ptr() );
				if( !ret )
					syncSelection( -1 );
				return 0;
			}

			break;
		}

		case WM_USER_DSP_CORE_CHANGE:
		{
			if( skip_msg )
			{
				skip_msg = false;
				return 0;
			}

			// just rescan DSP name entries and remove the current selected one
			pfc::list_t<pfc::string8> d;
			initEntries( d );
			CFG_IDX = -1;
			return 0;
		}

		case WM_USER_SYNC_CHANGE:
		{
			if( wp == -1 )
			{
				pfc::list_t<pfc::string8> l;
				initEntries( l );
				return 0;
			}

			skip_msg = true;
			setEntry( wp );
			return 0;
		}

		default:
		{
			//console::printf( CONSOLE_HEADER "default case: %u" , msg );
			break;
		}
	}

	// Calls the default window procedure to provide default processing for any window messages that an application does not process. 
	// This function ensures that every message is processed.
	return uDefWindowProc( parent_wnd , msg , wp , lp );
}