dbTalk Databases Forums  

Maximizin Access Window

comp.databases.ms-access comp.databases.ms-access


Discuss Maximizin Access Window in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Jon Lewis
 
Posts: n/a

Default Re: Maximizin Access Window - 11-22-2010 , 07:45 AM






"It occurs to me that the code will find the handle for any Access
application open so you may want to compare the returns from fGetcaption to
make sure it's the relevant one."

This is what I suggested 2 posts ago - did you do this? (I assumed that you
would be able to write appropriate code)

I posted the fGetcaption code but assumed that you would include what you
needed in the main routine to compare the return from this function to (in
your case) whatever the title is of your "Clubs" db is to ensure you get the
handle to another instance of "Clubs" and not just any open db.

Jon



"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 22/11/2010 09:03:18, "Jon Lewis" wrote:
Well doesn't my post above cover this?

Jon

"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in message
news:ic6uq1$18n$1 (AT) speranza (DOT) aioe.org...
Hi Jon
Thought it was working, but no lock

Here is the code

Function fEnumWindows()

Dim lngx As Long, lngLen As Long
Dim lngStyle As Long, strCaption As String
Dim Otherhwnd As Long

lngx = apiGetDesktopWindow()
'Return the first child to Desktop
lngx = apiGetWindow(lngx, mcGWCHILD)

Do While Not lngx = 0
strCaption = fGetCaption(lngx)
If Len(strCaption) > 0 Then
lngStyle = apiGetWindowLong(lngx, mcGWLSTYLE)
'enum visible windows only
If fGetClassName(lngx) = "OMain" Then ' Databases
If lngStyle And mcWSVISIBLE Then
Debug.Print "Class = " & fGetClassName(lngx),
Debug.Print "Caption = " & fGetCaption(lngx),
Otherhwnd Otherhwnd = apiFindWindow(fGetClassName(lngx),
fGetCaption(lngx))
Debug.Print "OtherDb = " & Otherhwnd
Debug.Print "ThisDb = " & GetAccesshWnd()

'******** 'OMain is the class name of a main Access window so if this
Window
's handle ********** '******** 'differs from your hWndAccessApp then
lngX
is
the handle you want***************** If lngx <> hWndAccessApp Then
SendMessage lngx, SW_SHOWMAXIMIZED, 0, 0
Application.Quit
End If
End If
End If
End If
lngx = apiGetWindow(lngx, mcGWHWNDNEXT)
Loop

End Function

Problem is that if any other Access DB is open, this DB (Clubs)
immediately
quits. The duff line is If lngx <> hWndAccessApp
Then
I Only want to quit the application if someone tries to open up a second
copy
of the Clubs database

Thanks, Phil




Hi Jon

Have pasted your code in exactly as your previous post. This is in my
"Clubs"
Db. If I have my "Questions" Db open, then try to open my "Clubs" Db, it
opens and immediately closes.

if I comment out the Application'Quit line, the debug gives me

Class = OMain Caption = WFYC Club DB Phil 0
OtherDb = 788380
ThisDb = 788380
Class = OMain Caption = Microsoft Access - Questionnaire : Database
(Access
2007) 788380 OtherDb = 852634

Any further thoughts?

Thanks,
Phil

Reply With Quote
  #12  
Old   
Phil
 
Posts: n/a

Default Re: Maximizin Access Window - 11-22-2010 , 10:07 AM






On 22/11/2010 13:45:41, "Jon Lewis" wrote:
Quote:
"It occurs to me that the code will find the handle for any Access
application open so you may want to compare the returns from fGetcaption
to make sure it's the relevant one."

This is what I suggested 2 posts ago - did you do this? (I assumed that
you would be able to write appropriate code)

I posted the fGetcaption code but assumed that you would include what you
needed in the main routine to compare the return from this function to (in
your case) whatever the title is of your "Clubs" db is to ensure you get
the handle to another instance of "Clubs" and not just any open db.

Jon

Thanks Jon, all sorted now, and working perfectly

Phil

Reply With Quote
  #13  
Old   
Jon Lewis
 
Posts: n/a

Default Re: Maximizin Access Window - 11-22-2010 , 01:36 PM



You're welcome and for anyone who sees this thread in the future the call to
SendMessage is a mistake - it should be to ShowWindow

Jon

"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 22/11/2010 13:45:41, "Jon Lewis" wrote:
"It occurs to me that the code will find the handle for any Access
application open so you may want to compare the returns from fGetcaption
to make sure it's the relevant one."

This is what I suggested 2 posts ago - did you do this? (I assumed that
you would be able to write appropriate code)

I posted the fGetcaption code but assumed that you would include what you
needed in the main routine to compare the return from this function to
(in
your case) whatever the title is of your "Clubs" db is to ensure you get
the handle to another instance of "Clubs" and not just any open db.

Jon

Thanks Jon, all sorted now, and working perfectly

Phil

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.