[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to remember the size of a dialog

Posted on 2002-07-10
4
Medium Priority
?
255 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 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

872 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