Solved

Always on top

Posted on 1998-03-23
10
339 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
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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 50 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

825 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