Solved

Always on top

Posted on 1998-03-23
10
332 Views
Last Modified: 2013-12-03
ms visual c 4.1 :

In MDI application, how do I implement the always on top feature?
0
Comment
Question by:rich135
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
Comment Utility
Do you want a child to always be on top? Or do you mean the application?

0
 

Expert Comment

by:lbrucher
Comment Utility
For the app to be always on top, look at the SetWindowsPos() Win32 API. The last param (flags) allows you to set/remove that feature.

If you want that for a child window (and I suppose relative to the other child windows), dunno (and don't remember having ever seen it).

L.

0
 

Author Comment

by:rich135
Comment Utility
win 95    ms visual c++ 4.1 App.

trying to implement always on top feature for a MDI app. Want entire app to be on top (but at users command).

tried SetWindowPos as advised but dont undersatnd which of the flags to set. Tried to set the 1st parm to &wndTopMost, but then the module gave me wndTopMost= undefined! (even though spinctrl sample app uses same statement).

Have spent 4 hours trying to figure out why (esp. why the undefined).

Previous answer got me started, but still stuck..

Thanx...rich
0
 

Author Comment

by:rich135
Comment Utility
also...how to I respond to Thui's "comment"
0
 
LVL 15

Expert Comment

by:Tommy Hui
Comment Utility
In your response to making the application be on top, use

  AfxGetApp()->GetMainWnd()->ModifyStyleEx(0, WS_EX_TOPMOST);

and to turn it off

  AfxGetApp()->GetMainWnd()->ModifyStyleEx(WS_EX_TOPMOST, 0);

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:rich135
Comment Utility
thui...tried the modify style fix, but it didnt work. MDI app wizard created app. vis c 4.1 ..name of app is opcal. here is code i put in opcal.doc to turn on "always on top" feature. And still, other apps, when run, would overlap/hide this app.

have spent all day on this.....

      // create main MDI Frame window
      CMainFrame* pMainFrame = new CMainFrame;
      if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
            return FALSE;
      pMainFrame->ShowWindow(m_nCmdShow);
      pMainFrame->UpdateWindow();
      AfxGetApp()->GetMainWnd()->ModifyStyleEx(0, WS_EX_TOPMOST);       
//      AfxGetApp()->GetMainWnd()->ModifyStyle(SWP_NOZORDER,0);       
      m_pMainWnd = pMainFrame;
i also tried the 2nd modify style to insure swp_nozorder turned off. i also put the modify style statement (the one you rec'd in opcaldoc. cpp, and opcaldlg.cpp (i use a formview, not a view).

still, other windowsapps would overlap this app.

why?
0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
In this case, use
pMainFrame->ModifyStyleEx(0, WS_EX_TOPMOST);
or
m_pMainWnd = pMainFrame;
AfxGetApp()->GetMainWnd()->ModifyStyleEx(0, WS_EX_TOPMOST);

0
 

Author Comment

by:rich135
Comment Utility
Chensu...still doesnt work...Did a brand new app with vis c++ 4.1...MDI...nothing fancy. here is code in alwaysontop.doc:

      // Dispatch commands specified on the command line
      if (!ProcessShellCommand(cmdInfo))
            return FALSE;

      // The main window has been initialized, so show and update it.
      pMainFrame->ShowWindow(m_nCmdShow);
      pMainFrame->UpdateWindow();
      pMainFrame->ModifyStyleEx(0, WS_EX_TOPMOST);       
      return TRUE;

yet this app gets overlapped/hidden when i run other, different apps, under win 95...

allday i spent on this...

maybe someone should try to construct, using vis c++, similar app, abd see if iyt works...
0
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
Comment Utility
First, m_pMainWnd = pMainFrame; is still needed in the above code.

Second, try overriding PreCreateWindow().

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    cs.dwExStyle |= WS_EX_TOPMOST;

    return CFrameWnd::PreCreateWindow(cs);
}

Third, you can also try overriding OnCreate:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...

    this->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

    return 0;
}

0
 

Author Comment

by:rich135
Comment Utility
Chensu...finally got it to work...by putting setwindowpos(&wnd...etc) in mainfrm.h.

we conversed several times but i gave you a b cause you responded quickly and stayed with it. The other methods you suggested did not work for me. if int.., you can call me a thome (Boston).

rich
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

11 Experts available now in Live!

Get 1:1 Help Now