Graphical User Interface@klopix
ResearchMFC

This part of the site is devoted to discuss some basic things about computer user interface, whether it is a desktop one or a web one.


Topics to cover


Apps to implement

 How to minimize amount of issues in new app:

Feb 12 2010
Vague issues

Let's consider a software developing company. Usually (at least in my case) there is a quality assurance group testing and checking if developers made any mistakes or offering some improvemets to apply in future, so called new features.

But I wanna talk about mistake kinda issues (bugs) that quality assurance arouses. And not all the different sorts of mistakes, but completely obscure ones and if developer gets such an issue, s/he has no idea what the hell to do about it. Because usually it says something like: «X does not do Y»

Okay. X does not do Y. So what? Is that bad? Is that good? What do you want? How exactly should X do Y? In times like this my first intention is to go kick somebody's ass and rip their head off.

But as it turns out, these obscure issues is a clear indication of bad user experience (there few times when QA member composes a bug issue on exactly correct app behaviour, but it happens no so often). I mean, the app doesn't quite satisfy its user who is a member of the QA team. And there is no way to fix the problem without major redesigning the entire mechanism so that it brings a better experience.

To conclude, I'd say that a vague issue is a clear indication of bad design. Don't blame QA, go ahead and figure out how to improve it dramatically so as it brings easiest convenient usage.

Dec 7 2009
Painting upon desktop device context

(1) Get desktop window: CWnd pWnd = GetDesktopWindow()

(2) Obtain device context: pWnd->GetWindowDC()

(3) How do I restore windows after paintings? (I tried to enumerate topmost windows and their children, but some pieces of those windows remain not updated) And how do I disable all those windows so that if I move mouse pointer over they don't show tooltips?

I should probably size my window to GetSystemMetrics(SM_CXSCREEN) horizontally and GetSystemMetrics(SM_CYSCREEN) vertically, and hide title, and get this window device context and draw upon it, not the desktop window DC. YO-HOOOOOOO! It works!

void Switch_Style()
{
	static BOOL fullscreen = FALSE;
	static CRect r_windowed;
	DWORD style = (WS_SYSMENU | WS_SIZEBOX | WS_BORDER | WS_CAPTION);
	
	CRect r;
	if (!fullscreen)
	{
		GetWindowRect(&r);
		r_windowed = r;
		r.right		= ::GetSystemMetrics(SM_CXSCREEN);
		r.left		= 0;
		r.bottom	= ::GetSystemMetrics(SM_CYSCREEN);
		r.top		= 0;

		SetWindowLong(GetSafeHwnd(), GWL_STYLE, style ^ GetWindowLong(GetSafeHwnd(), GWL_STYLE));
		//ModifyStyle(0, style);
	}
	else
	{
		r.right		= r_windowed.right;
		r.left		= r_windowed.left;
		r.bottom	= r_windowed.bottom;
		r.top		= r_windowed.top;
		ScreenToClient(&r);

		SetWindowLong(GetSafeHwnd(), GWL_STYLE, style | GetWindowLong(GetSafeHwnd(), GWL_STYLE));
		//ModifyStyle(style, 0);
	}

	MoveWindow(r.left, r.top, r.Width(), r.Height());	
	fullscreen = !fullscreen;
}


void Paint()
{
		CWnd* pDWnd = this; //GetDesktopWindow();
		CDC* pDC = pDWnd->GetWindowDC();
		double coeff = 0.05;
		CRect r;
		pDWnd->GetWindowRect(&r);
		pDWnd->ScreenToClient(&r);

		r.right += (-r.left);
		r.left -= r.left;
		r.bottom += (-r.top);
		r.top -= r.top;

		int h_off = (int) (r.Height() * coeff);
		int x1 = r.left; //0;
		int x2 = r.right; //GetSystemMetrics(SM_CXSCREEN);
		int y1 = r.top;//h_off;
		int y2 = r.bottom;// GetSystemMetrics(SM_CYSCREEN) - 2*h_off;
		
		BYTE color  = (BYTE) (255.0 * (double)counter / duration);
		COLORREF cr = ((COLORREF)(color << 16)) + ((COLORREF)(color << 8)) + ((COLORREF)color);

		pDC->FillSolidRect(x1, y1, x2-x1, h_off, (COLORREF) 0x00000000);
		pDC->FillSolidRect(x1, y1+h_off, x2-x1, y2-h_off-y1-h_off, cr);
		pDC->FillSolidRect(x1, y2-h_off, x2-x1, h_off, (COLORREF) 0x00000000);
}

Dec 5 2009
Drag&Drop: wrong type

How to indicate to an user that if files, being dragged over, are of a wrong type (say, if images're dragged over sound list)? How to change (+) cursor to (x) cursor?

Dec 4 2009
Drag and drop files

Two things about it in MFC.

(1) CYourDialog::OnInitDialog(): DragAcceptFiles();

(2) Implement WM_DROPFILES:

void CYourDialog::OnDropFiles(HDROP hDropInfo)
{
	UINT count = DragQueryFile(hDropInfo, 0xFFFFFFFF, 0, 0);
	UINT cch = 0;
	UINT cch_max = 0;
	CString str_file;
	CString str_result;

	WCHAR* pWStr = NULL;

	for (UINT i=0; i < count; ++i)
	{
		cch = DragQueryFile(hDropInfo, i, NULL, 0);

		if (cch < 1)
		{
			continue;
		}

		if (pWStr && cch > cch_max)
		{
			delete pWStr;
			pWStr = NULL;
		}
		if (cch > cch_max)
		{
			cch_max = cch;
		}
		if (!pWStr)
		{
			pWStr = new WCHAR[cch_max+1];
		}

		DragQueryFile(hDropInfo, i, pWStr, cch_max+1);
		str_file = CString(pWStr);

		str_result += str_file + _T("\r\n");
	}

	m_edt_files.SetWindowText(str_result);

	CDialog::OnDropFiles(hDropInfo);
}

After this tiny work, your dialog is accepting draggable files from a folder. And you get each file path by calling DragQueryFile() in OnDropFiles(). It's that simple.

Nov 13 2009
CDHtmlDialog

Dialogs based on CDHtmlDialog may be well layouted by composing an html source page.

July 19 2008
MFC versus System.Windows.Forms

MFC is way harder then C# windows GUI library. It is more about writing code then drag'n'drop operating. To prove these tough words I say that there is even no layout control presented in MFC. Which means that each dialog GUI application has to be layouted manually once again. But what's wrong with me I'm starting to like MFC :)

Apr 05 2008
Icons program

Does anybody know a good (convenient, light weighted) program that paints the .ico images? I want it to produce icons from regular (.bmp, .jpg, .gif) images. I don't really like to draw icons because it is kind of art. And does take time.

Semern GUI

Today I've designed some improvements to the Semern engine and also a word amount control. Now we can say whether we want to see 3% of the whole word amount or we just need 20 words.

Another feature I like in Semern is that the whole interface reads like a sentence: Analyze <a document> displaying <that much procents of words or that many words> written in <language> with encoding <the encoding> using options <the options>.

Mar 10 2008
C# System.Windows.Forms library

Graphical plot

I need a small library that should produce reports as a graphical plot. So it takes an array of pairs (double x; double y), width and height of a result picture (plot). And it gives out the plot as a System.Drawing.Image.

Image buildPlot( ArrayList dots, int width, int height );

Ivan Yurlagin,