• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

Which API I need to make my software appears in front of other started software in user desktop?

  Hi experts!

I have a complicate software system which is actually of 6 different separated programs running in same time. I want to implement functionality when user click on Control Center all of my modules to goes in front of screen. Sometimes user start other program and is not comfortable to click on task bar to restore all of my started modules. I hope I ‘m clear what I need .

In a sentence – I need a VB6 code which to put my program in front of desktop of user. To use all the time SetTopMOST is not a option. May be to set up and then to remove topmost and software will stay at first position? Which command I need ?
0
dvplayltd
Asked:
dvplayltd
  • 3
1 Solution
 
VBClassicGuyCommented:
Put this in your Declarations section:

Public Enum SetWindowPosFlagsEnum
   SWP_FRAMECHANGED = &H20
   SWP_DRAWFRAME = SWP_FRAMECHANGED
   SWP_HIDEWINDOW = &H80
   SWP_NOACTIVATE = &H10
   SWP_NOCOPYBITS = &H100
   SWP_NOMOVE = &H2
   SWP_NOOWNERZORDER = &H200
   SWP_NOREDRAW = &H8
   SWP_NOREPOSITION = SWP_NOOWNERZORDER
   SWP_NOSIZE = &H1
   SWP_NOZORDER = &H4
   SWP_SHOWWINDOW = &H40
End Enum

Public Enum WndInsertAfterEnum
   HWND_BOTTOM = 1
   HWND_BROADCAST = &HFFFF&
   HWND_DESKTOP = 0
   HWND_NOTOPMOST = -2
   HWND_TOP = 0
   HWND_TOPMOST = -1
End Enum


Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As WndInsertAfterEnum, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As SetWindowPosFlagsEnum) As Long


Then, this code, executed once will put the window on top, but then allow others to appear on top of it later. That is what you want as I understand your question:

SetWindowPos Form1.hwnd, -1, 0, 0, 0, 0, 3
SetWindowPos Form1.hwnd, -2, 0, 0, 0, 0, 3
0
 
dvplayltdAuthor Commented:
I’m not sure I need exactly this, but will test does it work tomorrow. I’ in Europe based, now is 1 a.m in the morning.

My concert is not in start. IN start – as this is new programs it appears on top. My ask is later, once all my software modules are started.

Well, may be if I put it on topmost they will appears before other programs (if have such), but then I should remove topmost properties, may be this will work.
0
 
dvplayltdAuthor Commented:
It is Ok - it work. Due to your offer I write a function:

Public Sub SetPopup(ByVal frmHwnd As Long, Optional ByVal bRemove As Boolean = False)
  If bRemove Then
    Call SetWindowPos(frmHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_SHOWWINDOW)    'SWP_NOMOVE Or SWP_NOSIZE
  Else
    Call SetWindowPos(frmHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE)
  End If
End Sub


when I call it like this it work as I need:


 SetPopup Me.hwnd
 SetPopup Me.hwnd, True

this make form on top of all, and after that user can put other on his top.

Thank you!
0
 
dvplayltdAuthor Commented:
10x
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now