|
services start before a lot of the system has initialised and they have no logged on user generally
there is a bunch of info about what u can and cant do on ms
what exactly are u trying to do?
"there is no spoon" biz stuff about me
|
|
|
|
|
I need to use CWnd::FindWindow to find out if the game "Freelancer" is running. If I use NULL as the first parameter and "Freelancer" as the second, it also finds windows explorer windows that are in a "Freelancer" directory. Therefore, I need to also specify the classname in the first parameter. The problem is, how do I determine Freelancer's classname? I tried GetWindowInfo, but that returned an ATOM number that varies; not good!
|
|
|
|
|
Spy++ will tell you. It's the string after the string in quotes (which is the window title). For example, this window I'm typing into is called "The Code Project- Free Source Code and Tutorials - Microsoft Internet Explorer" and is of the class named "IEFrame".
Alternatively, try GetClassName .
|
|
|
|
|
Friends,
I'm trying to create a function so I can print the conents of a STL list from main(). It looks like:
<br />
void TraverseAndDisplay(list< PhoneRecord>::iterator& itor, const list< PhoneRecord>& l) <br />
{ <br />
while (itor != l.end()) <br />
{ <br />
cout << *itor++ << " "; <br />
} <br />
cout << endl; <br />
}
Unfortunately, because PhoneRecord is not a primitive data type (it's my own class), the default operator != won't work.
The exact error I'm getting is:
error C2679: binary '!=' : no operator defined which takes a right-hand operand of type 'class std::list<class PhoneRecord,class std::allocator<class PhoneRecord> >::const_iterator' (or there is no acceptable conversion)
Obviously I need to overload the != to work. I don't know how to overload the != operator to work for iterators in this case?
Thanks in advance for your help!
|
|
|
|
|
Can you please repost the code, using < and > for the angle brackets so that we can see the template parameters?
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Sorry about that. It's reposted. Ignore the space after the < and before PhoneRecord.. it was making it a smiley.
|
|
|
|
|
I suspect it is because you are comparing an iterator with a const_iterator. Since the list passed in as a parameter is constant, it will only return a const_iterator, so you could either make the list non-cost, or pass in a const_iterator instead of an iterator as the first parameter (the better option as you do not appear to be modifying the list here). Alternatively, you could pass in the end iterator as a parameter rather than passing in the entire list - this is the approach used by STL, as then the type of container can be changed without modifying the function itself.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Dave, thank you so much for your help!
|
|
|
|
|
I have a small program I'm getting my feet wet with in having different ASCII, Extended ASCII and hopefully Unicode characters in a message window. This is the code
int n;
CHAR cTempChar[2];
LPCTSTR lpAsciiString=""
WCHAR wTempWchar[2];
static wchar_t szTitle[] = L"Unicode Characters";
static WCHAR wzTitle[] = L"high Unicode Characters";
static wchar_t * wzUnicode = L"U";
lpAsciiString=cTempChar;
cTempChar[1]=0;
for(n=48;n<70;n++)
{
cTempChar[0]=(CHAR)n;
MessageBox(NULL, lpAsciiString, TEXT("ASCII Characters"), MB_OKCANCEL|ML_ICONHAND);
}
wzUnicode=wTempWchar;
wTempWchar[1]=0;
for(n=48;n<60;n++)
{
wTempWchar[0]=(WCHAR)n;
MessageBoxW(NULL, wzUnicode, wzTite, MB_YESNOCANCEL|MB_ICONQUESTION);
}
for(n=204;n<226;n++)
{
wTempWchar[0]=(WCHAR)n;
MessageBoxW(NULL, wzUnicode, wzTitle1, MB_ABORTRETRYIGNOR|MB_ICONEXCLAMATION);
}
This is a sample for class and I'm supposed to change things to show the new Unicode characters (sample of). How would I go about doing this?
I need much help in the class and I hope this is the right place to get it cause I'm about out of ideas forhelp.
|
|
|
|
|
I am new to C++ and was presented with this piece of code to try and figure out what it does. I was hoping that someone could tell me or give me some idea. Here is the code, for(c=a^b, cnt=0; c>0; cnt += c%2, c>>=1);
Thanks, Claytide
|
|
|
|
|
two variables are being set, c and cnt. I believe that ^ is exclusive or ( in other words, use only bits set in only one of the two numbers ), and % is definately remainder, so t will = 1 or 0, depending on if c is odd or even. I don't see how cnt t = c%2 works, is the second t a typo ? I presume so, and so if t = 1 and c is odd, or t = 0 and c is even, the loop ends.
>> is the shift operator, so if a right shift of the number results in a value of 1, the loop ends.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
It's been a couple of years since I've done C++ but here goes:
a^b : ^ is a bitwise Exclusive-OR operator, e.g. 1^1=0; 1^2=3; 2^2=0; 32^64=96; 32^96=64;
Bitwise Exclusive OR Operator: ^[^]
c%2 : % is a modulus operator
C Multiplicative Operators[^]
>>= is a right-shift assignment operator
Shift Operators: >> and <<[^]
for
C++ language reference: The for statement[^]
c is initialised to a XOR b
cnt is initialised to zero.
The iteration will continue to loop around so long as c is greater than zero. This test is done at the start of each iteration.
At the end of each iteration cycle cnt is set to the remainder of c divided by 2 (In other words cnt will be 1 if c is odd, or zero if c is even) and c is shifted one bit to the right (in other words divided by two)
Now, while I was writing this, it occurred to me that this is an interview style question. No one in their right mind would code this.
So, for a bonus, (assuming c is an unsigned int and the code inside the loop doesn't alter c), what is the maximum number of iterations possible?
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
It looks like you've mis-transcribed it a bit. That should be a 't', it should be a '+', giving:
for(c=a^b, cnt=0; c>0; cnt += c%2, c>>=1) ;
And that then clearly counts the number of bits that are different between 'a' and 'b'. *chuckles* Isn't that obvious?
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Is it possible to simulate mouse clicks?
|
|
|
|
|
Yes.
Just send (or post) WM_LBUTTONDBLCLK (and similar) messages to a target window. However, you need to deliver the messages to the right target window, which can be easier said than done. (Finding the window can be non-trivial).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
How can I use a progress control to monitor the transfer status of file being transferred to the pocket pc device. Any ideas?
Thanks
|
|
|
|
|
Dont write the whole file with CeWriteFile, instead write it in parts so you can update your gui while writing.
Here's some pseudo-code doing that:
while (totalbyteswritten != totalsize)
{
CeWriteFile(hDest, buff+totalbyteswritten, min(chunksize, totalsize-totalbyteswritten), &byteswritten, 0))
totalbyteswritten += byteswritten;
}
“Our solar system is Jupiter and a bunch of junk” - Charley Lineweaver 2002
|
|
|
|
|
I want to convert int, long values to byte arrays, and from byte arrays back to int, long. I can do it with In .NET BitConverter class, but I want to do it in C++. any help greatly appreciated..
happy coding
|
|
|
|
|
Not sure if this is what you want:
char b[sizeof(int)];
int i=*reinterpret_cast<int *>(&b);
...
int i=...;
char b[4];
mempcy(b,&i,sizeof(int));
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi
I have a dialog which fits perfectly in a regular 17inch screen.
But with my friend, who has a 15inch screen, the dialog is too large to display.
How can i make sure the dialog got scrollbars on the 15inch screen, and not when the program is run with the 17inch screen?
Greetings
Bart
|
|
|
|
|
don't
Change your layout to fit the smaller screen size, using Tabs, and/or secondary dialogs.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Oh, i've thought about that too
but that isn't possible.
|
|
|
|
|
Friends,
Please tell me that how can i change the background color of my dialog box at runtime.
Thanks.
|
|
|
|
|
Thanks for reply..one more question
How can i force repaint after applying your solution. For example on pressing the OK button of dialog box i call the following code:
AgxGetApp()->SetDialogBkColor( COLORREF clrCtlBk = RGB(192, 192, 192), COLORREF clrCtlText = RGB(0, 0, 0) );
But the problem is that the dialog is not repainted at that moment. Its only when i bring some other window on top of dialog, the dialog gets repainted with new background color. I also tried PostMessage(WM_PAINT) after the above line of code, but it is also not applying color ?
|
|
|
|
|
I want to list all sub-keys under a key. In my test I have two sub-keys. I open my key with ::RegOpenKeyEx() and then I put zero into first call for ::RegEnumKeyEx() . I call it again until it does not return ERROR_SUCCESS . This is my code:
HKEY hKey;
CHAR achKey[MAX_KEY_LENGTH];
DWORD i = 0;
if (::RegOpenKeyEx(HKEY_CURRENT_USER, REG_MAJOR_KEY, 0,
KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
{
while (::RegEnumKeyEx(hKey, i++, achKey, &cbName, NULL, NULL, NULL,
&ftLastWriteTime)) == ERROR_SUCCESS)
print("Found %s", achKey);
RegCloseKey(hKey);
}
The problem is it finds one key but not the other. Can anyone tell me where I am wrong please? Thank you.
|
|
|
|