johndixson
asked on
ATL property page
I need to enable a timer and poll some hardware when a property page of an ATL component is active. I need to disable this timer when the property page is no longer the active property page.
The MFC CPropertyPage class has two Overridables that are called OnSetActive(), OnKillActive() when the page is activated or deactivated. This is exactly what I want to implement on my components propery page.
I have added a windows message handler for WM_SHOWWINDOW but it is called only once when the property page is first created, but never again when the page is deactivated or re-activated.
My question is how can you determine when the property page is activated or deactivated?
The MFC CPropertyPage class has two Overridables that are called OnSetActive(), OnKillActive() when the page is activated or deactivated. This is exactly what I want to implement on my components propery page.
I have added a windows message handler for WM_SHOWWINDOW but it is called only once when the property page is first created, but never again when the page is deactivated or re-activated.
My question is how can you determine when the property page is activated or deactivated?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
perhaps you can also look into, IPropertPage::Show, if this applies at all ..
ASKER
Fredthered, this is ActiveX control written using the ATL (I hate the overheard that MFC imposes). Therefore CPropertyPage is not used it's the IPropertyPageImpl interface.
BeyondWu, the WM_NOTIFY message cannot be used because it's handled by the property frame created through the OleCreatePropertyFrame() function.
Ambience, I have tried 'Show' but beleive it or not it's only called once when the property page is first created. And never again when changing property pages.
BeyondWu, the WM_NOTIFY message cannot be used because it's handled by the property frame created through the OleCreatePropertyFrame() function.
Ambience, I have tried 'Show' but beleive it or not it's only called once when the property page is first created. And never again when changing property pages.
Oh, I misunderstand your question.:O(
It depend on how the OleCreatePropertyFrame implemented, it seems there no interface can be used by you. I have tested to get IOleWindow or other Infterface which can get the window handle from IPropertyPageSite, but failed:O(
I think the OleCreatePropertyFrame implement with SysTabControl32, so I think there two method you can use.
1. Don't use OleCreatePropertyFrame, implement your own IPropertyPageSite, then you can do everything.
2. When initialization, the OleCreatePropertyFrame will call IPropertyPage::Activate, it will pass a HWND hWndParent, It's actually an dialogbox, you can get it's parent window through it, know you get the HWND of the OleCreatePropertyFrame's window, now you can subclass it with SetWindowLong(..GWL_WNDPRO C, NewWinProc, ..); then in the NewWinProc, you can handle the WM_NOTIFY message just as I said above.
It seems hasn't send PSN_SETACTIVE/PSN_KILLACTI VE to the parent, it only send TCN_SELCHANGE/TCN_SELCHANG ING/NM_CLI CK message to the parent, but it's enough for you.
Good Luck.
It depend on how the OleCreatePropertyFrame implemented, it seems there no interface can be used by you. I have tested to get IOleWindow or other Infterface which can get the window handle from IPropertyPageSite, but failed:O(
I think the OleCreatePropertyFrame implement with SysTabControl32, so I think there two method you can use.
1. Don't use OleCreatePropertyFrame, implement your own IPropertyPageSite, then you can do everything.
2. When initialization, the OleCreatePropertyFrame will call IPropertyPage::Activate, it will pass a HWND hWndParent, It's actually an dialogbox, you can get it's parent window through it, know you get the HWND of the OleCreatePropertyFrame's window, now you can subclass it with SetWindowLong(..GWL_WNDPRO
It seems hasn't send PSN_SETACTIVE/PSN_KILLACTI
Good Luck.
Dear johndixson
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity, I will suggest to accept
"BeyondWu"
comment(s) as an answer.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity, I will suggest to accept
"BeyondWu"
comment(s) as an answer.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Force accepted
** Mindphaser - Community Support Moderator **
** Mindphaser - Community Support Moderator **
class CMyPropertyPage: public CPropertyPage{
//
virtual BOOL OnSetActive()
//
};
BOOL CMyPropertyPage::OnSetActi
{
BOOL bResult
// call base method
bResult = CPropertyPage::OnSetActive
// your code to poll hardware, set timers etc.
return bResult
}