Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

How to properly use IE object's ClientToWindow method?

$
0
0
I'm trying to resize the window with ClientToWindow so that the client area is 640x480. But no matter what I do it seems that me call to ClientToWindow is seemingly being ignored because the size isn't changing. The entire window, (including the border), is 640x480, but that is the size I need the client area to be, (as in - not including the window border).

Anyone know why my code isn't doing that and what I need to change to get it doing what I need along these lines?

Here's what I have currently, while I have tried other things, this is the only thing I could find that didn't throw a type error, (because ClientToWindow's parameters need to be Long's).

Code:

Set Screen = CreateObject("InternetExplorer.Application")
Screen.FullScreen = True
Screen.TheaterMode = True
ScreenWidth = Screen.Width
ScreenHeight = Screen.Height
Screen.Quit

Set objShell = CreateObject("WScript.Shell")
Set objIE = CreateObject("InternetExplorer.Application")

Sub CheckEscKey

    If objIE.document.parentWindow.event.keycode = 27 Then bEsc = True

End Sub

With objIE

    .FullScreen = False
    .TheaterMode = False
    .MenuBar = False
    .StatusBar = False
    .ToolBar = False
    .Resizable = False
    .Width = 640
    .Height = 480
    .ClientToWindow .Width, .Height
    .Left = (ScreenWidth / 2) - (.Width / 2)
    .Top = (ScreenHeight / 2) - (.Height / 2)
    .Navigate "http://www.yoyogames.com/"
    .Visible = True

    Set Processes = GetObject("winmgmts:").InstancesOf("Win32_Process")

    intProcessId = ""

    For Each Process In Processes
   
        If StrComp(Process.Name, "iexplore.exe", vbTextCompare) = 0 Then
       
            intProcessId = Process.ProcessId
            Exit For
   
        End If

    Next

    If Len(intProcessId) > 0 Then
   
        objShell.AppActivate intProcessId

    End If

    If .FullScreen = True Or .TheaterMode = True Then

        Do While bEsc = False And (err.number = 0)

            Do While .Busy

                Dim dteWait
                dteWait = DateAdd("s", 0.000001, Now())

                Do Until (Now() > dteWait)
                Loop

            Loop

            Set .document.body.onkeypress = GetRef("CheckEscKey")

            For i = 1 To 100

                If (err.number <> 0) Or bEsc Then Exit Do

            Next

        Loop

        .Visible = False
        .Quit

    End If

End With

Also the only forum sections on this site I could find on VBScript are web-development related VBScript, but what I'm working with is a local *.VBS file that I intend to convert to a "native" application, (using that term very loosely), with Microsoft Script Control. So anyway the point I said that, if this is in the wrong section feel free to move it into a better fit and I'll know where to post stuff like this in the future.

Thanks!
Samuel

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>