Link to home
Start Free TrialLog in
Avatar of MHorner
MHorner

asked on

Hwnd_TopMost(In this Process)

I am trying to display a form that sits on top of all other forms in the application but sits behing any windows form other processes that the user might switch to. I want to load this for from a user control.

I currently have a work around using the follwing code but I looking for something a bit swisher.

Private Sub Timer1_Timer()

  Dim lngHandle As Long

  Timer1.Enabled = False
 
  lngHandle = GetActiveWindow
  If lngHandle <> mlngFormHWND Then
    If lngHandle = mlngParentHWND Then
      SetWindowPos moPlanner.hWnd, HWND_TOPMOST, _
        0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
    Else
      SetWindowPos moPlanner.hWnd, HWND_BOTTOM, _
        0, 0, 0, 0, SWP_NOACTIVATE Or _
        SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    End If
  End If
  Timer1.Enabled = True

End Sub

Thanks

Martin
ASKER CERTIFIED SOLUTION
Avatar of ameba
ameba
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MHorner
MHorner

ASKER

Thanks for that. I suspected that subclassing was the right answer but I was hoping for an alternative.
C grade is insulting.  Even if my answer was only confirmation of what you were doing, it required high degree of knowledge and expertize!

I am rejecting C grade!
Experts work very hard to maintain good grade averages here at experts-exchange. More likely than not, they request that questions with grades less than A be deleted because many askers do not understand the grading policy. Askers also may not know that the grade given in no way affects the question points paid, but greatly affects the expert points received.
 
To avoid that, I've determined that, if someone is graded less than an A and does not give the reasoning behind it, other than "wishing" it were different than it it, I change the grade to an A.
 
Guidelines for giving grades can be found at https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3
 
If, after reading that, you still think this question warrants a grade less than an A, feel free to let us know.
 
Changed grade to A...
 
Moondancer
Community Support Moderator @ Experts Exchange
Avatar of MHorner

ASKER

I am guilty of not reading the guidelines. I marked the response as C for average or in other words what I would expect from an Expert.

I felt afterwards that I should have just found the vb2theMax page myself instead of bothering anyone here. But I did bother people here and I am happy to change it to an A if that is the policy.