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.
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. To all, peace and happiness.
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. To all, peace and happiness.
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
Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1
Originally Posted by 4x2y
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.
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
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.
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.
Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1
[s]This solution (for MDI) is helped me:[/s]
When using VB 6 in MDI mode, to force code/object windows to open maximized add a new key called 'MDIMaximized' to the registry as indicated below, and set its value to a string value of 1:
HKEY_CURRENT_USER/Software/Microsoft/Visual Basic/6.0/MDIMaximized = "1"
Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1
hmmm... I had never even noticed this. I ran a couple of tests just now starting it with the vb shortcut and also by just double clicking a vbp to open it. Both cases it behaved the same. Window is not maximized but you have to look close to even notice it as the window is the size of the screen every time. Clicking the max button does very little in terms of changing the size from what it already has. If I make the window smaller and exit then it restores it to the smaller size on start up. I generally do not do this and when I do well I just resize it when I need to, no biggie, it always retains whatever size I had set when I closed it.
So the simple solution would seem to be just drag the form to the size of the screen. That way it will be in effect maximized when it starts even if it is not set to maximized so there is no need to maximize and you can still move it around if you like. Aside from that is it really a big deal to click the maximize button if your normal state is smaller? I doubt that I would even notice such a thing much more important things to do when I open the editor so I would not give it a second thought.
Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1
Ok, I modified Add-In by Victor Bravo VI version with a timer by The Trick.
Now, it works fine.
Using:
1. Compile Add-In
2. Run _Register.cmd as Admin.
I removed most code related to save settings since I don't have those registry key by default "HKCU\Software\Microsoft\Visual Basic\6.0\MainWindow", and anyway I don't care about size, I just need it to be full screen always at start up. I added force maximize each 1 sec. (10 times). It's my first Add-In (fork). So, sorry if something wrong.
Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1
Originally Posted by Dragokas
Ok, I modified Add-In by Victor Bravo VI version with a timer by The Trick.
Now, it works fine.
Using:
1. Compile Add-In
2. Run _Register.cmd as Admin.
I removed most code related to save settings since I don't have those registry key by default "HKCU\Software\Microsoft\Visual Basic\6.0\MainWindow", and anyway I don't care about size, I just need it to be full screen always at start up. I added force maximize each 1 sec. (10 times). It's my first Add-In (fork). So, sorry if something wrong.
In my home version. It seems that the plug-in did not start successfully
Code:
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
Set VBInstance = Application
Set m_cTimer = New CTrickTimer
m_cTimer.Tag = "1"
m_cTimer.Interval = 500
MsgBox "10" 'cant show'
End Sub
Private Sub m_cTimer_Tick()
Static Count As Long
Count = Count + 1
If Count = 10 Then
Addin_Unload
Exit Sub
End If
Wnd_SetMaximized
End Sub
Private Sub Wnd_SetMaximized()
With VBInstance.MainWindow
MsgBox "ok" 'cant show'
.WindowState = vbext_ws_Maximize
End With
End Sub
Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1
xxdoc, no idea. Can you check "Add-ins" -> "Add-In Manager" -> is item exist at all: "IDE Window Fix" ?
If yes, select "Loaded/Unloded" and press OK, IDE should instantly maximize in 1 sec.
Re: VB6 IDE run as admin no longer remembers its maximized state in Windows 10 ver. 1
xxdoc, I think I know, what whas the problem. For some reason, project had a reference to office library.
Updated.
- removed unused references
- removed custom base dll address (what is it for?)
- changed options to "fast code"
- decreased timer reaction down to 100 ms.
- fixed throwing errors when you run the application too early
- fixed IDE window overlap your form when you run the application too early
- fixed going to fullscreen when you specially minimize the window
- now, attempt to make a fullscreen only once, then instantly unload the add-in. No need to "flash".
Last edited by Dragokas; Jul 27th, 2021 at 08:29 AM.