473,472 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CPropertySheet problem

Hi all,

We have a property sheet that is created in one dll, and on that property
sheet, there is a property page that is created in another dll. So, the
property sheet and the property page come from different module states. Now,
in CPropertySheet::OnKickIdle(), it calls GetActivePage(), which then sends a
message in order to get the handle to the active page. Given the handle, it
then calls CWnd::FromHandle() to get the pointer to the CPropertyPage. The
problem is that the CPropertyPage was initialized in a different module state
than the CPropertySheet, and so the map of handles-to-pointers does not
include the property page. Since the handle is not found in the map, MFC
creates a temporary CWnd object and gives us that back. But this object isn't
a CPropertyPage, and so GetActivePage() fails. I can think of three
possibilities here...

(1) Creating a page in one dll and adding it to a sheet in another dll is
not legal/supported, and so we shouldn't even try to do it,

(2) The code in CPropertySheet should not do a FromHandle() because that is
assuming that we are in the correct module state for the active page,

(3) There is something else we have to do to make this work.

--
Thanks much
Saran
Nov 17 '05 #1
2 2815
Saran wrote:
Hi all,

We have a property sheet that is created in one dll, and on that property
sheet, there is a property page that is created in another dll. So, the
property sheet and the property page come from different module states. Now,
in CPropertySheet::OnKickIdle(), it calls GetActivePage(), which then sends a
message in order to get the handle to the active page. Given the handle, it
then calls CWnd::FromHandle() to get the pointer to the CPropertyPage. The
problem is that the CPropertyPage was initialized in a different module state
than the CPropertySheet, and so the map of handles-to-pointers does not
include the property page. Since the handle is not found in the map, MFC
creates a temporary CWnd object and gives us that back. But this object isn't
a CPropertyPage, and so GetActivePage() fails. I can think of three
possibilities here...

(1) Creating a page in one dll and adding it to a sheet in another dll is
not legal/supported, and so we shouldn't even try to do it,

(2) The code in CPropertySheet should not do a FromHandle() because that is
assuming that we are in the correct module state for the active page,

(3) There is something else we have to do to make this work.


Is there any chance you can use extension DLLs? I've written many MFC
extension DLLs, and I've never once worried about module state. I do define
resource ranges for each DLL and adhere to them when I create their
resources. You can create a sample MFC EXE project and note where the
various resource IDs begin; your extension DLL ID space then would start
substantially beyond those IDs. To avoid stepping on MFC's ID space, see
these tech notes:

TN020: ID Naming and Numbering Conventions
http://msdn.microsoft.com/library/de...OTES_TN020.asp

TN033: DLL Version of MFC
http://msdn.microsoft.com/library/de...OTES_TN033.asp

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #2
Hi Doug-

I can't use extension DLLs. I am dealing with large applications which can
be configured differently, and so we have to keep some code in separate
top-level dlls. So, this brings me back to where I started. Either:

(1) Microsoft does not intend CPropertySheets to own CPropertyPages whose
resources come from different module states, or

(2) CPropertySheet should not be calling FromHandle the way it currently is,
or

(3) There is some trick to get this to work...

Thanks
Saran

"Doug Harrison [MVP]" wrote:
Saran wrote:
Hi all,

We have a property sheet that is created in one dll, and on that property
sheet, there is a property page that is created in another dll. So, the
property sheet and the property page come from different module states. Now,
in CPropertySheet::OnKickIdle(), it calls GetActivePage(), which then sends a
message in order to get the handle to the active page. Given the handle, it
then calls CWnd::FromHandle() to get the pointer to the CPropertyPage. The
problem is that the CPropertyPage was initialized in a different module state
than the CPropertySheet, and so the map of handles-to-pointers does not
include the property page. Since the handle is not found in the map, MFC
creates a temporary CWnd object and gives us that back. But this object isn't
a CPropertyPage, and so GetActivePage() fails. I can think of three
possibilities here...

(1) Creating a page in one dll and adding it to a sheet in another dll is
not legal/supported, and so we shouldn't even try to do it,

(2) The code in CPropertySheet should not do a FromHandle() because that is
assuming that we are in the correct module state for the active page,

(3) There is something else we have to do to make this work.


Is there any chance you can use extension DLLs? I've written many MFC
extension DLLs, and I've never once worried about module state. I do define
resource ranges for each DLL and adhere to them when I create their
resources. You can create a sample MFC EXE project and note where the
various resource IDs begin; your extension DLL ID space then would start
substantially beyond those IDs. To avoid stepping on MFC's ID space, see
these tech notes:

TN020: ID Naming and Numbering Conventions
http://msdn.microsoft.com/library/de...OTES_TN020.asp

TN033: DLL Version of MFC
http://msdn.microsoft.com/library/de...OTES_TN033.asp

--
Doug Harrison
Microsoft MVP - Visual C++

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
2
by: Stephen | last post by:
Hi, I have created a NON-MODULE CPropertySheet in a form. And I have added several CPropertyPage to the sheet. There's a runtime error where I call SetWindowText of CProertyPage which is not...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
1
by: Krish | last post by:
hi all, In my application I use Cpropertysheet to create tabs.... I am having OK,CANCEL,HELP buttons in that window... i am not able to move the control over Help button using -> arrow key...I am...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
2
by: asuna | last post by:
I have a class extends CPropertyPage, I want to add a button in this page, for jumping to another CPropertyPage. But how can I get a pointer of CPropertySheet? Then I can use the SetActivePage()....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.