Post Reply

Forums -> UltraMon™ SDK -> VB6 does not seem to be affected by positioning
Les Caudle   2002-01-11 11:25
I'm tried several things, and can't seem to get VB6 GUI to come up on my left monitor at all (I have 3). Is there some trick to it? This code works with the notepad ok.

Set util = CreateObject("UltraMon.Utility")
If util.Run("G:\Util\Microsoft Visual Studio\Vb98\Vb6.exe") = true Then
Set wnd = CreateObject("UltraMon.Window")
If wnd.Find("", "", 0, util.ProcessID, 5000) = True Then
Set sys = CreateObject("UltraMon.System")
Set mon = sys.Monitors("1")
'wnd.Monitor = 3
wnd.left = mon.left ' + 800
wnd.top = mon.top
'wnd.width = mon.width
wnd.height = mon.workHeight
wnd.ShowState = SHOWSTATE_NORMAL
wnd.ApplyChanges 0
End If

Thanks, Les Caudle
Christian Studer   2002-01-11 11:50
VB is a special case:

1) it has a splash screen, so by default UltraMon will move the splash screen (being the first window created by the app) instead of the app's main window.

This can be fixed by looking for the window by title or class. In the case of VB, you'll need to specify the class because there are some hidden windows that are also named 'Microsoft Visual Basic'.

2) VB always repositions its main window to the primary monitor, so it is possible that UltraMon moves the window before VB has done the repositioning.

This can be fixed by waiting for a short period before moving the window.

On my system, the following script works fine, you may have to adjust the wait period:

Set util = CreateObject("UltraMon.Utility")
If util.Run("D:\Program Files\Msdev\VB98\VB6.exe") = True Then
Set wnd = CreateObject("UltraMon.Window")
If wnd.Find("", "wndclass_desked_gsk", FINDWND_CLASS, util.ProcessID, 5000) = True Then
Set sys = CreateObject("UltraMon.System")
Set mon = sys.Monitors("3")
wnd.Monitor = 3

util.Sleep 2000
wnd.ApplyChanges 0
End If
End If

Christian Studer - www.realtimesoft.com
Les Caudle   2002-01-13 00:47
Christian - I was unable to get that to work. I've seen it move the splash screen, but even if I have it wait for 30 seconds, it never seems to be able to find and move the main screen. I've tried it with no sleep values (I've got a dual processor box).

I've tried:
If wnd.Find("", "wndclass_desked_gsk", FINDWND_CLASS, 0, 5000) = True Then
MsgBox "found it" & wnd.title & " l = " & wnd.left

and it is always a window with no title.

I used to have tools that would allow me to click on a window and get info (class, etc.), but it is been a number of years and I don't even remember their names. Do you have utilities that will help in this issue?

A utility that would list all windows by a search name with wildcards showing their class and position and whether visible, etc. - whatever could be used to locate the proper window - would be very useful during the script development process (output to a listbox or something, running as an actual program I suppose, not script)

If you haven't already done this, wildcards (*name*, *name, name*) would be useful in your wnd.Find.

Thanks, Les Caudle
Christian Studer   2002-01-13 01:12
Works fine here, using VB6 SP5 Enterprise edition.

I'm using Spy++ (included with Visual C++) to get window class names etc. A much simpler tool, Spy, is included in the Platform SDK.

Support for wildcards in Window.Find will be considered for one of the next releases.

Christian Studer - www.realtimesoft.com
Les Caudle   2002-01-13 05:08
I had Spy++ on my system, just what I was looking for. I'm running VS Ent SP3 (sp5 causes a lot of crashes in VB when I've tried it).

The class is certainly correct - and Spy found no other windows with wndclass_desked_gsk.

With VB6 running, I can run the following code:

Set wnd = CreateObject("UltraMon.Window")
If wnd.Find("", "wndclass_desked_gsk", FINDWND_CLASS, 0, 5000) = True Then
MsgBox "found it" & wnd.title & " left = " & wnd.left
wnd.left = - 800
wnd.ShowState = SHOWSTATE_NORMAL
wnd.ApplyChanges 0
End If

VB6 doesn't move, but whatever I set the wnd.left to, that is what shows up in the msgbox. I change the value, then next time I run it, I get back that value. It is moving something, just not the visible window. I'm running in the MDI development environment (I have the SDI Development environment unchecked).

I'm confused.

Also, there is no wnd.title displaying in the msgbox at all.

Thanks, Les Caudle
Christian Studer   2002-01-13 05:28
I have uploaded a little test program, FindWndTest.zip. Please let me know if it displays the same HWND and title for the VB6 window as Spy++.

Christian Studer - www.realtimesoft.com
Les Caudle   2002-01-14 04:47
Your routine displays the same HWND and caption as found in spy++.

If I search for the "wndclass_desked_gsk" using ultraMon, the wnd.hWnd returns a differnet hWnd - and no wnd.title.

Thanks, Les Caudle
Christian Studer   2002-01-14 06:28
I have uploaded a new FindWndTest, please run it and let me know what happens. This new version does both an exact match and a 'begins with' match for all top-level windows.

Christian Studer - www.realtimesoft.com
Les Caudle   2002-01-14 08:01
It says: exact match for wndclass_desked_gsk: HWND = 0xE00B6, caption = Project 1 - Microsoft VB...

It essentially shows the same thing as the last FndWndTest - just worded a little differently - shows the same HWND - but different than the one that UltraMon finds.

Thanks, Les Caudle
Christian Studer   2002-01-15 11:10
Not sure what's going wrong here, if possible I would like to do a remote debug session over the Internet.

This would take approximately 1 hour. Please contact me by e-mail if you would like to do this.

Christian Studer - www.realtimesoft.com
Christian Studer   2002-01-17 01:20
The problem has been resolved, it was caused by an incorrectly defined constant.

If you don't want to manually define constants in script files, try using .wsf (Windows Script File) files.

Following is a sample script using the <reference> tag to import the UltraMon type library, which gives you access to all constants:

<job>
<reference object="UltraMon.System" />
<object id="wnd" progid="UltraMon.Window" />
<script language="VBScript">
If wnd.Find("", "wndclass_desked_gsk", FINDWND_CLASS, 0, 1000) = True Then
MsgBox "Found VB6 window: Title = " & wnd.Title & ", HWND = 0x" & Hex(wnd.HWnd)
Else
MsgBox "Didn't find VB6 window"
End If
</script>
</job>

Christian Studer - www.realtimesoft.com
rob   2002-10-05 12:17
Don't understand why you didn't make an addin to vb to excute script.

Rob
Forums -> UltraMon™ SDK -> VB6 does not seem to be affected by positioning

Post Reply