hWndAccessApp in .Net

How can I change vb code with hWndAccessApp
to VB Dot Net code ?

what is the command that replace hWndAccessApp
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
I don't understand your question.  hWndAccessApp is a VBA command to get a handle to the main Access window.  What is the context for this question?  What do you need the main window handle?  Are you using Access COM interop?
DoronAviadCEOAuthor Commented:
There are some API that neeed the application hWnd
How can I return it from Dor Net VB Forms ?
There is a Handle property on forms.
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

DoronAviadCEOAuthor Commented:
Sorry I need the hWnd
Can you please show me code example
Bob LearnedCommented:
If you need to find a window handle, then you can use FindWindow API call.

FindWindow (user32)

'// VB (chellios at gmail dot com)
'// Open up a blank Notepad!
Dim lpszParentClass As String = "Notepad"
Dim lpszParentWindow As String = "Untitled - Notepad"
Dim lpszClass As String = "Edit"

Dim ParenthWnd As New IntPtr(0)
Dim hWnd As New IntPtr(0)

ParenthWnd = FindWindow(lpszParentClass, lpszParentWindow)

If ParenthWnd.Equals(IntPtr.Zero) Then
    Debug.WriteLine("Notepad Not Running!")
    hWnd = FindWindowEx(ParenthWnd, hWnd, lpszClass, "")

    If hWnd.Equals(IntPtr.Zero)
       Debug.WriteLine("Notepad doesn't have an Edit component, how strange.")
       Debug.WriteLine("Notepad Window: " & ParenthWnd.ToString())
       Debug.WriteLine("Edit Control: " & hWnd.ToString())
    End If
End If

Open in new window

DoronAviadCEOAuthor Commented:
if I have Form1 in Dot Net WinForms application
How can I get the hWnd ?

How can I know the Class and Window ?, Do I need them or there is a way to get it from
Form1.handle ?

Bob LearnedCommented:
Are you talking about the window handle inside of your application, or outside?  If it is outside, you can enumerate the windows, or use something like Spy++ to examine the details of the open windows.
You can use the Me.Handle.ToInt32 or Me.Handle.ToInt64 methods to convert to hwnd.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.