Getting Navison in front while using Excel

compu-knowcompu-know Member Posts: 21
edited 2004-10-05 in Navision Attain
Is there a possibility (Statement, program or so) to get the Navision-Application in front while using another application (Excel).

Comments

  • BigblueBigblue Member Posts: 4
    Hi,

    it is possible to set a property ~"Visible" before starting Excel. Maybe also via ~"Userinteraction is allowed"

    If you have further questions in this type of materia, you can also contact me via mail.

    Best Regards from Stuttgart

    Martin
  • janpieterjanpieter Member Posts: 298
    You mean that you want Navision to be the topmost window:

    1. so navision is on top of excel
    2. but excel has the focus

    Thats possible when you write an automation DLL in VB6. You will have to use the API function "SetWindowPos". Little code example:
    Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
    
    Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
    Declare Function GetForegroundWindow Lib "user32" () As Long
    
    Global Const HWND_TOPMOST = -1
    Global Const HWND_NOTOPMOST = -2
    Global Const SWP_NOMOVE = 2
    Global Const SWP_NOSIZE = 1
    Global Const flags = SWP_NOMOVE Or SWP_NOSIZE
    
    Public Sub SetTopMostWindow()
      SetWindowPos GetNavHwnd, HWND_TOPMOST, 0, 0, 0, 0, flags
    End Sub
    Public Sub UndoSetTopMostWindow()
      SetWindowPos GetNavHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, flags
    End Sub
    Public Function GetNavHwnd as long
      Dim tmphwnd As Long
        
      tmphwnd = GetForegroundWindow
      Do
        GetNavHwnd = tmphwnd
        tmphwnd = GetParent(tmphwnd)
      Loop Until tmphwnd = 0
    End Function
    
    In a world without Borders or Fences, who needs Windows and Gates?
Sign In or Register to comment.