Solved

How to remember the size of a dialog

Posted on 2002-07-10
4
244 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 66
List out all word 7 224
substring method in java 1 79
sumHeights2  challenge 7 78
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: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

11 Experts available now in Live!

Get 1:1 Help Now