Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 420

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

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
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


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
Bruj
• 3
• 3
• 2
1 Solution

OwnerCommented:
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 Commented:
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

OwnerCommented:
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 Commented:
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

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

Thanks!
Bruce
0

OwnerCommented:
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

OwnerCommented:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
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.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.ResumeLayout(False)

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

form1.designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
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.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.ResumeLayout(False)

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

form1.vb

It is just so easy
Public Class GoogleWebBrowser

End Class

0

OwnerCommented:
another way is to use a hta
<html>
<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>

<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>

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

save as whatever.hta
0

Author Commented:
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")

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


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>
<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>

<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>


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

## Featured Post

• 3
• 3
• 2
Tackle projects and never again get stuck behind a technical roadblock.