CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    LoadFrame, but hidden

    Hello. I have a 3rd-party MFC-app. I thought this was a simple task: I want to run the app with the main-window hidden.

    So I want to CTheApp::InitInstance() where the main-window is created:
    Code:
    if (pFrame->LoadFrame(IDR_MAINFRAME,
    		WS_OVERLAPPEDWINDOW, NULL, 
    		NULL))
    	{
    		if (bShow)
    		{      pFrame->ShowWindow(SW_SHOW);
    			pFrame->UpdateWindow();
    		}
    		else
    			pFrame->ShowWindow(SW_HIDE);
    	}
    Depending on bShow, the window should be visible or hidden.

    This works in general, but LoadFrame shows the window and ShowWindow(SW_HIDE) is hiding it again, so that the user sees the window for a short time. How is it possible to hide the window from the start?

  2. #2
    Join Date
    May 2002
    Location
    Romania
    Posts
    929

    Re: LoadFrame, but hidden

    Try

    if (pFrame->LoadFrame(IDR_MAINFRAME,
    WS_OVERLAPPEDWINDOW | ~WS_VISIBLE, NULL,
    NULL))
    {
    if (bShow)
    { pFrame->ShowWindow(SW_SHOW);
    pFrame->UpdateWindow();
    }
    }
    Move like a snake, think like a snake, be a snake !!!

  3. #3
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    Re: LoadFrame, but hidden

    Thanks, but this didn't work either. I made a small new demo-project and found that LoadFrame doesn't show the frame by default. I guess somewhere in the code of the 3rd-party-application they are showing the window.

  4. #4
    Join Date
    Apr 2011
    Location
    Australia
    Posts
    18

    Re: LoadFrame, but hidden

    Sorry to bring this ancient thread again but I have the very same problem and could not figure it out how to get rid of 'blinking' main frame window. Tried PreCreateWindow, ShowWinow(SW_HIDE) but the problem is still there. Any suggestion? Thanks for your time.

  5. #5
    Join Date
    Apr 2011
    Location
    Australia
    Posts
    18

    Resolved Re: LoadFrame, but hidden

    Found it. Before LoadFrame() set m_nCmdShow=bShow?SW_SHOW:SW_HIDE;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured