Solved

How to remember the size of a dialog

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
fix34  challenge 9 141
wordmultiple challenge 12 141
Problem to event 3 102
Thin secure Windows 10 5 102
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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