>Hi,
>I made use of some excellent postings the other day to rename my access window
>with the title of my choice. Thanks to those who posted the code.
>But now I find that the routine (which makes use of the FindWindow and
>SetWindowText routines)
>can find ANY window called 'Microsoft Access' that happens to be running,
>and rename it without any problem.
You can use the handle of a form and get the parent iteratively,
or do it with the active window (assumes code is running only when the
correct instance of Access is active).
Function GetAccessHWnd () As Integer
'* Keep getting the handle of the parent, until ClassName = "OMain",
'* which is the class name of the Microsoft Access window.
'* Note this is MS implementation. Others just use:FindWindow("OMain",
0&)
'* -> problematic with multiple copies of Access!
Dim hWnd As Integer
hWnd = GetActiveWindow()
While ((GetWindowClass(hWnd) <> "OMain") And (hWnd <> 0))
hWnd = GetParent(hWnd)
Wend
GetAccessHWnd = hWnd
End Function
Gregor Hagedorn
Inst. f. Mikrobiologie, BBA Net: hage...@zedat.fu-berlin.de
Koenigin-Luise-Str. 19 Tel: +49-30-8304-295 or -279
14195 Berlin, Germany Fax: +49-30-8304-284
Often wrong but never in doubt!
But now I find that the routine (which makes use of the FindWindow and
SetWindowText routines)
can find ANY window called 'Microsoft Access' that happens to be running,
and rename it without any problem.
Can I somehow make sure it only finds the window in which it is running???
i.e. stop it from affecting other instances of Access that may be running
concurrently...
cheers,
nik
I posted the FindWindow suggestion. The post I was replying to did check
only the ancester top level window of the current window (involving
GetWindow?). I did not save it because I'm happy with all my Access windows
appear as "Ssecca Tfosorcim."
--
Weiqi Gao
>Hi,
>I made use of some excellent postings the other day to rename my access window
>with the title of my choice. Thanks to those who posted the code.
>But now I find that the routine (which makes use of the FindWindow and
>SetWindowText routines)
>can find ANY window called 'Microsoft Access' that happens to be running,
>and rename it without any problem.
>Can I somehow make sure it only finds the window in which it is running???
>i.e. stop it from affecting other instances of Access that may be running
>concurrently...
>cheers,
>nik
Maximise your current form then find "Microsoft Access - [form]" then
restore your form.
Or
If you know the current instance is the topmost window, use
GetActiveWindow() to find it, it most certainly will be if you execute
the code from AutoExec Macro.
\|||/
/ \
C + + D
-----------------ooO--u--Ooo-------------------------------
While money can't buy happiness,
it certainly lets you choose your own form of misery.
tre...@microprism.com
Microprism (UK) Limited
Lyndon
Sub ChangeAccessCaption (Caption$)
Dim x%
Dim hParent%
' Example of how to set the caption bar
Application.Echo False
DoCmd OpenForm "ControlWindow" 'Open the
main startup form
x% = forms!ControlWindow.hWnd 'Get its
handle
hParent% = GetParent(GetParent(x%)) 'Get the form'
parent
Call SetWindowText(hParent%, Caption$ & " - " &
CurrentUser())
'DoCmd Close
Application.Echo True
End Sub
--Jay