[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Pop-up window style.

Posted on 1998-06-23
11
Medium Priority
?
399 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 160 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

Hire Technology Freelancers with Gigs

Work with 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

We aren’t perfect, just like everyone else.  Check out the email errors our community caught and learn the top errors every email marketer should avoid.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

649 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