Esempio n. 1
0
void DlgConfigure::onWMInitDialog()
{
	TranslateDialogDefault(m_hWnd);
	utils::centerDialog(m_hWnd);
	SendMessage(m_hWnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_HISTORYSTATS))));
	EnableWindow(GetDlgItem(m_hWnd, IDC_APPLY), FALSE);

	m_hOptWnd = CreateDialogA(g_hInst, MAKEINTRESOURCEA(IDD_OPTIONS), m_hWnd, DlgOption::staticDlgProc);

	ShowWindow(m_hOptWnd, SW_SHOW);
	SetFocus(m_hOptWnd);
}
	void SetDialogParameters ( bool visible, float progress, const char* text )
	{
		if ( text && text != TextString )
			TextString = text;
		else
			text = nullptr;
		float actualProgress = std::max ( 0.0f, std::min ( 1.0f, progress ) );

		if ( Dialog == NULL )
		{
			Dialog      = CreateDialogA ( GetModuleHandle ( NULL ), MAKEINTRESOURCE(IDD_PROGRESS_DIALOG), MainWindow, DlgProc );
			ProgressBar = GetDlgItem ( Dialog, IDC_PROGRESS_DIALOG_PROGRESS );
			Text        = GetDlgItem ( Dialog, IDC_PROGRESS_DIALOG_TEXT );
			assert ( ProgressBar && Text );

			SendMessage ( ProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 65535) );
		}

		if ( visible )
			ShowWindow ( Dialog, SW_SHOW );
		else
			ShowWindow ( Dialog, SW_HIDE );

		WPARAM progressInt = (WPARAM)(actualProgress * 65535);
		SendMessage ( ProgressBar, PBM_SETPOS, progressInt, 0 ); 
		if ( text )
			SetWindowTextA ( Text, text );

		MSG Msg;
		while ( PeekMessage ( &Msg, NULL, 0, 0, PM_REMOVE ) )
		{
			if(!IsDialogMessage(ProgressBar, &Msg))
			{
				TranslateMessage(&Msg);
				DispatchMessage(&Msg);
			}
		}
	}