|
1) CPropertySheet::GetPage(int index) will return a pointer to a CPropertyPage object, which can be cast to a specific CPropertyPage derived class pointer; e.g., CMyPage* page = (CMyPage*)MySheet->GetPage(0); .
2) Likewise, CPropertySheet::GetActivePage()will return a CPropertyPage pointer to the active page. There's also a GetActiveIndex() which returns the integer index of the active page.
|
|
|
|
|
1) treat each property page like a standard dialog: it reads and sets member variables that the owner can then set and read.
|
|
|
|
|
In a Standard dialog you have a CWnd object in it's constructor, the "CBCGPPropertySheet" constructor does not. (see constructor below
"CPropSheet(CBCGPPropertySheet::PropSheetLook look,UINT uiIconsResID = 0, int cxIcon = 0);"
If it had an CWnd object I could easily pass that to the propertypage, How could I obtain the CWnd of the "CBCGPPropertySheet" so I can use it for the propertypage could load inline functions in the CBCGPPropertySheet object?(see inlines below
" //inline functions:
void SetDate(CString csDate){ m_csDate = csDate;}"
A C++ programming language novice, but striving to learn
|
|
|
|
|
why do you need a CWnd ?
if you are creating the property sheets, you have the objects themselves - you don't need a CWnd.
|
|
|
|
|
Are you wanting the pages to communicate with the sheet, or the pages to communicate with each other?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I may need both. I'm not certain yet which way is best. Could you show me an example of both. I'll try the examples an see which is best in my program.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Store the data in the sheet, and use the QuerySiblings() method to forward a message to each page in the sheet. If a page needs to get/put the data, it can get to it via GetParent() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks.
A C++ programming language novice, but striving to learn
|
|
|
|
|
I'm trying to write a program that will use ETW, but I'm feeling completely baffled by it. I've read as much documentation as I can find, I've tried looking for samples, and I've been Googling for two weeks. I don't understand much of what I read, and I have no idea how to apply what I do understand.
I think I'd understand it better if I had a very bare bones C/C++ program that used it. What I had in mind was a program that waits for one minute, and then couts the total amount of disk activity that occurred in that minute, as measured by ETW.
How would one do this?
|
|
|
|
|
i_kant_spel wrote: I'm trying to write a program that will use ETW...
Event Tracing for Windows?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Yes. Event Tracing for Windows.
|
|
|
|
|
Are you familiar with writing kernel-mode components and drivers?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I don't know the first thing about kernel-mode code.
|
|
|
|
|
Isn't that where ETW resides?
<edit>
I see here that ETW can be used at the user level and the kernel level.
</edit>
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
modified on Tuesday, November 10, 2009 8:59 AM
|
|
|
|
|
Thanks for that link. I did see that page before, but somehow I never noticed Using Events to Calculate CPU Usage [^] in that reference until just now, which is pretty much exactly what I thought would help.
So I got that code, and I'm trying to run it, but I don't quite understand how it's supposed to work. I made an .etl file using xperf, which contains some data on CPU sampling. And I altered the code so that LOGFILE_PATH points to that file.
Now, what it seems like it's doing is it calls ProcessEvent many times, but each time, in order for something useful to happen, IsEqualGUID(CpuUsageEvent, pEvent->Header.Guid) must return true. CpuUsageEvent is a static const, generated using VS2K8 tools. But pEvent->Header.GuidHeader.Guid seems to always return a value from a fixed set of possible GUIDs. These NEVER match the generated CpuUsageEvent, so ProcessEvent never does anything useful.
What am I doing wrong here?
Also, does ETW *have* to read from a log file? Maybe I don't know what I'm talking about, but it seems like being able to capture events and save them directly to a struct or object would be a lot more useful than dumping the data to a log and then immediately parse it afterwards.
|
|
|
|
|
hi,
I'm trying to create a popup menu and modify the text font, colour and background colour for when the mouse is over an item. Does anyone know how to do this?
I can create the popup menu with TrackPopupMenu but I only know how to change the background colour of the items.
|
|
|
|
|
doug25 wrote: I can create the popup menu with TrackPopupMenu but I only know how to change the background colour of the items.
Checkout these sections on Fonts and Text[^] in MSDN. They should tell you everything you need.
|
|
|
|
|
the magic words are "owner drawn menu". there are a few articles here on CodeProject which can get you started.
|
|
|
|
|
thanks for the replies
I've managed to change the look of a menu
but now i've realised i don't know how to get the item selected for the WM_UNINITMENUPOPUP message. well, i can get the item the mouse was last over while the menu is still popped up, but if the user cancels the popup menu i want to set the item_selected to -1. it's difficult to explain. i think the WM_UNINITMENUPOPUP message is sent before the WM_COMMAND message so when the popup is destroyed i can't get the item clicked (command made) at destruction / cancelation time. how do i go about getting the command when the popup has sent the WM_UNINITMENUPOPUP ?
hope this makes sense, i've tried different things like GetMenuItemInfo, GetMenuState during WM_UNINITMENUPOPUP, but with no luck ??
|
|
|
|
|
ah, i've now realised there was no need for a message loop. so i made it so TrackPopupMenu returns the selected item. but now i can't understand why a message box won't show after TrackPopupMenu is called.
this is what i have :
item_selected = TrackPopupMenu(menu, flags, x, y, 0, hwnd, NULL);<br />
<br />
MessageBox(NULL, "Got to the end of showPopupMenu !", "Success!", MB_ICONEXCLAMATION | MB_OK);<br />
<br />
return item_selected;
any idea why the message box won't show ?
if i put it before TrackPopupMenu it shows but not after
|
|
|
|
|
i fixed the problem
because my program is a dll
i actually create an invisible window so i have a window procedure for the popup menu, when the popup menu gets destroyed it calls DestroyWindow to destroy the invisible window.
for some reason when i use a message loop after TrackPopupMenuEx the loop catches the WM_DESTROY message, quits the loop and after that MessageBox works.
it fixes the problem (MessageBox didn't show) but i don't quite understand why ?
here's a snippet of code
item_selected = TrackPopupMenuEx(menu, flags, x, y, hInvisibleWindow, NULL);<br />
<br />
<br />
int result = 0;<br />
<br />
MSG msg;<br />
<br />
while( (result = GetMessage( &msg, NULL, 0, 0 )) != 0)<br />
{ <br />
if (result == -1)<br />
{<br />
}<br />
else<br />
{<br />
TranslateMessage(&msg); <br />
DispatchMessage(&msg); <br />
}<br />
}<br />
<br />
MessageBox(NULL, "Got to the end of showPopupMenu !", "Success!", MB_ICONEXCLAMATION | MB_OK);
code from the WndProc
case WM_UNINITMENUPOPUP:<br />
DestroyWindow(hInvisibleWindow);<br />
break;<br />
case WM_DESTROY:<br />
PostQuitMessage(0);<br />
break;<br />
default:<br />
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
|
|
|
/*
Visual Studio 2008
Vector is a template class,and there is a class iterator in Vector;
I declare the function operator== as the iterator's friend function
(according to C++Primer,we'd better declare operator== as a friend function)
then how to do that? how to write the friend function operator== ?
the compiler can not deduce T,help me please!
I am a Chinese student,my English is not very good,I hope
you can understand me! ^-^
*/
#include<iostream>
using namespace std;
template<typename T> class Vector;
template<typename T> bool operator==(typename Vector<T>::iterator it1,typename Vector<T>::iterator it2);
template<typename T> class Vector
{
public:
class iterator
{
friend bool operator==(typename Vector<T>::iterator it1,typename Vector<T>::iterator it2);
};
};
template<typename T> bool operator==(typename Vector<T>::iterator it1,typename Vector<T>::iterator it2)
{
return true;
}
int main()
{
Vector<int>::iterator it1,it2;
//cout<<(it1==it2)<<endl;//failed,can not deduce the T,why? help me!
cout<<operator==<int>(it1,it2)<<endl;//success,but not very useful
return 0;
}
|
|
|
|
|
As workaround, you may define the == operator as member of th iterator class:
template<typename T> class Vector
{
public:
class iterator
{
public:
bool operator==(iterator it2)
{
}
};
};
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
This should be fine.
template<typename T>
bool operator==(T it1, T it2)
{
return true;
} Now compiler will be able to infer the type correctly.
wanchao507 wrote: according to C++Primer,we'd better declare operator== as a friend function)
Scott Meyers says, declare operator overload functions as non-member functions and make it friend only if it requires access to internals.
Best wishes,
Navaneeth
|
|
|
|
|
Thanks for Navaneeth.
You inspired Me.
I solved the problem successfully.
A very hard question? friend function again! remember my Question.
I declare the operator== as the class iterator's friend function just because
i want to access its private members.you mentioned that.
I reply the Question too,so others who meet with the same Question can get help!
my answer is just below yours!
Anyway,here I want to Thank You for your help!
|
|
|
|