Solved

Pop-up window style.

Posted on 1998-06-23
11
389 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Read about the 3 stages of the buyer's journey: awareness, consideration, and decision.
There are many other benefits to creating an inbound marketing strategy. Let’s take a look at five of the biggest and how they'll affect your business.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

688 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