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

x
?
Solved

Always on top

Posted on 1998-03-23
10
Medium Priority
?
360 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
[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
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 15

Expert Comment

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

0
 

Expert Comment

by:lbrucher
ID: 1412228
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
ID: 1412229
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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Author Comment

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

Expert Comment

by:Tommy Hui
ID: 1412231
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
 

Author Comment

by:rich135
ID: 1412232
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
ID: 1412233
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
ID: 1412234
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 150 total points
ID: 1412235
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
ID: 1412236
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

656 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