|
But how do I find out if its black or white? Also, there is a utility called SetTextColor made by Pact Software www.12ghosts.com which says they send a message to the desktop telling it to change the icon text color...how do they do that? Thanks.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Do you know how to get the hue/luminance of a color? That is what its based on. Thanks.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
|
I'm having some difficulties sending large amounts of data (>40,000 bytes) to a server using CAsyncSocket in MFC. The client has no problem sending all the bytes, but when the server receives the bytes, the OnReceive function is called 4 times: each receive brings in about 10,000 bytes. However, after the first chunk is received (that one is OK), the rest of the received chunks are empty (don't have the numbers I am expecting). Any ideas on what might be going on?
Thanks in advance...
Nathan Brown
Southern Company
Technical Services
|
|
|
|
|
Just keeping this thread active...
|
|
|
|
|
I have been given a DLL project given to me that should be able to communicate through the web to a firmware device. I am familiar with Winsock, but I am not sure what type of dll to use and if I will encure any problems when spawning threads. Is Winsock thread safe? Please help.
|
|
|
|
|
Is Winsock thread safe
Yes, I have made a lot of multithreaded apps. that used winsock. Works great
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
There must be a really simple answer to this but how does one convert from a string representation of a hexadecimal number to the integer value. For example,
CString strHex = "00002A87";
int nHexValue = ....?
Anyone got any ideas?
Cheers
James Spibey
Well cover me in honey and throw me to the lesbians!
|
|
|
|
|
Try this Jim.
CString strHex = "00002A87";
int nHexValue;
sscanf((const char*)strHex, "%x", &nHexValue);
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
I did something like this once to get integers from hex strings. Just start at the least signifigant digit of the number (the right hand side), and work to the most. Assign each digit a value from 0 - 15 based on the digit. Multiply that value by 16^i, since HEX 10 = 16, hex 100 = 256, etc. Add this to a running total.
Tis should do it:
#include "string.h"
#include "math.h"
#include "ctype.h"
int main(int argc, char* argv[])
{
char hx[] = "16EFC";
int len = strlen(hx);
long val = 0, total = 0;
for(int i = 0; i < len; i++)
{
char c = toupper(hx[len-1-i]);
switch(c)
{
case '0':
val = 0;
break;
case '1':
val = 1;
break;
case '2':
val = 2;
break;
case '3':
val = 3;
break;
case '4':
val = 4;
break;
case '5':
val = 5;
break;
case '6':
val = 6;
break;
case '7':
val = 7;
break;
case '8':
val = 8;
break;
case '9':
val = 9;
break;
case 'A':
val = 10;
break;
case 'B':
val = 11;
break;
case 'C':
val = 12;
break;
case 'D':
val = 13;
break;
case 'E':
val = 14;
break;
case 'F':
val = 15;
break;
default:
// Oops!!
break;
}
val *= pow(16,i);
total += val;
}
printf("16EFC = %i", total);
return 0;
}
|
|
|
|
|
strtol()
strtoul()
---
Blessed are those who can laugh at themselves, for they shall never cease to be amused
|
|
|
|
|
That's a good one too.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
You can also use the standard library :
CString strHex = L"00001234";
int nValue;
std::stringstream ss( (const char*)strHex );
ss >> std::hex >> nValue;
std::stringstream ss( (const char*)strHex );
ss >> std::dec >> nValue;
std::stringstream ss( (const char*)strHex );
ss >> std::oct >> nValue;
The biggest (potential) advantage of the standard library stringstream is that you can write your own extensions, which integrate seemlessly into the syntax. So if you need to convert to/from base 36 for example (I actually had to do this once!), then you end up with something that looks like:
ss >> myStd::base36 >> nValue;
-----------------------
The sermon on the mount...
Man 1 : Hear that? Blessed are the greek.
Man 2 : The greek?
Man 1 : Well apparently, he's going to inherit the earth.
Man 2 : Did anyone catch his name?
|
|
|
|
|
So, of the methods posted, which did you use?
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Netmeisters,
I have a Pocket PC app which adds several thousand items to a CListBox. At times the items have to be redisplayed in a different order. Currently I am doing this by using CListBox.ResetContent() to remove all the items, CListBox.InitStorage() to allocate memory, and then CListBox.AddString() to add each item.
The problem is that, although this process is instantaneous on the emulator, it takes an annoying amount of time on the actual device. I am wondering if there is any way of optimizing this process to reduce the time it takes to repopulate the list box. My impression is that under desktop Windows an "owner-draw" list box might be used for this purpose, but these are not supported under Windows CE.
Of course, I could rewrite the app so it doesn't actually put thousands of items in the listbox, but I was hoping some other remedy might be available.
Thanks in advance,
Matthew Fleming
|
|
|
|
|
Hi!
I developped a MMC snapin that display an ATL object in the result pane (the one to the right).
The ATL object is a Composite Control. The control is showing ok but there is no functionnality except the buttons. I would like to add a progress bar but it doesnt work.
If anyone knows how to add the progress bar and make it functionnal. Or even better, if anyone knows how to use a CDialog (or anything CWnd based) based class behind that ATL object in the result pane. Help would be very appreciated!
Thanks
Scoob
|
|
|
|
|
Hi,
I need to convert a WMF (Windows Meta File) to Bitmap format.
I would be grateful, if someone can throw some light on this.
cheers
kannan
|
|
|
|
|
I would draw it to a window and then create a bitap from the contents of the window.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Hi,
thanks for replying.
cheers
kannan
|
|
|
|
|
WindowsNT 4.0, 2 CPU system, Visual C++ 6.0
I have a timer in a view going off every 5 seconds, and it removes items from a CObList and processes them one at a time.
Meanwhile, I have a worker thread (thread 2) which is creating the objects to be put in the CObList. After it creates a new object, it does a PostMessage back to the view with a pointer to the newly created object. Back in the view (thread 1), the message handler for this message takes the new object and adds it to the CObList. Then when the timer goes off, it removes this new object from the CObList and processes it (as stated earlier).
Since the timer function is adding objects to the same list that the message handler function is removing them from, I set a lock flag before adding/removing and remove it after the add/removal is completed.
The problem is that after several of these objects have been processed (but it's not a fixed number of times), in the middle of the timer function the program execution jumps to the message handler function. Since the lock for the timer function has been set, the message function is unable to obtain the lock and so it can't properly process the message. If I try to resend the message (do another PostMessage with the received message) then the program immediately handles the new message without returning to the timer function, effectively just spinning over and over in the message function.
I have tried posting the message to the mainframe instead of the view, and the same thing happens. I have verified using GetCurrentThreadId() that the timer function and message handler function are in the same thread, and that the thread that does the PostMessage is in a different thread.
I have verified that the timer function gets preempted by adding TRACE statements, and also by setting a member variable to different values at different points in the program.
How is it possible that in the middle of a function, the program execution jumps to a message handler? I thought that this wasn't supposed to happen, and can't figure out what to do about it. Help! Thanks.
|
|
|
|
|
> ... I set a lock flag before adding/removing
Is this a simple boolean variable? If so, this mechanism is error prone as thread1 may set it to true after the view thread has read it as false.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have verified using GetCurrentThreadId() that the timer function and message handler function are in the same thread
OK - this leaves only one possibility. One of statements in the timer function causes some messages to be sent to window, and handler fires. Put the breakpoint in message handler and check the stack when it happens - probably you'll see timer function somewhere below.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I posted the original problem.
Thanks to everyone who had suggestions, after struggling with this for two days, of course I finally figured it out shortly after I posted this message to the board.
In my timer function I had an assert similar to this:
ASSERT(pointer1 == pointer2);
when this assertion fails (as it does only sometimes), the program execution jumps from the timer function to the message handler function, and does this before it notifies me of a failed assertion. I don't really understand that, but by fixing the problem that was causing the ASSERT failure, I stopped my original problem from happening any more. Something about the ASSERT must allow it to go read the message queue.
Thanks again.
|
|
|
|
|
I'm moving some 16-bit Windows code over to 32-bit and one function that is giving me problems is a function that determines if a given filename is executing. More specifically, this program updates executables and DLLs from the network and before it performs a file copy, it calls a function called ProgramRunning(szFileName). Using TASKENTRY (which doesn't exist in 32-bit land) they enumerate the running processes and see if the filename passed in is in the tasklist.
Is there anyway to do something like this in 32-bit? It's easy if you have a process handle, but all I have is a damn filename.
Thanks,
Bill
http://www.ratebeer.com
|
|
|
|
|
AFAIK, There's no solution for all 32-bit Windows versions. On Win9x and 2K you can use Process32First/Next. If you need to support NT4, you'll probably have to use EnumProcesses (which is also available on 2K, but not on 9x).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|