Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Renaming Access Window: FindWindow() too good!!!

99 views
Skip to first unread message

Gregor Hagedorn

unread,
Aug 10, 1995, 3:00:00 AM8/10/95
to
nsar...@mround.bt.co.uk (Pyro Teknik) wrote:

>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!


Pyro Teknik

unread,
Aug 10, 1995, 3:00:00 AM8/10/95
to
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

Weiqi Gao

unread,
Aug 10, 1995, 3:00:00 AM8/10/95
to
In article <40cd0v$c...@pheidippides.axion.bt.co.uk>,
nsar...@mround.bt.co.uk says...

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


Trevor Best

unread,
Aug 10, 1995, 3:00:00 AM8/10/95
to
nsar...@mround.bt.co.uk (Pyro Teknik) wrote:

>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 Hills

unread,
Aug 10, 1995, 3:00:00 AM8/10/95
to

In article <40cd0v$c...@pheidippides.axion.bt.co.uk>, Pyro Teknik (nsar...@mround.bt.co.uk) writes:
>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
>
In the first place you can set it it in the .ini file
TitleBar="caption" in the [Run-Time Options] section. This is
easier but a one-off i.e you can't change it dynamically.
If you use the API call GetActiveWindow() this should give you the
current copy, or an mdi child. If the class name for the hWnd
returned by GetActiveWindow() is not 'OMAIN' then you have a mdi
child and need to use the GetParent call to get the main access
window, which will be the one you want.

Lyndon


Jay Eskandarian

unread,
Aug 11, 1995, 3:00:00 AM8/11/95
to nsar...@mround.bt.co.uk
Use the function below and pass it any string...

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


0 new messages