|
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
|
|
|
|
|
Process32First/Next were exactly what I was looking for. I'm about 99% certain that we'll never be running on NT4 (it's an inhouse application) so this should work perfectly.
Thanks so much!
Bill
http://www.ratebeer.com
|
|
|
|
|
HOWTO: Enumerate Applications in Win32
KB: Q175030
I think that will answer your question(s).
|
|
|
|
|
Hi, All!
========
Does anyone know how can I change the caption of my API console application ?
Thanks.
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
|
I posted earlier this week about a problem I had where I could delete files but not remove a directory. Someone mentioned they once had a similar problem which was due to a shortcut existing that referenced the directory. As it happened I had three on my Desktop which were to be deleted in the next step of the program.
I have changed to order to delete the shortcuts from the Desktop. This is successful. Now when I try to delete the files with ::DeleteFile() or CFile::Remove() it fails. The return value from ::GetLastError() after ::DeleteFile() is ACCESS_DENIED. This is strange as earlier this week I could delete these files.
I am running Windows 2000 Professional SP2 VC++ 6 SP5. The files I am trying to delete were added by me to a directory that I created. They are icons and batch files that are (I am positive) not in use.
Anyone have any idea what the problem could be.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
"Don't belong. Never join. Think for yourself. Peace"
- Victor Stone
|
|
|
|
|
Did you try SHFileOperation? You could delete directory with files in one step.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
No I haven't. Will give it a go in the morning.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
"Don't belong. Never join. Think for yourself. Peace"
- Victor Stone
|
|
|
|
|
I would like to get the physical drive characteristics of the floppy drive in Win32. I am familiar with the diskinfo_t structure that was used for old DOS programs, but I am unfamiliar with how to do this in Windows. Does anyone have any idea on how to do this?
Thanks...
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
See MSDN:
Platform SDK\WIndows base services\hardware\device input and output\
using device input and output control\
That contains all the info you need.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
I'm writing an application using MFC, and i'm planning on using DAO for the main data source and serialisation for all the options etc. I was wondering if it would be possible to get the application to work on any machine? Could the MS Jet engine (i'm assuming DAO uses the jet engine) be installed on a machine that doesn't have it? Or could the neccesary functions be packed into the exe?
Thanks guys.
|
|
|
|