[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

Always on top

ms visual c 4.1 :

In MDI application, how do I implement the always on top feature?
0
rich135
Asked:
rich135
  • 5
  • 2
  • 2
  • +1
1 Solution
 
Tommy HuiCommented:
Do you want a child to always be on top? Or do you mean the application?

0
 
lbrucherCommented:
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
 
rich135Author Commented:
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
rich135Author Commented:
also...how to I respond to Thui's "comment"
0
 
Tommy HuiCommented:
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
 
rich135Author Commented:
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
 
chensuCommented:
In this case, use
pMainFrame->ModifyStyleEx(0, WS_EX_TOPMOST);
or
m_pMainWnd = pMainFrame;
AfxGetApp()->GetMainWnd()->ModifyStyleEx(0, WS_EX_TOPMOST);

0
 
rich135Author Commented:
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
 
chensuCommented:
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
 
rich135Author Commented:
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now