[AccessD] Access Lockdown

Jim Dettman jimdettman at verizon.net
Mon May 23 13:05:29 CDT 2011


 Not this specifically no, but I play around with the Windows API stuff when
I get the chance.  Right now I'm working on two things:

1. How to change the main Access window in 2007 & up.

2. How to make a form dockable (or at least simulate it).

  To do that I have a bunch of generic routines to poke around under the
hood. Couple that with Process Explorer and it's amazing some of the stuff
you can do or manipulate.  But it's more of a hobby thing for me and I
usually get myself in more trouble then it's worth<g>.

  What started this is seeing "Printing on the Fly" by ATTAC Consulting
years ago; I was simply amazed what they could do with API calls from within
Access/VBA (hiding the properties dialog is what originally caught my eye).
That and I've always wanted to get into systems programming.

 BTW, I tripped over this today looking for something else, which is really
cool and will be interesting to everyone I'm sure (watch the wrap):

http://blog.nkadesign.com/2008/ms-access-modal-dialogs-with-transparent-back
grounds/

Jim. 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Monday, May 23, 2011 11:22 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Access Lockdown

Holy cow!  It would appear that you have done this stuff?

John W. Colby
www.ColbyConsulting.com

On 5/23/2011 10:57 AM, Jim Dettman wrote:
> <<What I want to know is how does he figure out the name of the objects?
> for example...>>
>
>
> One way is to enumerate all the child windows when something is running:
>
> Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As
Long,
> _
>      ByVal lParam As Long) As Long
> Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent
As
> _
>      Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
>
> Declare Function GetWindowTextLength Lib "user32.dll" Alias
> "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
> Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA"
> (ByVal hWnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As
> Long
> Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA"
(ByVal
> hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As
Long
>
> ' The following variables are shared between the main ChildWindows
procedure
> ' and the auxiliary (private) ChildWindows_CBK routine
>
> ' An array of Long holding the handle of all child windows.
> Dim windows() As Long
> ' The number of elements in the array.
> Dim windowsCount As Long
>
>
>
>
> Sub getWindows()
>
>     Dim lnghwnd As Long
>
>     lnghwnd = CLng(Application.hWndAccessApp)
>
>     Debug.Print ChildWindows(lnghwnd)
>
> End Sub
>
>
> ' Return an array of Long holding the handles of all the child windows
> ' of a given window. If hWnd = 0 it returns all the top-level windows.
>
> Function ChildWindows(ByVal hWnd As Long)
>      windowsCount = 0
>      If hWnd Then
>          EnumChildWindows hWnd, AddressOf EnumWindows_CBK, 1
>      Else
>          EnumWindows AddressOf EnumWindows_CBK, 1
>      End If
>      ' Trim uninitialized elements and return to caller.
>      ReDim Preserve windows(windowsCount) As Long
>
> End Function
>
> ' The callback routine, common to both EnumWindows and EnumChildWindows.
>
> Private Function EnumWindows_CBK(ByVal hWnd As Long, ByVal lParam As Long)
> As _
>      Long
>
>      Dim slength As Long
>      Dim buffer As String
>      Dim retval As Variant
>      Dim classname As String
>
>      ' Make room in the array, if necessary.
>      If windowsCount = 0 Then
>          ReDim windows(100) As Long
>      ElseIf windowsCount>= UBound(windows) Then
>          ReDim Preserve windows(windowsCount + 100) As Long
>      End If
>      ' Store the new item.
>      windowsCount = windowsCount + 1
>      windows(windowsCount) = hWnd
>    slength = GetWindowTextLength(hWnd) + 1  ' get length of title bar text
>    buffer = Space(slength)  ' make room in the buffer
>    retval = GetWindowText(hWnd, buffer, slength)  ' get title bar text
>    Debug.Print "Window #"; windowsCount  ' display number of enumerated
> window
>    Debug.Print "Handle: "; hWnd
>    Debug.Print ; "Title:"; Left(buffer, slength - 1) ' display title bar
text
> of enumerated window
>    classname = Space(255)
>    slength = GetClassName(hWnd, classname, 255)
>    classname = Left(classname, slength)  ' remove empty space
>    Debug.Print ; "Class: "; classname
>    Debug.Print
>
>      ' Return 1 to continue enumeration.
>      EnumWindows_CBK = 1
> End Function
>
>
> <<snip>>
>
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list