Print Page | Close Window

LoadPosition question

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=13091
Printed Date: 23 June 2025 at 8:19am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: LoadPosition question
Posted By: dennisV
Subject: LoadPosition question
Date Posted: 06 January 2009 at 4:19pm
Hello all!

Is it possible to call LoadPosition, but for it not to actually display the main frame? The problem is that if I wish for the application to start minimized, I don't want to see the widow poping up and then getting minimized, but a call to LoadPosition from InitInstance does that. If I don't call LoadPosition, then the main window is not created properly (the CXTPTabClientWnd is not created it seems).

Thanks in advance!


-------------
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)



Replies:
Posted By: Oleg
Date Posted: 07 January 2009 at 1:50pm

Hi,

What is "LoadPosition" there is no such API and we don't have any class that has such method.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: dennisV
Date Posted: 07 January 2009 at 3:15pm
Oops, sorry - I meant LoadWindowPos(). This is how I have it:

bool CMainFrame::LoadPosition()
{
    bool bRet = m_wndPosition.LoadWindowPos(this,_T("mainFrame"));
    GetCommandBars()->RedrawCommandBars();

    return bRet;
}



-------------
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)


Posted By: mdoubson
Date Posted: 07 January 2009 at 3:26pm
Usually in such cases you can prepare everything in hidden widow state and show windows when you needed - still all your geometry will be proper e.g. you can dock control bar by x,y - coordinates


Posted By: dennisV
Date Posted: 07 January 2009 at 3:43pm
Originally posted by mdoubson mdoubson wrote:

Usually in such cases you can prepare everything in hidden widow state and show windows when you needed - still all your geometry will be proper e.g. you can dock control bar by x,y - coordinates

Yes, I do have my window in the hidden state, but it becomes visible as soon as this is hit:

pWnd->SetWindowPlacement(this);

(inside the LoadWindowPos() function)


-------------
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)


Posted By: mdoubson
Date Posted: 07 January 2009 at 4:08pm
You right - but you can overwrite this function and use
CWnd::SetWindowPos instead of CWnd::SetWindowPlacement
 
BOOL CXTWindowPos::LoadWindowPos(CWnd* pWnd, LPCTSTR lpszWndPos/*=NULL*/, LPCTSTR lpszSection/*=NULL*/)
{

ASSERT_VALID(pWnd); // must be valid.

if (::IsWindow(pWnd->m_hWnd))

{

if (LoadWindowPos(lpszWndPos, lpszSection))

{

pWnd->SetWindowPlacement(this);

return TRUE;

}

}

return FALSE;

}



Posted By: mdoubson
Date Posted: 07 January 2009 at 4:45pm

This is piece of SaveWindowPos function:
it always keep stored showCmd of WINDOWPLACEMENT as SW_SHOWNORMAL or SW_SHOWMAXIMIZED
 
// Make sure we don't pop up
// minimized the next time
if (showCmd != SW_SHOWMAXIMIZED)
{
showCmd = SW_SHOWNORMAL;
}
 
so in YOUR LoadWindowPos you can change showCmd before SetWindowPlacement call and it will be hidden or minimized as you with. Be careful with potential popups!

BOOL CXTWindowPos::LoadWindowPos(CWnd* pWnd, LPCTSTR lpszWndPos/*=NULL*/, LPCTSTR lpszSection/*=NULL*/)

{

ASSERT_VALID(pWnd); // must be valid.

if (::IsWindow(pWnd->m_hWnd))

{

if (LoadWindowPos(lpszWndPos, lpszSection))

{

pWnd->SetWindowPlacement(this);

return TRUE;

}

}

return FALSE;

}



Posted By: dennisV
Date Posted: 08 January 2009 at 4:15pm
Overriding the LoadWindowPos() seems to work (I pass in a bool specifying whether to hide the window or not). This is what I've got now:

BOOL CMyXTWindowPos::LoadWindowPos(bool bHide, CWnd* pWnd, LPCTSTR lpszWndPos/*=NULL*/, LPCTSTR lpszSection/*=NULL*/)
{
    ASSERT_VALID(pWnd); // must be valid.

    if (::IsWindow(pWnd->m_hWnd))
    {
        if (__super::LoadWindowPos(lpszWndPos, lpszSection))
        {
            if(bHide)
            {
                showCmd = SW_HIDE;
            }
            pWnd->SetWindowPlacement(this);
            return TRUE;
        }
    }

    return FALSE;
}


I didn't exactly understand what you mean about popups - can you please explain a bit more?

Thanks!


-------------
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)


Posted By: mdoubson
Date Posted: 08 January 2009 at 4:31pm
Of course it will work. Popup means that some app have popup appears on some state. Better for user-friendly desigh to have visible owner of such popup othercase popup can be under some other app and user will mo see it. Example - Google notifier which popup login dialog but sometimes under OutlookExpress window


Posted By: dennisV
Date Posted: 08 January 2009 at 4:37pm
Ah, ok, I understand 

-------------
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net