Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am storing values in resgistery while closing application and while relaunching application im getting values from registery (values coming coming correctly)and those values i want update in in the CREATESTRUCT

but values not updating in
CREATESTRUCT


What I have tried:

LPTSTR p = Width.GetBuffer(dwLen / sizeof(TCHAR));
        //Read TargetServer value from registry
        LSTATUS lStatus = ::RegQueryValueEx(hPathKey, _T("Width"), NULL, &dwtype, (LPBYTE)Width.GetBuffer(MAX_PATH), &nBytes);
        if (ERROR_SUCCESS == lStatus)
        {
            //m_ConnectServerVal.ReleaseBuffer();
        }
        else {
            dwLastError = GetLastError();
        }
        //Read TargetPort value from registry
        nBytes = (MAX_PATH) * sizeof(TCHAR);
        lStatus = ::RegQueryValueEx(hPathKey, _T("Height"), NULL, &dwtype, (LPBYTE)Height.GetBuffer(MAX_PATH), &nBytes);
        if (ERROR_SUCCESS == lStatus)
        {
           // m_ConnectPortVal.ReleaseBuffer();
        }
        else {
            dwLastError = GetLastError();
        }




cs.cy = _tstoi(Height); // here the value is coming 786,and storing it in cs
cs.cx = _tstoi(Width); // width is 1214
and  storing it in cs

if( !CFrameWndEx::PreCreateWindow(cs) )
but after this line executipon the values are updated,it means here when i debug its showing the above avlues(786,1214 ) not coming here.
could you please tell me if anything is wrong here
Posted
Updated 19-Sep-17 23:05pm
v2
Comments
Richard MacCutchan 20-Sep-17 4:31am    
Firstly why are you storing integer values as strings? Secondly, where is this code actually called?
Member 13089825 20-Sep-17 5:03am    
Firstly why are you storing integer values as strings
In registery we can store its as string only so from registery im getting that value(that is string type) and stroring it in CS
this code will be called in BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{

}
Richard MacCutchan 20-Sep-17 5:34am    
No, you can store as any type in the registry; see the documentation.
According to CWnd::PreCreateWindow (MFC)[^] you should be able to change the window size at that point. you need to use your debugger to see what is happening.

1 solution

The common place to restore the window size is OnCreate or ShowWindow (when called the first time) instead of PreCreateWindow. That can be used to modify the window class or style but window size and position may be changed by other functions before the window is shown the first time or even when ShowWindow is called with specific states.

You may also call CWnd::SetWindowPlacement or CWnd::SetWindowPos just before calling ShowWindow in InitInstance (or create a member function for your main frame class that does all that and is called from InitInstance instead of ShowWindow).

BTW: Why you are storing integer values as strings in the registry?
With MFC, just use CWinApp::WriteProfileInt and CWinApp::GetProfileInt after calling SetRegistryKey in InitInstance.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900