Results 1 to 1 of 1

Thread: How to properly use IE object's ClientToWindow method?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2018
    Posts
    16

    How to properly use IE object's ClientToWindow method?

    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
    Thanks!
    Samuel
    Last edited by Samuel Venable; Jan 26th, 2018 at 08:40 PM. Reason: removed fluff

Posting Permissions

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



Click Here to Expand Forum to Full Width