Solved

Pop-up window style.

Posted on 1998-06-23
11
381 Views
Last Modified: 2013-11-28
I am developing an application which can pop up another  window when a button on the main window is clicked. I used the CFrameWnd member function LoadFrame(nResID, WS_OVERLAPPEDWINDOW, NULL, &context). The problem is that the popped up window is always on top, even if it is inactive. I tried other window styles, but they are either still always on top or do not show up at all. Is there any way to solve the problem? By the way, how to set the size of the popped up window. I do not want to use the default size. I want it smaller when it is popped up.
0
Comment
Question by:mchen2
11 Comments
 

Expert Comment

by:dujie
ID: 1318357
The first question: You don't use the LoadFrame fuction.
second question:
  You can use CWnd::PreCreateWindow function,It is called by the framework before the creation of the Windows window attached to this CWnd object.


0
 

Author Comment

by:mchen2
ID: 1318358
In LoadFrame fuction the context is an instance of CCreateContext. It associates the View with the Frame and the Document. If I do not use the LoadFrame function, how can I associate the View with the Frame and the Document?
How to use CWnd::PreCreateWindow function?

Could you give me some sample code?
0
 

Author Comment

by:mchen2
ID: 1318359
Adjusted points to 30
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:mchen2
ID: 1318360
Adjusted points to 50
0
 

Author Comment

by:mchen2
ID: 1318361
Adjusted points to 80
0
 

Expert Comment

by:mulenga
ID: 1318362
Why don't you try using a modeless dialog box and passing it a reference to your view/document?
0
 
LVL 1

Expert Comment

by:speedup
ID: 1318363
DO remember to remove WS_EX_TOOLWINDOW from its style.
In your PreCreateWindow(), set its size as you want.
0
 

Author Comment

by:mchen2
ID: 1318364
Hi, Mr. Speedup,

How to remove WS_EX_TOOLWINDOW?

How to set the size of the window in PreCreateWindow()?
0
 

Author Comment

by:mchen2
ID: 1318365
I withdraw the first question.

Now the question is:

How to set the size and the title of the window in PreCreateWindow()?
0
 
LVL 1

Accepted Solution

by:
payn earned 80 total points
ID: 1318366
Look up PreCreateWindow and CREATESTRUCT in your documentation, but here's a simple sample that illustrates everything you want and more:

The following window will not have the WS_EX_TOOLWINDOW style when created, will be k_nMyWidth by k_nMyHeight in size, will have the title "Falco Lives!", and will be a top-level window (e.g., outside of your MDI frame). You can also add or remove any other style or extended style, explicitly place the window, change the window's menu, and do a few other things here.

class CMyWnd : public CWnd
{
public:
  BOOL PreCreateWindow(CREATESTRUCT& cs);
}

BOOL CMyWnd::PreCreateWindow(CREATESTRUCT& cs)
{
  // First call the base class
  if (!CWnd::PreCreateWindow(cs)) return FALSE;

  // Turn off the WS_EX_TOOLWINDOW style (an extended style)
  cs.dwExStyle &= ~WS_EX_TOOLWINDOW;
  // Set the window size to be smaller than usual
  cs.cx = k_nMyWidth;  // Maybe max(cs.cx, k_nMyWidth instead? or cs.cx/2?)
  cs.cy = k_nMyHeight;
  // Set the title
  cs.lpszName = "Falco Lives!";
  // Set the parent window to NULL, so we're free-floating. We could explicitly attach
  // the window to a parent just as easily.
  cs.hwndParent = NULL;
  // If you return FALSE, Windows cancels creation of the window.
  return TRUE;
}


0
 

Author Comment

by:mchen2
ID: 1318367
Thanks.

I tried your approach. The problems are:

1. cs.hwndParent = NULL; statement causes assertion failure.
2. cs.lpszName = "Falco Lives!"; statement does not work. (The frame is a CChildFrame, not a top-level window)
3. cs.cx = cs.cx/2; statement does dot work.
I guess I did not make the question clear. This is a MDI application. I want to set the child window's style.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For many of us, the  holiday season kindles the natural urge to give back to our friends, family members and communities. While it's easy for friends to notice the impact of such deeds, understanding the contributions of businesses and enterprises i…
A great marketing strategy is diverse.  Read about the not so popular, yet effective, marketing tactics you can start using today!
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question