|
Hello,
I'm looking for an API function to get the CPU load (or a method to do this based on several API functions).
I recently bought a dual core processor and the minimized task manager isn't very helpful with providing quick information as to how each core is used. After digging a little on the net I decided I would be nice to write my own utility, but got stuck.
Any ideas how to do this? Any existing apps worth installing?
Many thanks,
Miron Brezuleanu
|
|
|
|
|
You need to use the performance counters. See PdhOpenQuery for how to get started with the Performance Data Helper APIs.
|
|
|
|
|
#include <iostream>
#include <string>
void println(const std::string& msg)
{ std::cout << msg << '\n'; }
class Base {
public:
Base() { println("Base::Base()"); virt(); }
virtual void virt() { println("Base::virt()"); }
};
class Derived : public Base {
public:
Derived() { println("Derived::Derived()"); virt(); }
virtual void virt() { println("Derived::virt()"); }
};
int main()
{
Derived d;
...
}
Why does the virtual virt function is called on the base class and not on derived class?
|
|
|
|
|
tom groezer wrote: Why does the virtual virt function is called on the base class and not on derived class?
Because in the base constructor, the object is only created to that point - there's still no
derived class constructed yet (Constructors are called in order from base to derived).
That's why you shouldn't make virtual calls from a constructor
Mark
"I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing." The Big Lebowski
|
|
|
|
|
Hi iam doing a project on localization. For that i want to develop a translator tool. Pls tell me the way to generate a dynamic resource file.
|
|
|
|
|
Maybe this link wll help: Creating a Resource-Only DLL[^]
"I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing." The Big Lebowski
|
|
|
|
|
Actually i want to generate rc file programatically. Can any one help me out?
|
|
|
|
|
hariharask wrote: Actually i want to generate rc file programatically
Oh, ok. Sorry about that!
In that case, you should know the .rc file format so you can read/write them.
Here's the info: About Resource Files[^]
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
I have 2-Views with property pages. If I am in View1, I can
get and save a number that I would like to transfer to a property
page in View2. I can save the number to the document and if I
print preview, the data appears in the correct property page in
View2.
Here is my problem. When I visit the property page in View2, the
data does not appear on the screen. I need to take (or load) the
data from the document. But OnSetActive nor OnInitDialog are not
called in the property page when it becomes active. When I am
in a property page in View2, how can I reload data from the document?
I tried a variety of different things. I just cant get it to work
unless I add a button that says "Get Number" and then when clicked,
it goes and retrieves that data. There has to be a way to automatically
transfer retrieve that data. Please, any response any one can give
me will be greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
I'm wanting to make a chat program that uses IRC for my gaming clan. We use IRC to talk mostly. When in games I play some window mode so I can still chat in IRC.
Basically I want to make a program that will sit on top of any window so I can view IRC activity and respond (I can do that bit all later)
The problem I'm having is making the form sit on top of windows. For example Sitting on top of CSS as it uses Direct-X. Is there a way I can make it sit on top? I don't need to be able to type or click the window directly so CSS would always have mouse/keyboard control. I'd use a key combo like ctrl+keys to talk.
So yea true "on top" for forms over games etc? Code would be nice to help me, or just advice on what to research.
Thanks
|
|
|
|
|
mosimo wrote: Basically I want to make a program that will sit on top of any window so I can view IRC activity and respond
See -> SetWindowPos Function[^]
looks something like
SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
With respect, I must disagree. A quick look at middle management in just about any corporation shows that the dodo not only survived, it's reproducing in record numbers. Christopher Duncan
|
|
|
|
|
Hi,
I need to capture a scrolling web page to an image file,
( Not just the images on the page ), c++ code preferred.
Does anyone know of an sdk or any examples of how to do this.
Many thanks.
|
|
|
|
|
Hi all,
How can i be able to add the Smart tee filter to the filter graph and then connect it to the video renderer to display video.
I am using the following line of code to add smart tee filter but it is not working:
CHECK_HRESULT(AddFilterByName(CLSID_LegacyAmFilterCategory, bstrDeviceName, &pSmartFilter));
Thanks and Regards,
Mayank
|
|
|
|
|
Hi all,
How can i replace RenderStream function using AddFilter or any other DirectShow function if i want to capture and display live video captured from webcam.
Regards,
Mayank
|
|
|
|
|
One way is to use AddFilter, FindPin, and Connect to manually connect filters in the capture
graph.
You can also use RenderStream, but in increments...
In your graph example
TvTuner-->TvAudio-->Crossbar-->FusionHDTV-->Video Renderer
You could build this graph by
Create an instance of the capture filter (FusionHDTV) and add it to the graph.
Create an instance of the desired video renderer and add it to the graph.
To insert an infinite tee filter, create an instance of the infinite tee filter, add it to the
graph.
IBaseFilter *pInfinitePinTeeFilter = 0;<br />
hr = CoCreateInstance(CLSID_InfTee, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, reinterpret_cast<void**>(&pInfinitePinTeeFilter));<br />
if (SUCCEEDED(hr))<br />
{<br />
pGraphBuilder->AddFilter(pInfinitePinTeeFilter, L"Infinite Pin Tee");<br />
}
Do whatever initialization necessary on the capture filter (so the media type is set and known).
Now connect them together..
Use RenderStream to connect the capture filter to the infinite tee filter.
pCaptureGraphBuilder2->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pCaptureFilter, NULL, pInfinitePinTeeFilter);
The graph should be TvTuner-->TvAudio-->Crossbar-->FusionHDTV-->InfiniteTee at this point (the
tuner and crossbar filters should automatically be added if necessary).
Use FindPin to find the (unconnected) output pin on the tee.
IPin *pTeeOutputPin = NULL;<br />
pCaptureGraphBuilder2->FindPin(pInfinitePinTeeFilter, PINDIR_OUTPUT, NULL, NULL, TRUE, 0, &pTeeOutputPin);
Use RenderStream to connect that pin to the renderer filter
pCaptureGraphBuilder2->RenderStream(NULL, NULL, pTeeOutputPin, NULL, pRenderFilter);
The graph should be TvTuner-->TvAudio-->Crossbar-->FusionHDTV-->InfiniteTee-->Video Renderer
and the Tee will have a new output pin, which you can get using FindPin() with the unconnected
flag (like above).
I hope that helps a bit,
Mark
"I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing." The Big Lebowski
|
|
|
|
|
In a singleton class is it mandatory to provide a private copy of each of the three viz. default constructor, copy constructor and the assignment operator.
Also can the following code be repalced something with a notiion of new operator ie of creating the pattern on stack
class CSingleton {
public:
static CSingleton& GetInstance() {
static CSingleton theInstance; // one and only instance
return theInstance;
}
}
ie the GetInstance method could be replaced by
static CSingleton* GetInstance() {
static CSingleton* p = new CSingleton();
return p;
}
|
|
|
|
|
You only really need to make the constructor private.
After all, unless to can create an object, you can't assign anything into it, and you can't copy into it either.
And your second question... They are pretty much equivalent. references are all but identical to pointers, with the exception that you can't be NULL.
Iain.
|
|
|
|
|
Here is a code sample that I use and works fine.
CTORs and assignment operator are private
Definition
class BnBGetObjects
{
private:
BnBGetObjects(void);
BnBGetObjects(const BnBGetObjects& ref);
virtual ~BnBGetObjects(void);
void operator=(const BnBGetObjects& ref){}
static BnBGetObjects* m_pbnbGetObjects;
public:
BnBTreeControl* m_pEditTreeCtrl;
BnBSecuritiesSettingsPSheet* m_pSecuritiesPSheet;
BnBSecuritiesSettingsPPge1* m_pSecuritiesPPge1;
BnBSecuritiesSettingsPPge2* m_pSecuritiesPPge2;
public:
static BnBGetObjects *GetInstance();
void DeleteInstance();
};
Declaration
#include "StdAfx.h"
#include ".\bnbgetobjects.h"
BnBGetObjects::BnBGetObjects():
m_pEditTreeCtrl(NULL)
,m_pSecuritiesPPge1(NULL)
,m_pSecuritiesPPge2(NULL)
,m_pSecuritiesPSheet(NULL)
{
}
BnBGetObjects::BnBGetObjects(const BnBGetObjects& ref):
m_pEditTreeCtrl(NULL)
,m_pSecuritiesPPge1(NULL)
,m_pSecuritiesPPge2(NULL)
,m_pSecuritiesPSheet(NULL)
{
}
BnBGetObjects::~BnBGetObjects()
{
DeleteInstance();
}
BnBGetObjects *BnBGetObjects::GetInstance()
{
if(m_pbnbGetObjects==NULL)
m_pbnbGetObjects = new BnBGetObjects();
return m_pbnbGetObjects;
}
void BnBGetObjects::DeleteInstance()
{
if(m_pbnbGetObjects!=NULL)
{
delete m_pbnbGetObjects;
m_pbnbGetObjects=NULL;
}
}
BnBGetObjects* BnBGetObjects::m_pbnbGetObjects;
|
|
|
|
|
CMenu *SubMenu;
SubMenu = m_FloatMenu.GetSubMenu(0);
.
.
.
.
for(int i = 0;i < nRows; i++)
{
UINT Id = IDR_DYN_STAGE; //some Iteger Id
SubMenu->InsertMenuW(ID_GETJOBS,MF_BYCOMMAND,Id,CString(szStageName));
Id++;
}
SubMenu->RemoveMenu(ID_GETJOBS,MF_BYCOMMAND);
.
.
This will Create A dynamic menu from values on Database.
I want to Have an event handler (based on Id) while clocking on that item.
Neo
|
|
|
|
|
Neo.hack.net wrote: I want to Have an event handler (based on Id) while clocking on that item.
Take a look at XPrintHeader at the file XPrintHeader.cpp.
|
|
|
|
|
I know you've just typed this as an example, but you need to move the UINT Id= stage out of the loop, unless you want them all to have the same ID....
If you're in MFC, you can write a ON_COMMAND_RANGE_EX (IDR_DYN_STAGE, IDR_DYN_STAGE + large number, OnDynStage) message handler, and check if its within range as the first option inside the handler.
The _EX means you can let MFC know if it need to pass the message on or not - do a search in MSDN for more info.
Iain.
|
|
|
|
|
I am new user of Visual c++ .NET, I was Using Visual c++ MFC and Access.
1. Whow can I write the name of my program so that It can be shown in the title barre when I run my program
2. I create a menu, Whow can I load a forms from my menuitem ?( I have now two forms, the first is loaded by default, if i want to change when I click on my itemmenu, what codes to write ?
I learn my self
|
|
|
|
|
you need to change first page or open new page
Its Not clear ,Please give its detail
Regard's
Kaushik
|
|
|
|
|
Do you want to set title? see SetWindowText .
|
|
|
|
|
I am using now Visual c++ .NET
I don't know if it is this forum where I would ask.
Where to write it and whow ? syntax
|
|
|
|
|