Solved

How to remember the size of a dialog

Posted on 2002-07-10
4
245 Views
Last Modified: 2013-11-20
Hi,

I have a resizable dialog. I want the size of the dialog to be remembered so that the next user open the dialog, it is in the customized size. So, I made two member viable in the dialog class: m_DialogWidth and m_DialogHeight. The question is in what function I should change the values of m_DialogWidth and m_DialogHeight? I tried OnSize(UINT nType, int cx, int cy) function of the dialog but it does not work. Because before the dialog is displayed, OnSize is called with some default width and height values. So m_DialogWidth and m_DialogHeight are always the default values not the customized values. Can anyone recommed me how to do this? Thanks!
0
Comment
Question by:yeshengl
  • 2
4 Comments
 
LVL 4

Expert Comment

by:mblat
ID: 7144819
Well, you can store your initial values in OnInitDialog() and AFTER that process them in OnSize();

CMyDialog::CMyDilaog()
{
 m_flag = false;
}

CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();

   m_flag = true;
   m_w = ..;
   m_h = ....
}

CMyDialog::OnSize(....)
{
  if(m_flag)
  {
    m_w = ....;
    m_h = ....;
  }
}

Hope it helps....
0
 

Accepted Solution

by:
skibud2 earned 50 total points
ID: 7151718
If you are closing your App then reopenning it, you can use a CArchive object to store the data.  For example, use this to get the data out of the archive-

///////////////////////////////////////////
// Get the data out of the archive

CFile aFile;
if(!aFile.Open(YOUR_PATH,CFile::modeRead,NULL))
{
#ifdef _DEBUG
afxDump << "Unable to open file" << "\n";
exit( 1 );
#endif
}
CArchive ar(&aFile,CArchive::load);

ar>>sizeX;
ar>>sizeY;
aFile.Close();

/////////////////////////////////////////////
// Insert the data into the archive

CFile aFile;
if(!aFile.Open(YOUR_PATH,CFile::modeWrite,NULL))
{
#ifdef _DEBUG
afxDump << "Unable to open file" << "\n";
exit( 1 );
#endif
}
CArchive ar(&aFile,CArchive::store);

ar<<sizeX;
ar<<sizeY;
aFile.Close();


0
 

Expert Comment

by:skibud2
ID: 7155364
Any questions?
0
 

Author Comment

by:yeshengl
ID: 7156085
Thanks for the answer!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
Expand macro to ask for filename column 8 37
Whole sheet autoscrub still needed 19 48
firstChar challenge 13 110
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now