|
Thx for the reply,
I can't find anything here on codeproject to do with WMI and the SDK I just downloaded makes me realise how 'stoopid' I am
Dont suppose I can prevail upon you to point me in a slightly more confined direction?
Mark
|
|
|
|
|
Sorry, I meant codeguru. Here is a good starting point.
http://www.codeguru.com/system/WMI_using.html
This is the Microsoft tutorial.
http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/msdn-files/027/001/574/msdncompositedoc.xml
The WMI SDK also contains many more examples. I had pretty goo luck using Google to find info.
WMI is a client server type arrangement. The server software is called a provider. Once you know what providers you need to use, you can do more specific searches on google.
My own project used the Win32_Processor provider. I put Win32_Processor and Loadpercentage into a Google.com query and got lots of links, some of which were useful.
Hope this helps,
Bill
|
|
|
|
|
Can anybody either
a) provide me with a C\C++ function that mimicks CString::Replace in functionality, or
b) explain in detail (i.e. step by step) how to do this myself?
I have tried for ages, but can;t get anything that works.
Thank you,
Russell McCurly
Hobbiest Programmer
|
|
|
|
|
can't offer code, but have a look at std::string, from the C++ standard library.. (#include <string>) - it has members such as find_first_of() and replace() that you should be able to use quite easily to perform the CString::Replace() functionality.
happy coding!
|
|
|
|
|
It's not a trivial task because the text being replaced may be larger or smaller (in length) than the text to replace it with. I recommend looking at CString::Replace's source code to get some ideas. Even better, use the debugger to step into the function to see it in action.
If you want, you may also post your source code and we'll try to spot the problems.
Regards,
Alvaro
|
|
|
|
|
I've been teaching myself C++ for the past couple months and I'm absolutely loving it. I'm attempting to learn classes right now and I'm writing my own little program. Here is the code:
#include
using namespace std;
class CLogin{
private:
char m_Username[15];
char m_Password[15];
char m_Usernames[2][9]={"John","Bob"};
public:
void getUsername(){
cout<<"Enter user name: ";
cin>>m_Username;
cout<<"You entered: "<
|
|
|
|
|
char m_Usernames[2][9]={"John","Bob"};
You can't initialize a member variable within a class declaration. You have to do that within a constructor or some other member function.
char m_Usernames[2][9];
HTH,
Jon Sagara
"There are lies, damned lies and statistics."
-- Mark Twain.
|
|
|
|
|
I'll have a go at it...
/************************************************\
* Class Definition *
\************************************************/
#include <<someheaderhere>>
using namespace std;
class CLogin{
private:
char m_Username[15];
char m_Password[15];
char m_UserNames[2][9];
// Can't do this here. Need to do this through a member function
// or a constructor
char m_Usernames[2][9]={"John","Bob"};
public:
CLogin() // Default Constructor
void getUsername();
};
/***************************************************\
* Class Implementation *
\***************************************************/
CLogin::CLogin()
{
m_Username[0] = ' ';
m_Password[0] = ' ';
m_UserNames[0][0] = {' ',' '};
}
void CLogin::getUsername()
{
cout<<"Enter user name: ";
cin>>m_Username;
cout<<"You entered: "<<m_username;
}
********************************************\
*="" program="" entry="" point="" *
\********************************************=""
int="" main(void){
clogin="" login;
login.getusername();
return(1);
}
it="" should="" be="" cleaned="" up="" enough="" now="" to="" allow="" you="" compile="" it.
you="" initialize="" your="" variables="" through="" the="" class="" constructor="" or="" another="" member="" function.="" take="" time="" learn="" about="" standard="" string="" class...="" you'll="" never="" use="" char="" array's="" again="" =""
good="" luck="" and="" happy="" programming="" =""
<b="">Paul Lyons
Do not go where the path may lead, go instead where there is no path and leave a trail.
- Ralph Waldo Emerson
|
|
|
|
|
You can initialize fundamental data types in your class interface..
(a'cordin to the new C++ std + the compiler must support)
class CNewStd
{
private:
unsigned int m_nCount = int(8); //or use int() for zero initialization
public:
.
.
};
Atul Dharne
___First Law of Security___
1. Don't buy a computer...
|
|
|
|
|
pliz help me...
i want to get the text string from the focused editbox of focused application...
how can i do it?
|
|
|
|
|
GetWindowText ? I believe if you have the HWND of the app, you can get the HWND of the focused control.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
ye, i have the HWND of the app...
but now how can i get HWND of the control?
|
|
|
|
|
It it has the focus, you can call GetFocus, I presume this will return the control that has the focus, not the parent window. You don't even need the windows HWND.
If I'm wrong, you can iterate looking for the control with focus with GetNextDlgTabItem.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
you are wrong... but... i have found the function that enums all child windows of the the parent window...
BUT! i dont know how to find out whether it has focus or not
|
|
|
|
|
call:
HWND GetFocus()
or
static CWnd* PASCAL GetFocus() in MFC
|
|
|
|
|
Use CWnd::GetForegroundWindow() to get the top-level CWnd that currently has focus. Then, iterate through its child windows as mentioned earlier.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
|
Hi,
I have a range of controls developed in my project. I have a requirement where in I have to link each control with a specific memory location at program time. This would mean that whenever I create a new instance of control all I need to do is map the id of the control with appropriate Shared memory location (one option is through a script or mapping file).
If any one has worked on any similar problems before I will luv to hear from them. If you have any other ideas they are welcome.
Thanks
Sandeep
|
|
|
|
|
Hi,
I'm just looking for some advice on where to start.. I have a list control and with in the control I have "n" numbers of items, each item has a different value of time.. eg (140 seconds, 300 seconds etc..). I need to use a timer to count down each item until it reaches 0.. The problem is I never know how many items will be in the list so I can't pre-define all my variables.. any ideas on where to start?
Thanks,
B0neHead
|
|
|
|
|
Never mind i figured it out.
B0neHead
|
|
|
|
|
OK, here's my situation...
I'm creating a bitmap keypad, where the color of the buttons change as the user moves their mouse over. The image doesn't appear to change. Can anyone see what I'm missing here. Sorry this is so long.
Thanks in advance for any help...
==============================================================
I store the two BMP's as CBitmap's member variables... also I have their respective DC's
class CKeypadView : public CView
{
....
CBitmap m_kpBitmap; // scratchpad bmp
CBitmap m_kpEnabled; // all keys w/no mouseover (blue)
CBitmap m_kpMouseOver; // all keys w/mouseover (yellow)
CDC m_kpBitmapDC;
CDC m_kpEnabledDC;
CDC m_kpMouseOverDC;
CRgn m_rgnKey[18]; // stores the key regions
....
}
In the constructor, I define the key regions and load the BMPs...
CKeypadView::CKeypadView()
{
m_rgnKey[OES_KEY_01].CreateRectRgn( 3, 102, 48, 132);
m_rgnKey[OES_KEY_02].CreateRectRgn( 51, 102, 96, 132);
m_rgnKey[OES_KEY_03].CreateRectRgn( 99, 102, 144, 132);
m_rgnKey[OES_KEY_04].CreateRectRgn( 3, 69, 48, 99);
.......
m_kpEnabled.LoadBitmap(IDR_KEYPAD_MOUSENORM);
m_kpMouseOver.LoadBitmap(IDR_KEYPAD_MOUSEOVER);
}
In OnCreate, I set up the utulity bmp, and associate the DCs...
int CKeypadView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
CClientDC dc(this);
// get the size and pallete for the utility bitmap
BITMAP bits;
m_kpEnabled.GetObject( sizeof(BITMAP), &bits );
CRect rcKP(0,0,bits.bmWidth,bits.bmHeight);
// setup the utility bitmap
m_kpBitmap.CreateCompatibleBitmap( &dc, rcKP.Width(), rcKP.Height() );
m_kpEnabledDC.CreateCompatibleDC(&dc);
m_kpMouseOverDC.CreateCompatibleDC(&dc);
m_kpBitmapDC.CreateCompatibleDC(&dc);
m_kpEnabledDC.SelectObject( &m_kpEnabled);
m_kpMouseOverDC.SelectObject( &m_kpMouseOver);
m_kpBitmapDC.SelectObject( &m_kpEnabled);
return 0;
}
When the user moves the cursor over a key on the bmp keypad, I want that key to be BitBlt'd with the key of the "mouseover" bmp....
// ==================================================================
void CKeypadView::OnMouseMove(UINT nFlags, CPoint point)
{
CRect rctKeyRgn; // stores the region of the mouse cursor
CClientDC dc(this);
CRect rect;
GetClientRect( &rect );
// find which key it is over (if any)
for( int iKey=OES_KEY_01; iKey<=OES_KEY_ALL; iKey++)
{
if( m_rgnKey[iKey].PtInRegion(point) )
{
int nRgnBoxResult = m_rgnKey[iKey].GetRgnBox( &rctKeyRgn );
ASSERT( nRgnBoxResult != ERROR || nRgnBoxResult != NULLREGION );
// copy the normal keypad to the utility bmp
m_kpBitmapDC.BitBlt( 0,
0,
rect.Width(),
rect.Height(),
&m_kpEnabledDC,
0,
0,
SRCCOPY );
// copy only the region that the mouse is over
m_kpBitmapDC.BitBlt( rctKeyRgn.left,
rctKeyRgn.top,
rctKeyRgn.Width(),
rctKeyRgn.Height(),
&m_kpMouseOverDC,
rctKeyRgn.left,
rctKeyRgn.top,
SRCCOPY );
CRect rect;
GetClientRect( &rect );
// output the bmp to the view
dc.BitBlt( 0,
0,
rect.Width(),
rect.Height(),
&m_kpBitmapDC,
0,
0,
SRCCOPY );
continue; // break out of loop
}
}
CView::OnMouseMove(nFlags, point);
}
------------------------------------------------
I am not discouraged because every wrong attempt discarded is another step forward
-- Thomas Edison --
|
|
|
|
|
What I would is rearrange your code a bit. Place all drawing code in the OnDraw handler. Use a state variable for each key to signify whether it is up, down, or under the cursor. The OnMouseMove and OnLButtonDown functions are then used to determine the state of the key. This could help you untangle your problem.
|
|
|
|
|
You know what... I like your structure muuuuch better. Thanks for untangling this web.
Mark
------------------------------------------------
I am not discouraged because every wrong attempt discarded is another step forward
-- Thomas Edison --
|
|
|
|
|
I am glad I could help.
PS: remember to Invalidate the key's rectangle when it changes state.
|
|
|
|
|
Here's what I think:
1) I assumed that all coordinates are in client coordinates not screen.
m_rgnKey[OES_KEY_01].CreateRectRgn( 3, 102, 48, 132); and etc.
thus, this line is reached:
int nRgnBoxResult = m_rgnKey[iKey].GetRgnBox( &rctKeyRgn );
2) I am not sure that your bitmap has the same size than the screen. Use StretchBlt function
when source and destination rectangle are different size
3) Note: You have twice "CRect rect" in your code
4) continue; // break - does not break, the loop continue...
5) Do not select the same bitmap to two different device context
6) What your OnDraw look like?
good luck
|
|
|
|