Solved

Pop-up window style.

Posted on 1998-06-23
11
376 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
 

Author Comment

by:mchen2
ID: 1318360
Adjusted points to 50
0
 

Author Comment

by:mchen2
ID: 1318361
Adjusted points to 80
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Panda2.5's Release Date The latest Google Panda algorithm update was released late on Tuesday, September 27th, and was noticed to have started affecting website traffic on Wednesday, September 28th.  Google did not proactively announce this update,…
Read about the 3 stages of the buyer's journey: awareness, consideration, and decision.
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.
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now