Control the menu suite from within Navision code

PidiPidi Member Posts: 35
I wonder, if there is any way to either contol (hide / show) the menu suite from within Navision code or get it´s status to be able to control it by something like Keysend(ALT + F1).

What we basically want is the menu to be hidden on startup of the client.

I read all threads about the menu suite but couldn´t fing anything about this.

Thanks in advance for any hint

Pidi
Michael Peters
Bos Fod GmbH Düsseldorf
+49 2132 139-0

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    You could try SendKeys in Codeunit 1 to send Alt + F1 to Navision.

    Have a look at this thread how to use SendKeys: http://www.mibuso.com/forum/viewtopic.php?t=4934
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • ara3nara3n Member Posts: 9,257
    Here is code that will send the key command to windows and close the menue suit.

    wscript Automation Windows Script Host Object Model'.WshShell";
    IF ISCLEAR(wscript) THEN
      CREATE(wscript);
    
    wscript.SendKeys('%F1');
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • PidiPidi Member Posts: 35
    Thanks for the answers.

    I know Sendkeys and I´m using it already (incedentliy I mention "keysend" in my first message - sorry).

    SendKeys is exactly what I would use for switching off the menu, but to do that, I would need it´s status - othweise I might switch it on, when it´s off already.

    The On/Off status of the menu seems to be stored within the .ZUP file, so it can be either on or off on startup.

    Pidi
    Michael Peters
    Bos Fod GmbH Düsseldorf
    +49 2132 139-0
  • ara3nara3n Member Posts: 9,257
    Landsteiner has an ocx called called WinCtrl.ocx. The name of the class
    LSRetail Screen Control (Landsteinar Strengur)

    Here is how you use it.


    Screen.HideToolbar;

    It handles both scenarios.

    I don't know don't how they get the state, but it's a hack, or they have special connection with developers of Navision.
    I can send it to you if you like. I believe it requires MFC libraries.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • MauddibMauddib Member Posts: 269
    Ara3n - I assume this Landsteinar OCX is theirs and so cant really legally be used by other companies without getting their software?

    Any idea how they acheived what they do with it? I could do with doing the same thing and hiding the menu bar.
  • ara3nara3n Member Posts: 9,257
    Yes that is correct. Have no idea on how they achieved it. I would contact navision directly. Or ask for permission from LSretail.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • janpieterjanpieter Member Posts: 298
    Mauddib wrote:
    Ara3n - I assume this Landsteinar OCX is theirs and so cant really legally be used by other companies without getting their software?

    Any idea how they acheived what they do with it? I could do with doing the same thing and hiding the menu bar.

    Just a quick hint to get you going.

    If you know visual basic 6 i have samplecode of how to obtain window handles of all different windows (controls) within navision which currently has the active focus.

    I programmed this years ago so i hope the copied code parts are complete. - probably it won't compile as variable and functions are missing but it is just to get an idea -

    You have to do 2 things:
    - add code to obtain window handle of the menu (use program spy that ships with visual studio to obtain window name). If you don't get a window handle probably this window is closed.
    - send a WM_CLOSE to this handle (google for WM_CLOSE) (or use sendkeys ALT+F1)
    Public Declare Function APIFindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, _
                                                                              ByVal hWnd2 As Long, _
                                                                              ByVal lpsz1 As String, _
                                                                              ByVal lpsz2 As String) As Long
    
    Public Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
    
    Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, _
                                                                      ByVal lpClassName As String, _
                                                                      ByVal nMaxCount As Long) As Long
    
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, _
                                                                               ByVal lpString As String, _
                                                                               ByVal cch As Long) As Long
    
    Public Sub GetHwnd()
        Dim oldHWNDFINEXE As Long
        Dim tmpHwnd As Long
        
        oldHWNDFINEXE = g_hwndFINEXE
        'tmpHwnd = GetForegroundWindow
        g_hwndFINEXE = GetParentForeGroundWindow(g_strExcludeWindowName)
    
        ' check ik valid FIN EXE window
        Dim WinClassBuf As String * 255
        Dim WinClass As String
        GetClassName g_hwndFINEXE, WinClassBuf, 255
        WinClass = StripNulls(WinClassBuf)  ' remove extra Nulls & spaces
    
        If InStr(UCase(WinClass), "C/SIDE") = 0 Then
            g_hwndFINEXE = oldHWNDFINEXE
        End If
    
        If g_hwndFINEXE <> 0 Then
            g_hwndMDICLIENT = APIFindWindowEx(g_hwndFINEXE, 0&, "MDICLIENT", vbNullString)
            g_hwndTOOLBAR = APIFindWindowEx(g_hwndFINEXE, 0&, "C/SIDE Glued", "Toolbar")
            g_hwndSTATUSBAR = APIFindWindowEx(g_hwndFINEXE, 0&, "C/SIDE Glued", "Status Bar")
            g_hwndOBJECTDESIGNER = APIFindWindowEx(g_hwndMDICLIENT, 0&, vbNullString, "Object Designer")
        End If
    End Sub
    
    Private Function StripNulls(OriginalStr As String) As String
       If (InStr(OriginalStr, Chr(0)) > 0) Then
          OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
       End If
       StripNulls = OriginalStr
    End Function
    
    Public Function GetParentForeGroundWindow(WindowName As String) As Long
        Dim tmpHwnd As Long
        tmpHwnd = FindWindowByName(g_strExcludeWindowName)
        ' tmpHwnd = GetForegroundWindow
        Do
            GetParentForeGroundWindow = tmpHwnd
            tmpHwnd = GetParent(tmpHwnd)
        Loop Until tmpHwnd = 0
    End Function
    
    Public Function FindWindowByName(WindowName As String) As Long
        m_lngFoundHwnd = 0
        m_strWindowName = WindowName
        Call EnumChildWindows(0, AddressOf EnumChildWindow2, 0&)
        FindWindowByName = m_lngFoundHwnd
        m_strWindowName = ""
        m_lngFoundHwnd = 0
    End Function
    
    Function EnumChildWindow(ByVal hWnd As Long, ByVal lParam As Long) As Long
        Dim RetVal As Long
        Dim WinClassBuf As String * 255
        Dim WinTitleBuf As String * 255
        Dim WinClass As String
        Dim WinTitle As String
        Dim ChildCount As Integer    ' Number of Child Windows
        Dim cLV As Long              ' Child window handle
    
        RetVal = GetClassName(hWnd, WinClassBuf, 255)
        WinClass = StripNulls(WinClassBuf)  ' remove extra Nulls & spaces
        RetVal = GetWindowText(hWnd, WinTitleBuf, 255)
        WinTitle = StripNulls(WinTitleBuf)
        ChildCount = ChildCount + 1
        
        ReDim Preserve g_hwnd(UBound(g_hwnd) + 1)
        ReDim Preserve g_caption(UBound(g_caption) + 1)
        ReDim Preserve g_classname(UBound(g_classname) + 1)
        
        g_hwnd(UBound(g_hwnd)) = hWnd
        g_caption(UBound(g_caption)) = WinTitle
        g_classname(UBound(g_classname)) = WinClass
        
        EnumChildWindow = True
    End Function
    
    
    In a world without Borders or Fences, who needs Windows and Gates?
Sign In or Register to comment.