Solved

I am trying to remove all menus, titlebars, scroll bars etc from Internet Explorer and then restore them

Posted on 2011-09-25
8
380 Views
Last Modified: 2013-12-04
I am working with Win XP. I am writing this is VBA (ACCESS).
What I am trying to do, it to remove all except for the actual Internet Explore server window.
I am manipulating the web through VBA (this portion is working just fine!)
I have 7 windows that are being controlled and I want to just show the results pages, with out the other controls, as I want to make these instances as compact as possible.
I alreay have these screens zoomed out to 40%
I dont want the caption, the resize or any of it.
Just Explore server window and a frame either WS_DLGFRAME or a thin
I have tried to REMOVE by - ws_xxx in the setlong statement, I have tried to build up the complete windows I want by just the features I want and ORing them
I have tried to use OR NOT to remove from the current value, and then pusing that with the setlong.
(Where can I find how to properly use and understand ORing? How does OR and an item that has a value of 0 work????)

Here is what I have been trying to do, but it does not seem to change the results, as the GWL_Style only changes (and this is the only control I was able to remove) are for the system menu

Dim MyWindSytles As Long
's = GetSystemMenu(ieBACC.hwnd, False)
Dim z As Long, hMenu As Long

MyWindSytles = GetWindowLong(ieBACC.hwnd, GWL_STYLE)
Debug.Print GetWindowLong(ieBACC.hwnd, GWL_STYLE)
Dim myNewWin As Long

myNewWin = (MyWindSytles) Or Not WS_MINIMIZEBOX Or Not WS_MAXIMIZEBOX Or WS_VISIBLE Or WS_CLIPCHILDREN Or WS_CLIPSIBLINGS
z = SetWindowLong(ieBACC.hwnd, GWL_STYLE, MyWindSytles)
  lp2 = SetTopMostWindow(ieBACC.hwnd, True)
Debug.Print GetWindowLong(ieBACC.hwnd, GWL_STYLE)
    lp2 = SetTopMostWindow(ieBACC.hwnd, True)
         MoveWindow ieBACC.hwnd, 70, 200, 452, 418, 1
'Debug.Print DeleteMenu(hMenu, 6, 1024)

Open in new window


I would also need a way to restore it to the proper settings on exit.

Would these setting only control that ONE instance, or all sessions of IE until reset?

Some sampe code would help out a LOT!
Again, I am coding in VBA, but since I am using API, really just the calling method and declarations change (I think) for something of this nature.
Thanks
0
Comment
Question by:Bruj
  • 3
  • 3
  • 2
8 Comments
 
LVL 42

Expert Comment

by:Davis McCarn
ID: 36598776
Because those options are controlled by the user's preferences, you will train wreck their browser if you ever manage to pull it off (which; itself, will be very difficult).
However; JavaScript is the standard method to do exactly what you want and it shouldn't be hard to incorporate that into your VBA.  The function is called window.open and here are it's options: http://www.w3schools.com/jsref/met_win_open.asp
0
 

Author Comment

by:Bruj
ID: 36599759
I DONT want to wreck there settings. Thats one reason I am looking to do it through code instead of regedit (which seems to be the way most people recomend turning of the title bar. That seems like a PERMANANT tweak. I am just looking for application session life and only on the windows that my code opens.
I have not looked to much at it, but do you know if there is a way to capture the CURRENT settings so I can ensure that they are returned?
Thanks!

This does appear just what I need! (I was thinking I could control this through APIs, but had very little luck.)

 I will test and let you know. I am wondering if it may be best to create a webpage that has the script in it and then use my code to control that window.


Again Thanks!
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 36600639
I program in visual studio and you could easily create a program that has an internet explorer window using the internet explorer control it will use the local copy of internet explorer without addons. you can adjust the controls of the window as neccesary before compiling
0
 

Author Comment

by:Bruj
ID: 36718941
Is there another way besides window.open  to CHANGE the current windows settings?
Or is is possible to assign a IE object to an existing windows?

ve3ofa: How would you do this in V Studio? Not sure if it would translate, but it may help point me in the correct direction

I am using a classer wrapper for my IE object and have my app nearly finished, I just would like to clean up a few things. I cant rewrite the whole app.
Could I use window.open in my class?
Here is my initialize block:

Private Sub Class_Initialize()
    Set brs = New InternetExplorer
    brs.Visible = gbDebugMode
    Exit Sub
End Sub

Open in new window

I would think this would be the best place to make the modifications

Thanks!
Bruce
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 42

Accepted Solution

by:
Davis McCarn earned 500 total points
ID: 36720328
At some point in the process, you will always be running html to display the content.  If you spend a little time learning the Javascript coding necessary to open a new window, specify it's size and options (menubar, scroll bars, etc), you will (forever more) be able to do exactly what you want without slamming into the users permissions, browser, or preferences.
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 36814944
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class GoogleWebBrowser
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.WebBrowser1 = New System.Windows.Forms.WebBrowser()
        Me.SuspendLayout()
        '
        'WebBrowser1
        '
        Me.WebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.WebBrowser1.Location = New System.Drawing.Point(0, 0)
        Me.WebBrowser1.MinimumSize = New System.Drawing.Size(20, 20)
        Me.WebBrowser1.Name = "WebBrowser1"
        Me.WebBrowser1.Size = New System.Drawing.Size(1463, 595)
        Me.WebBrowser1.TabIndex = 0
        Me.WebBrowser1.Url = New System.Uri("http://www.google.com", System.UriKind.Absolute)
        '
        'GoogleWebBrowser
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(1463, 595)
        Me.Controls.Add(Me.WebBrowser1)
        Me.Name = "GoogleWebBrowser"
        Me.Text = "Google Web Browser"
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser
End Class

Open in new window

form1.designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class GoogleWebBrowser
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.WebBrowser1 = New System.Windows.Forms.WebBrowser()
        Me.SuspendLayout()
        '
        'WebBrowser1
        '
        Me.WebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.WebBrowser1.Location = New System.Drawing.Point(0, 0)
        Me.WebBrowser1.MinimumSize = New System.Drawing.Size(20, 20)
        Me.WebBrowser1.Name = "WebBrowser1"
        Me.WebBrowser1.Size = New System.Drawing.Size(1463, 595)
        Me.WebBrowser1.TabIndex = 0
        Me.WebBrowser1.Url = New System.Uri("http://www.google.com", System.UriKind.Absolute)
        '
        'GoogleWebBrowser
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(1463, 595)
        Me.Controls.Add(Me.WebBrowser1)
        Me.Name = "GoogleWebBrowser"
        Me.Text = "Google Web Browser"
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser
End Class

Open in new window

form1.vb

It is just so easy
Public Class GoogleWebBrowser

End Class

Open in new window

0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 36816896
another way is to use a hta
<html>
<head>
  <title>This is My Applicaton IE View</title>
  <meta http-equiv="x-ua-compatible" content="ie=9">
  <hta:application 
     id="oSample"
     applicationname="svghtasample1"
     version="1"
  </hta>
</head>

<body>

<p>Because this HTA includes an X-UA-Compatible header, 
it is displayed in IE9 Standards mode when Internet 
Explorer 9 is installed on the system.  As a result,
SVG can be used to draw a blue star.</p>     

<svg width="12cm" height="4cm" viewBox="0 0 1200 400"
     xmlns="http://www.w3.org/2000/svg" version="1.1">
  <desc>Example Star</desc>
  <polygon 
      fill="blue" stroke="blue" stroke-width="10" 
      points="350,75  379,161 469,161 397,215 423,301 
              350,250 277,301 303,215 231,161 321,161" />
</svg>
<iframe src="http://www.google.com" width="100%" height="300"> <p>Your browser does not support 

iframes.</p>
</iframe>
</body>
</html>

Open in new window

save as whatever.hta
0
 

Author Closing Comment

by:Bruj
ID: 36900807
DavisMcCarn,

Thanks very much!

Well....

Here is the CODE I came up with. (I am using classing in my application and am very far into it.. Looks a little funky, but it is working. I need to clean it up a little bit and would like to figure out a more reliable way to find the correct IE other than comparing URL. Maybe I could create a another page on local intranet and have a very specific title bar.

Private Sub Class_Initialize()
    Set brs = New InternetExplorer  'This will be the usable class object
    Set brstemp = New InternetExplorer ' This is a temp object that will be used to open the webpage that opens the real webpage with out bar, menus etc)

    brstemp.Visible = False ' Hide the IE - Just better looking
    On Error GoTo ErrTrap  ' Got to have error trapping! Right now just minimal

'Open up the webpage that opens the clean IE
    Call brstemp.Navigate("\\Cable\cal-dfs\ConcordFS1-Bay\TAC\CDV\BCDV\EAS\Tracker\OpenSmall.HTML")

'Wait for the page to finish loading
    Do While brstemp.Busy Or brstemp.ReadyState <> READYSTATE_COMPLETE
        If optActiveX Then    ' close any activex popup notifications
            PostMessage FindWindow("#32770", "Microsoft Internet Explorer"), &H10, 0&, 0&
        End If
        DoEvents
    Loop


'Create a shellswindow and test all instances of IE for the desired page. I have the temp web opening
'to a page I dont expect anybody to already have on there system running. Not the most robust way I am sure...
    Dim objSW As SHDocVw.ShellWindows
    Dim objIE As SHDocVw.InternetExplorer
    Dim objDoc As Object
    Set objSW = New SHDocVw.ShellWindows

'Loop through all IEs
    If objSW.Count Then    ' new
        For Each objIE In objSW
            If InStr(1, objIE.LocationURL, "http://msdn.microsoft.com/") Then ' this is the URL to test if I have found my temp page
'If I do find it, we will set brs (our final page) to the object
                Set brs = objIE

'We will now close to temp IE
                PostMessage brstemp.hwnd, WM_CLOSE, 0&, 0&
                Exit For
            End If
        Next objIE
    End If

'Approved by the good house keeping committee! Clean up after thyself!
    Set objIE = Nothing
    Set objSW = Nothing
    Exit Sub
ErrTrap:
    MsgBox Err.Description
    Resume
End Sub

Open in new window


Here is the code for the tempwebpage
<!-- saved from url=(0016)http://localhost -->
<!-- Need to have the above so that you will not be prompted about risks of running code in IE -->

<html>
<head>
<script type="text/javascript">
<!-- Function to actually open a new window configured with the switches (I have them all turned OFF) -->
function open_win()
{
window.open("http://msdn.microsoft.com/","_blank","toolbar=NO, location=NO, directories=no, status=no, menubar=NO, scrollbars=NO, resizable=no, copyhistory=NO, width=400, height=400");
}
</script>
</head>

<body>
<script type="text/javascript">
<!-- Run the function. Could have also been ran as  ON LOAD in the <body tag>-->
open_win();
</script>

</body>

</html>

Open in new window


To ve3ofa, Thank you very much as well! But I think there are too many unsupported features... Thanks though!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now