Solved

destroy/close childwindow

Posted on 1998-11-04
12
293 Views
Last Modified: 2010-04-30
I am using MS Access and the SetParent API call. I use SetParent to make a window (it actually is an executing mpg-file that was executed by mcisendstring function) the child of MS Access MDI.
At this point everything is ok. BUT: when I close MS Access while the mpg-file is still running, then MS Access closes indeed but short after that an MS Access fatal exception error is displayed.

I suspect this to be the result of the mci-object trying to continue to play while the window already has been closed (along with MS Access being its parent).

I need to know how I can properly close the childwindow. However, after the window becomes a child of MS Access, I can't find the hwnd using FindWindow function. So I don't know how to close/destroy it. Any suggestions?

Best regards,
kulikuli
0
Comment
Question by:kulikuli
  • 6
  • 4
  • 2
12 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1443106
Before the call of SetParent, store the HWND of the future window child. When you close your application, send a WM_Close message to close the child.
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1443107
hwnd property might be subjected to changes. Since it is an index-like identification the property is not guaranteed to contain the same value
0
 
LVL 14

Expert Comment

by:waty
ID: 1443108
Where did you see that the hwnd could change? The Hwnd will change only if you destroy and recreate the window. So long your window will stay alive, your Hwnd will stay valid an will identify this window.
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 40 total points
ID: 1443109
Use findwindowex. FindWindowEx allows you to find within a parent window.
In  your case first find the Access window and then find your child window. Use the Access window handle as parameter hwnd1.
Make sure that the classname of the window is right.


Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

0
 
LVL 5

Author Comment

by:kulikuli
ID: 1443110
Waty, this behavior is documented in several Help-files (in the MS Access helpfile for sure, but I believe it also is in the VB Help-file)
Mirkwood, I'll try your solution. However, I may need some an example. As I take a quick look at the API, I wonder how to get the child window since I don't know the hwnd property.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1443111
First do a findwindow to find the Access main window.
Now do a findwindowex to find the MDI child.

Here is a sample that finds the edit box inside internet explorer.

   hwndexpl = FindWindow("IEFrame", 0)   ' Find Internet Explorer
    hwndsizerebar = FindWindowEx(hwndexpl, 0,   "SizableReBar", "")    ' Find the sizable rebar toolbar control
    hwndrebar = FindWindowEx(hwndsizerebar, 0, "ReBarWindow32", "") ' Find the rebar toolbar control
    hwndcomboex = FindWindowEx(hwndrebar, 0, "ComboBoxEx32", "")  ' Find the extended combobox control on the toolbar
    hwndcombo = FindWindowEx(hwndcomboex, 0, "ComboBox", "")  ' Find the combobox control with the extended combo
    hwndedit = FindWindowEx(hwndcombo, 0, "Edit", "") 'Find the editbox within the combobox

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Author Comment

by:kulikuli
ID: 1443112
I seem required to know 1 more thing: How can I retreive the class name and does the class name change after it has become a child?
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1443113
No a class name of a window never expires. The class name is defined when a window is created during design time and will always be the same.
So use a utility like spy32.

I can give u the following class names.
The access main window class is "OMain"
The mdi window name is "MDIClient"
And the database windows is "ODb"
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1443114
It took me a lot of time to retreive spy32 from the Internet. Now that I got it: it seems to be a utility to monitor users' actions. It seems to me it is more like an administrator tool on a network. How should it be used for a purpose like retreiving the class name of a window?
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1443115
I got spy32.zip from the net. When I take a look at its readme.txt file it says this software is called 'Omnicad Desktop Serveillance 98'. I got some feeling I got the wrong file (about 5 meg). If this is the wrong file, could you send me in the right direction to find the correct one?

Best regards,
kulikuli
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1443116
Spy is a microsoft product. So the microsoft site is a good starting point.
0
 
LVL 5

Author Comment

by:kulikuli
ID: 1443117
I received the C++ Spy program in my email box. I suppose it was you who sent it (the email identity differs from your experts-identity). Thank you very much. I will go after the controls you asked for. Of course I'll grade you Excellent.

Best regards,
me
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now