dcsimg
Results 1 to 15 of 15

Thread: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1803

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2014
    Posts
    76

    VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1803

    If the main window of the VB6 IDE is maximized when we close the IDE, this window state must be restored automatically when we launch the IDE again. However, on my pc the situation has changed after I upgraded my Windows 10 to the version 1803. I launch my VB6 with admin rights, and now the IDE window is returned to its normal non-maximized state with the corresponding animation every time after I launch it. Is there a way to fix this?

    Pay attention to the fact that this happens only if I run VB6 as admin (no matter how I do this - using the compatibility settings or manually using the Windows interface). If VB6 is launched with normal user privileges, all is ok.

  2. #2
    Hyperactive Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    484

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    Mine is exactly the same!

  3. #3

  4. #4
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    350

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    Yep, too
    Why not a small VB6 addin that retain the last state, and restore it?

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,086

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    I've got more problems than that. I travel and often plug a client's monitors into my laptop when I'm on-site. For instance, I just got back from Houston, and used two of their monitors ... with my laptop, giving me three. However, in Houston, just because of the L shaped layout of where I worked, my laptop was on the far-right, with my "main display" on my laptop. And, at home, my "main display" is on the left.

    Now, one thing that's always been a bit annoying is that my VB6 designer-forms are often off-the-screen. It's not a big problem because I just call up their property windows and then set "Left" property to zero. I've even written an add-in to do this for me.

    However, here's the latest problem. On Windows 1803, my "Immediate Window" is also doing something similar. Prior to 1803, it always seemed to make sure it was visible. However, since 1803, if I switch my monitor configuration, the Immediate window may be off-the-screen somewhere.

    Now, here's what's even more annoying. This sometimes happens in other situations. When it happens, I typically use the Alt-space (call up command drop-down), "M" (the move window command), and then arrow-keys (move the window), until the window is back visible again. In fact, once you start moving the window, the mouse is captured and can be used to move it. However, that doesn't work with the Immediate window. When you tap Alt-space, the main IDE window shows it's command drop-down, and NOT the Immediate window. Therefore, it gets to be a real PITA to get the Immediate window back on the screen.

    I guess I'll have to write an Add-In for this as well.

    Best Regards,
    Elroy

    EDIT1: It's Alt-space, not Ctrl-space. I fixed it in the above verbiage too.
    Last edited by Elroy; Sep 10th, 2018 at 09:01 AM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  6. #6
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,797

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    Elroy, one of the benefits of *not* using SDI is that Alt+Space fix brings back the whole IDE :-))

    cheers,
    </wqw>

  7. #7
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,086

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    Oh goodness. I'm WAY too hard headed to quit using the SDI. I actually wrote some code to fix it. I'll clean it up, wrap it into an add-in, and post it.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  8. #8
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,580

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    After some investigation I found that the reason is that the option to prompt for project on VB starts isn't enabled, showing that dialog prevent IDE to restore normal state, this option is here to Tools> Options...> environment tab> When Visual Basic starts: group> Prompt for project



  9. #9
    Hyperactive Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    484

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    It's certainly enabled on mine! Unless you mean it should NOT be enabled.

  10. #10
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,580

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    Quote Originally Posted by Steve Grant View Post
    It's certainly enabled on mine! Unless you mean it should NOT be enabled.
    Yes, i said "the reason is ... isn't enabled"



  11. #11
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,797

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    Quote Originally Posted by 4x2y View Post
    Yes, i said "the reason is ... isn't enabled"
    No difference here.

    cheers,
    </wqw>

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Oct 2014
    Posts
    76

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    Quote Originally Posted by 4x2y View Post
    After some investigation I found that the reason is that the option to prompt for project on VB starts isn't enabled, showing that dialog prevent IDE to restore normal state, this option is here to Tools> Options...> environment tab> When Visual Basic starts: group> Prompt for project
    That helps if we launch VB to create a new project. However, this does not help if I open an existing project from the Windows Explorer or from the list of recent items displayed by the right click on the VB shortcut in the taskbar.

  13. #13
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    310

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    Here's an add-in that attempts to fix this issue:

    Code:
    Option Explicit
    
    Private VBInstance As VBIDE.VBE
    
    Private Sub AddinInstance_OnAddInsUpdate(custom() As Variant)
        VBInstance.Addins.Update    'The manual recommends updating but it doesn't seem to be necessary
    End Sub
    
    Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
        Dim Values() As String
    
        Set VBInstance = Application
    
       'The IDE appears to store the last window coordinates and state in the registry value below
       'This value seems to have the following format: "Left Top Width Height WindowState"
       'The Left, Top, Width & Height values are in pixels
       'while WindowState seems to have only 2 values: 1 (Normal) and 3 (Maximized)
    
        On Error Resume Next
        Values = Split(CreateObject("WScript.Shell").RegRead("HKCU\Software\Microsoft\Visual Basic\6.0\MainWindow"))
    
        Select Case UBound(Values)
            Case 4&:    With VBInstance.MainWindow
                            .Left = CLng(Values(0&))
                            .Top = CLng(Values(1&))
                            .Width = CLng(Values(2&))
                            .Height = CLng(Values(3&))
    
                            If CLng(Values(4&)) <> 3& Then
                                .WindowState = vbext_ws_Normal
                            Else
                                .WindowState = vbext_ws_Maximize
                            End If
                        End With
        End Select
    End Sub
    
    #If StayLoadedToPersistSettings Then
    
    Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
        Dim sValue As String
    
        With VBInstance.MainWindow
            sValue = .Left & " " & .Top & " " & .Width & " " & .Height & " "
    
            If .WindowState = vbext_ws_Maximize Then
                sValue = sValue & "3"
            Else
                sValue = sValue & "1"
            End If
        End With
    
        On Error Resume Next
        CreateObject("WScript.Shell").RegWrite "HKCU\Software\Microsoft\Visual Basic\6.0\MainWindow", sValue
    End Sub
    
    #Else 'Unload immediately after this add-in has done its job
    
    Private Sub AddinInstance_OnStartupComplete(custom() As Variant)
        Dim MyProgID As String, AddIn As VBIDE.AddIn
    
        On Error Resume Next
        Err.Raise vbObjectError
        MyProgID = Err.Source & "." & TypeName(Me)
        On Error GoTo 0
    
        For Each AddIn In VBInstance.Addins
            If AddIn.ProgId = MyProgID Then
                AddIn.Connect = False
                Exit For
            End If
        Next
    End Sub
    
    #End If
    Let me know if it works.
    Attached Files Attached Files

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Oct 2014
    Posts
    76

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    Does not work for me. It is loaded at startup, but the IDE window is not maximized. The add-in does its work only if I open the Add-in dialog and click the Loaded\Unloaded checkbox for the add-in.

  15. #15
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    310

    Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1

    OK, let's try a couple of APIs: ShowWindowAsync and WM_SYSCOMMAND. See if either of them works this time.

    Code:
    Private Const SW_SHOWNORMAL As Long = 1
    Private Const SW_MAXIMIZE   As Long = 3
    
    Private Declare Function ShowWindowAsync Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
    
    Private Const SC_MAXIMIZE   As Long = &HF030&
    Private Const SC_RESTORE    As Long = &HF120&
    Private Const WM_SYSCOMMAND As Long = &H112
    
    Private Declare Function PostMessageW Lib "user32.dll" (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Code:
    Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
        . . .
    
                            If CLng(Values(4&)) <> 3& Then
                               '.WindowState = vbext_ws_Normal
                                ShowWindowAsync .hWnd, SW_SHOWNORMAL
                               'PostMessageW .hWnd, WM_SYSCOMMAND, SC_RESTORE, 0&
                            Else
                               '.WindowState = vbext_ws_Maximize
                                ShowWindowAsync .hWnd, SW_MAXIMIZE
                               'PostMessageW .hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0&
                            End If
    
        . . .
    End Sub
    If they still won't work, try putting the code above in a Timer procedure (either via VB.Timer or SetTimer) and run the code repeatedly until the IDE is in the desired window state. Of course, the add-in will need to stay loaded at least until it has accomplished its mission, so the AddinInstance_OnStartupComplete() subroutine will have to be commented out.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width