![]() |
LoadPosition question |
Post Reply ![]() |
Author | |
dennisV ![]() Senior Member ![]() ![]() Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
![]() ![]() ![]() ![]() ![]() 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) |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
dennisV ![]() Senior Member ![]() ![]() Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
![]() ![]() ![]() ![]() ![]() |
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) |
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
dennisV ![]() Senior Member ![]() ![]() Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
![]() ![]() ![]() ![]() ![]() |
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) |
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
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;} |
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
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;} |
|
![]() |
|
dennisV ![]() Senior Member ![]() ![]() Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
![]() ![]() ![]() ![]() ![]() |
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) |
|
![]() |
|
mdoubson ![]() Senior Member ![]() ![]() Joined: 17 November 2008 Status: Offline Points: 1705 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
dennisV ![]() Senior Member ![]() ![]() Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
![]() ![]() ![]() ![]() ![]() |
Ah, ok, I understand
![]() |
|
// W7 64 Ultimate SP1
// VS 2008 // CodeJock 16.2.3 (MFC) |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |