|
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!
|
|
|
|
|
You are welcome. You really don't have to make iterator a class. Iterators can be implemented using simple pointers.
Best wishes,
Navaneeth
|
|
|
|
|
Thanks for Navaneeth.
You inspired Me!
I solved the problem successfully
I hope my source code below can help others who meet with the same problem!
#include<iostream>
using namespace std;
template<typename T> bool operator==(T it1,T it2);
template<typename T> class Vector
{
public:
class iterator
{
friend bool operator==<Vector<T>::iterator>(typename Vector<T>::iterator it1,typename Vector<T>::iterator it2);
public:
iterator(int a=0):value(a){}
private:
int value;
};
};
template<typename T> bool operator==(T it1,T it2)
{
if(it1.value!=it2.value)
{
return false;
}
return true;
}
int main()
{
Vector<int>::iterator it1(0),it2(1);
cout<<(it1==it2)<<endl;
return 0;
}
|
|
|
|
|
Hi ,
May i know how the static variable is stored in memory...
and is it right if i declare static variable inside class but not outside the clas...
|
|
|
|
|
kumar sanghvi wrote: May i know how the static variable is stored in memory...
I'm not sure what you mean by this. The variable is stored in the program's data space and exists for the life of the program.
kumar sanghvi wrote: and is it right if i declare static variable inside class but not outside the clas...
A static declared inside a class is a class variable and can only be accessed through the class name. A static declared outside a class may be accessed directly in a function, module or application depending on where it is declared.
I suggest a re-reading of the C++ documentation on variables for more information.
|
|
|
|
|
Alright, I've ran into a problem that I'm really confused over:
I'm writing a simple mail client. It runs fine on my computer (Windows XP, SP2). However, when ran on a Vista machine, it crashes. Not as in BSOD-crash, it's more like the whole system just freezes over. A friend of mine, who was testing it on her vista machine, she says that everything just freezes (including the mouse) and the few times she had music on,
*the last few times
*i had musci on
*but not this time
*and it like..
*Stutters
*in that spot
I managed to trace it down to here:
MessageBox(NULL,"got here 1","okay",MB_OK);
closesocket(hSocket);
hSocket = NULL;
MessageBox(NULL,"got here 3","okay",MB_OK);
The first msgbox shows, but the second doesn't. (friend of mine isn't exactly computer-savvy, so I put the messageboxs in there so she could test the app).
I'm really stumped by this, because it works fine on XP. What does Vista change that doesn't allow the proper disconnection and closing of a socket?
If it changes anything, this is all happening in a seperate thread, started by a call to AfxBeginThread inside a WH_KEYBOARD_LL callback function. But that shouldn't make a difference, should it?
If any more info is needed, just ask. It's a rather large piece of code, so it's hard for me to describe everything that's going on.
Thanks in advance. 
|
|
|
|
|
Did you try it on more than one Vista machines? Does it crash at the same spot on every vista computers? You mentioned that it is happeneding in a separate thread, so, could it be a synchronization error? I mean, synchronization errors tend to be different depending on a lot of things, for example we had such error(s) that would never pop up on a single core muchine but they would happen almost every time on dual core systems, also they can depend on timings, for example you could have such an error that doesn't pop up at first but if you run winamp and start playing your favourite music then it does because if the computer has more things to do then your process/threads get less CPU time and then somethings that before did not happen simulteniously before will happen now and cause the problem...
Also, are you sure your hSocket is valid?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|