Solved

Pop-up window style.

Posted on 1998-06-23
11
379 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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
canBalance challenge 34 69
matchUp  challenge 9 92
sumHeights2  challenge 7 87
Does Android x86 support RTSP stream in Xibo Client? 13 97
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
An overview of how to create reports in Adobe Analytics (formerly Omniture Site Catalyst) using pageNames, events, eVars and props. This video will show you how to install the Omniture Debugger tool so can see (and test) what is being passed int…
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.

919 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

16 Experts available now in Live!

Get 1:1 Help Now