Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - LoadPosition question
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

LoadPosition question

 Post Reply Post Reply
Author
Message
dennisV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 October 2004
Location: Australia
Status: Offline
Points: 242
Post Options Post Options   Thanks (0) Thanks(0)   Quote dennisV Quote  Post ReplyReply Direct Link To This Post Topic: LoadPosition question
    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)
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
dennisV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 October 2004
Location: Australia
Status: Offline
Points: 242
Post Options Post Options   Thanks (0) Thanks(0)   Quote dennisV Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
dennisV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 October 2004
Location: Australia
Status: Offline
Points: 242
Post Options Post Options   Thanks (0) Thanks(0)   Quote dennisV Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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;

}

Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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;

}

Back to Top
dennisV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 October 2004
Location: Australia
Status: Offline
Points: 242
Post Options Post Options   Thanks (0) Thanks(0)   Quote dennisV Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
dennisV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 October 2004
Location: Australia
Status: Offline
Points: 242
Post Options Post Options   Thanks (0) Thanks(0)   Quote dennisV Quote  Post ReplyReply Direct Link To This Post Posted: 08 January 2009 at 4:37pm
Ah, ok, I understand 
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.109 seconds.