Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to remember the size of a dialog

Posted on 2002-07-10
4
Medium Priority
?
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

618 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