Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ATL property page

Posted on 2002-07-22
7
Medium Priority
?
405 Views
Last Modified: 2013-11-25
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?

0
Comment
Question by:johndixson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 13

Expert Comment

by:John Mc Hale
ID: 7170661
Assuming that you are using CPropertyPage as a base class for your property page, the OnSetActive() and OnKillActive() methods should be called by the framework when your page activates/de-activates, so it should be straightforward to implement your code by over-riding these methods, ensuring to call the base class implementations.

class CMyPropertyPage: public CPropertyPage{

//
virtual BOOL OnSetActive()
//
};

BOOL CMyPropertyPage::OnSetActive()
{
BOOL bResult
// call base method
bResult = CPropertyPage::OnSetActive();
// your code to poll hardware, set timers etc.
return bResult
}

0
 
LVL 9

Accepted Solution

by:
BeyondWu earned 800 total points
ID: 7170879
When a property page is about to be activated/deactivated, it will send PSN_SETACTIVE/PSN_KILLACTIVE notify message, you can simple handle the WM_NOTIFY message in the parent window just like following code;

case WM_NOTIFY:
     switch(((NMHDR FAR *)lParam)->code)
     {
        case PSN_SETACTIVE:
        {
            // you can also check (((NMHDR FAR *)lParam)->idFrom or hwndFrom
            // to check which page send this notify msg.
            // ... do something ...
        }
        case PSN_KILLACTIVE:
        {
            // ...
        }
     }
0
 
LVL 22

Expert Comment

by:ambience
ID: 7170950
perhaps you can also look into, IPropertPage::Show, if this applies at all ..
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Author Comment

by:johndixson
ID: 7171961
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.


0
 
LVL 9

Expert Comment

by:BeyondWu
ID: 7173358
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_WNDPROC, 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_KILLACTIVE to the parent, it only send TCN_SELCHANGE/TCN_SELCHANGING/NM_CLICK message to the parent, but it's enough for you.

Good Luck.
0
 
LVL 11

Expert Comment

by:griessh
ID: 7378404
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
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7420015
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

670 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