?
Solved

hWndAccessApp in .Net

Posted on 2010-04-02
8
Medium Priority
?
1,073 Views
Last Modified: 2013-11-08
How can I change vb code with hWndAccessApp
to VB Dot Net code ?

what is the command that replace hWndAccessApp
0
Comment
Question by:DoronAviad
  • 3
  • 3
  • 2
8 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 29797092
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?
0
 

Author Comment

by:DoronAviad
ID: 29877640
There are some API that neeed the application hWnd
How can I return it from Dor Net VB Forms ?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 29887240
There is a Handle property on forms.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:DoronAviad
ID: 32686944
Sorry I need the hWnd
Can you please show me code example
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 32687573
If you need to find a window handle, then you can use FindWindow API call.

FindWindow (user32)
http://www.pinvoke.net/default.aspx/user32.FindWindow


'// 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!")
Else
    hWnd = FindWindowEx(ParenthWnd, hWnd, lpszClass, "")

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

Open in new window

0
 

Author Comment

by:DoronAviad
ID: 32695035
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 ?

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 32695315
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.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 32695380
You can use the Me.Handle.ToInt32 or Me.Handle.ToInt64 methods to convert to hwnd.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses
Course of the Month5 days, 22 hours left to enroll

589 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