Mario.Tapilouw

Thursday, February 26, 2009

writing a well-written code is faster than debugging a badly written code...

Debugging is a pain in the ass..
It can make you sleepless in the evening, lose your mood in the morning, decrease your appetite, and even a nightmare, hahaha...

Lesson learned: It's better to write a well-written code than you have to spend time in debugging your code in the end.. Sometimes, after you wrote the code, you don't even remember why you wrote it that way. This is what makes debugging a difficult job.

This is the most efficient way to develop a software, trust me hehe..

Labels: , , ,

Friday, February 13, 2009

Setting Minimum and Maximum Window Size on Visual C++

If you're using dialog based UI, it's quite simple. Just add this line in the MessageMap

BEGIN_MESSAGE_MAP(CDialogDlg, CDialog)
... ON_WM_GETMINMAXINFO()
END_MESSAGE_MAP()


and then add the function into your dialog class:


void CDialogDlg::OnGetMinMaxInfo( MINMAXINFO FAR* pMinMaxInfo )
{
// Preferred Maximum X & Y.
const int MAX_SIZE_X = 750;
const int MAX_SIZE_Y = 650;
// Preferred Minimum X & Y.
const int MIN_SIZE_X = 400;
const int MIN_SIZE_Y = 350;
// Set the maximum size. Used while maximizing.
pMinMaxInfo->ptMaxSize.x = MAX_SIZE_X;
pMinMaxInfo->ptMaxSize.y = MAX_SIZE_Y;
// Set the Minimum Track Size. Used while resizing.
pMinMaxInfo->ptMinTrackSize.x = MIN_SIZE_X;
pMinMaxInfo->ptMinTrackSize.y = MIN_SIZE_Y;
// Set the Maximum Track Size. Used while resizing.
pMinMaxInfo->ptMaxTrackSize.x = MAX_SIZE_X;
pMinMaxInfo->ptMaxTrackSize.y = MAX_SIZE_Y;
}


Don't forget to enable the Minimize and Maximize box in your dialog, then Voila.. your dialog box will changed.

Labels: , , ,