PC Review


Reply
Thread Tools Rate Thread

Any help in using this Code....

 
 
=?Utf-8?B?SHVzYW0=?=
Guest
Posts: n/a
 
      17th Mar 2005
Hi EveryBody:

I have the following code which just helpfull with Notepad:

Code:
<DllImport("user32", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function FindWindow(ByVal lpClassName As String, ByVal
lpWindowName As String) As Integer
'
End Function
<DllImport("user32", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function SendMessage(ByVal hwnd As Int32, ByVal wMsg As
Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
'
End Function
Private Const WM_CLOSE = &H10

Under button I put:

Dim intHandle As Integer = FindWindow("Notepad", vbNullString)
If intHandle > 0 Then
SendMessage(intHandle, WM_CLOSE, 0, 0)
End If

So I want to use this code to close the internet explorer,So i put Microsoft
Internet Explorer instaed of Notepad but it does not work and I put WordPad
instaed of Notepad also it does not work,how can I do that ?

any help will be appreciated

Husam
 
Reply With Quote
 
 
 
 
Michael D. Ober
Guest
Posts: n/a
 
      17th Mar 2005
FindWindow can only find those windows that have window text (Captions) that
match your search string. You would be better off using EnumWindows to
search for internet explorer By using EnumWindows, you can search for the
words "Internet Explorer" anywhere in the window text..

Mike Ober.

"Husam" <(E-Mail Removed)> wrote in message
news:1724F2E2-CCBE-427A-9C62-(E-Mail Removed)...
> Hi EveryBody:
>
> I have the following code which just helpfull with Notepad:
>
> Code:
> <DllImport("user32", CharSet:=CharSet.Auto, SetLastError:=True)> _
> Public Shared Function FindWindow(ByVal lpClassName As String, ByVal
> lpWindowName As String) As Integer
> '
> End Function
> <DllImport("user32", CharSet:=CharSet.Auto, SetLastError:=True)> _
> Public Shared Function SendMessage(ByVal hwnd As Int32, ByVal wMsg

As
> Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
> '
> End Function
> Private Const WM_CLOSE = &H10
>
> Under button I put:
>
> Dim intHandle As Integer = FindWindow("Notepad", vbNullString)
> If intHandle > 0 Then
> SendMessage(intHandle, WM_CLOSE, 0, 0)
> End If
>
> So I want to use this code to close the internet explorer,So i put

Microsoft
> Internet Explorer instaed of Notepad but it does not work and I put

WordPad
> instaed of Notepad also it does not work,how can I do that ?
>
> any help will be appreciated
>
> Husam
>




 
Reply With Quote
 
=?Utf-8?B?Q3JvdWNoaWUxOTk4?=
Guest
Posts: n/a
 
      17th Mar 2005
That's my code I posted:

Internet Explorer's class name is 'IEFrame'

To close it you need to use PostMessage & not SendMessage:

Declarations:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA"
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal
lParam As Integer) As Integer

Private Const WM_CLOSE = &H10

' Behind a button:

Dim intHandle As Integer = FindWindow("IEFrame", vbNullString)
If intHandle > 0 Then
PostMessage(intHandle, WM_CLOSE, 0&, 0&)
End If

I hope this helps
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linq to XML--Are there code examples that make Linq as easy as SQL? Or how can I convert ths simple pseudo code into real code? Reece Microsoft C# .NET 4 10th Dec 2008 03:13 AM
ATI Radeon Drivers - Code 43, Code 37 & Code 10 =?Utf-8?B?SmFrZQ==?= Windows Vista Hardware 14 29th Aug 2006 05:50 AM
ATI Display Drivers - Code 43, Code 37, Code 10 Jake Windows Vista Hardware 2 8th Jul 2006 04:00 PM
what is the difference between code inside a <script> tag and code in the code-behind file? keithb Microsoft ASP .NET 1 29th Mar 2006 02:00 AM
[New] Zipoid - ZIP Code, City Name and Area Code Lookup - Zip Code to Zip Code Distance Calculation Mel Freeware 0 22nd Jul 2005 04:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:51 PM.