resizing dialog box
-
Being a beginner, i am having quite alot problem in changing a size of a dialog box to another specific size..more precisely i wish to make a calculator like the one windows have .i have created a standard one and have added a menu but am having a problem in changing the size when the scientific tab is pressed in the menu.... please help me in this respect and please try to explain a bit.... thankyou haseeb
-
Being a beginner, i am having quite alot problem in changing a size of a dialog box to another specific size..more precisely i wish to make a calculator like the one windows have .i have created a standard one and have added a menu but am having a problem in changing the size when the scientific tab is pressed in the menu.... please help me in this respect and please try to explain a bit.... thankyou haseeb
well .. sizing a dialog is a little bit deferent than other kind of windows, because of its measuring units. In a dialog when you say that width = 100, it doesn't mean 100 pixels (!!) it means 100 dialog units (depends on the font you are using in the dialog). open user dialog resource in the visual c++ and look at the status bar (right most), you will find the size of your dialog in dialog units. so, 1- write down size of your dialog when in the scientific mode (from the status bar), these are in the dialog measuring units. 2- ...
CRect rect; rect.left = 0; rect.top = 0; //replace Width with the value of width you wrote rect.right = Width; //replace Height with the value of height you wrote rect.bottom = Height; //Call this function which converts the dialog units //into pixel units and pass it a pointer to rect MapDialogRect(&rect);
now you have the new size in pixel units. you can use it freely. 3- Call the function SetWindowPos() and give it the width and height of the rect. I suggest you move with the debugger to watch the change in the units after the MapDialogRect() call. hope it is helpfull good luck k_dehairy -
Being a beginner, i am having quite alot problem in changing a size of a dialog box to another specific size..more precisely i wish to make a calculator like the one windows have .i have created a standard one and have added a menu but am having a problem in changing the size when the scientific tab is pressed in the menu.... please help me in this respect and please try to explain a bit.... thankyou haseeb
Actualy the Windows calculator probably does not resize at all. It most likely consist of 2 different dialog boxes. When the user decides to switch caculator views, that is what it does. 1) Create 2 dialog boxes: normal and scientific. Remember to use the same IDs for the buttons, etc... that do the same thing. 2) Create a CDialog based class for the scientific dialog only, since you only need one class to handle all the commands. 3) Now when the user selects a new veiw call EndDialog(some known value). Example:
if( dialogID == IDD_NORMAL )
EndDialog(IDD_SCIENTIFIC).
else
EndDialog(IDD_NORMAL).- Finaly your code calling DoModal() (to show your dialog) needs to look something like this:
...
int result = IDD_NORMAL.
do {
if( result != IDD_NORMAL || result != IDD_SCIENTIFIC )
break; // something happen that should not have
{ // required
CMyDialog dlg(result);
result = dlg.DoModal
} // dlg destroyed here
// FYI: IDOK = 1, IDCANCEL = 2
} while( result != IDOK && result != IDCANCEL );Any way that is most likely how I would do it. You ought to be able to figure out the rest. Good Luck! INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
-
well .. sizing a dialog is a little bit deferent than other kind of windows, because of its measuring units. In a dialog when you say that width = 100, it doesn't mean 100 pixels (!!) it means 100 dialog units (depends on the font you are using in the dialog). open user dialog resource in the visual c++ and look at the status bar (right most), you will find the size of your dialog in dialog units. so, 1- write down size of your dialog when in the scientific mode (from the status bar), these are in the dialog measuring units. 2- ...
CRect rect; rect.left = 0; rect.top = 0; //replace Width with the value of width you wrote rect.right = Width; //replace Height with the value of height you wrote rect.bottom = Height; //Call this function which converts the dialog units //into pixel units and pass it a pointer to rect MapDialogRect(&rect);
now you have the new size in pixel units. you can use it freely. 3- Call the function SetWindowPos() and give it the width and height of the rect. I suggest you move with the debugger to watch the change in the units after the MapDialogRect() call. hope it is helpfull good luck k_dehairythanx alot ... probably now i would be able to achieve my goal.... thanx... haseeb haseeb
-
Actualy the Windows calculator probably does not resize at all. It most likely consist of 2 different dialog boxes. When the user decides to switch caculator views, that is what it does. 1) Create 2 dialog boxes: normal and scientific. Remember to use the same IDs for the buttons, etc... that do the same thing. 2) Create a CDialog based class for the scientific dialog only, since you only need one class to handle all the commands. 3) Now when the user selects a new veiw call EndDialog(some known value). Example:
if( dialogID == IDD_NORMAL )
EndDialog(IDD_SCIENTIFIC).
else
EndDialog(IDD_NORMAL).- Finaly your code calling DoModal() (to show your dialog) needs to look something like this:
...
int result = IDD_NORMAL.
do {
if( result != IDD_NORMAL || result != IDD_SCIENTIFIC )
break; // something happen that should not have
{ // required
CMyDialog dlg(result);
result = dlg.DoModal
} // dlg destroyed here
// FYI: IDOK = 1, IDCANCEL = 2
} while( result != IDOK && result != IDCANCEL );Any way that is most likely how I would do it. You ought to be able to figure out the rest. Good Luck! INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
thank you.... i hope now i would figure out a way to solve the problem... haseeb