473,324 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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 2810
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.