|
If you return a non-zero value from OnIdle you are asking for more idle processing time ( and you will get it ).Return 0 if you don't need more.
|
|
|
|
|
This is a bit of a long subject but you might consider listening to your socket in a seperate thread instead of using the OnIdle override. Functionally, it's probably easier to manage using the onidle, but I think a multithreaded solution would give you much more flexibility.
Paul
|
|
|
|
|
My OnIdle function it was actually a separate thread, not an override of the OnIdle function. I fixed the problem. It seems that the function waitformultipleobjects did this.
Now my function does just a repetead read on the socket and if there is a message than it processes it.
Thanks for the help.
A Happy New Year!
Florin
|
|
|
|
|
I'm trying to simulate a multiprocess job with the use of semaphores, but I'm not fluent in C++. Anybody knows how to implement such thread controls?
|
|
|
|
|
The C++ standard does not cover multithreading. If you want to implement multithreaded apps you will have to use platform specific routines - for windows look in MSDN for synchronization functions ( InitializeCriticalSection, CreateMutex, CreateSemaphore, etc). One of the best samples of how to use them is MFC - look in the implementation of CMutex , CSemaphore, and the rest of synchronization classes.
|
|
|
|
|
I am writting a windows application that uses Namepipes for IPC. I have a strange problem which is that this IPC some times fails in a random way. It will work just fine for some time and then suddenly will thow an exception saying that the namepipe initiator is expecting for the other end to open the pipe. The main issue is that this behavior is random and so far there is no way to repeat the error when I want it. I would appreciate any ideas for handling this issue. Thank you in advance for your time.
Spiros Prantalos
Miami the place to be!!
|
|
|
|
|
I'm trying to set the button text on the fly so that it can change labels as things change in my app.
I have been unable to figure out how/what type of var will work.
I've tried an array of char, a pointer, but it seem to only work when I use "blah....".
Is there a way? Maybe I just need some more coffee
|
|
|
|
|
DOUGH! I got it...seems in my attempt at this I left the button definition where it was...later in the program!
That coffee really works!
Thanks for looking
|
|
|
|
|
SetDlgItemText(....)
try.
|
|
|
|
|
hi,
I am using a system wide hook and get the handle (HWND) of the process about to start. How do I get the filename from this handle?
i am running win98,nt,2000,xp
thanks
neil
|
|
|
|
|
If you have the window handle you can use GetWindowThreadProcessId to get the process id , then using PSAPI or ToolHelp lib you can get the file name.
|
|
|
|
|
I have vc++ .net and I have a project that has a single define for compiling certain code for U.S. users and other code for Canadian users.
What I want to do is build two releases at the same time from the same code with one being built with the define BUILDCANADA defined and the other not, but I don't want to have two separate projects.
I see lot's of info on doing simultaneous separate builds based on compiler settings etc, but nothing that shows if it's possible to do one build with a define set and another with it not set. I guess what the real question is, is can you set a DEFINE in the build options somewhere?
|
|
|
|
|
Go into the "Build" menu, click on "Configuration Manager", here you can make multible configurations.
Then you can go into th projects options, and define what you need for each configuration.
To build both projects in a single step, select "Batch Build..." in the "build" menu...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi Anders, thanks for replying. I know you can do that, but the critical thing is that I need to have a DEFINE set differently for the two builds, is that possible?
|
|
|
|
|
In "Configuration dialog|C/C++|Preproccesor", there is an option called "Preprocessor definitions" where you can define your BUILDCANADA or whatever you want.
--------
Dave
|
|
|
|
|
Perfect! Exactly what I was trying to find.
Thank you very much.
|
|
|
|
|
Hi, In my program (VC++, MFC, MDI ap), I need a function to delete a directory and all it's contained files and sub-directories. I'm currently using "system" to call the DOS program Deltree.exe. However, I'm sure that there should be a pure Windows method to do the same thing that would be much cleaner. Has anyone any suggestions ?
Doug
|
|
|
|
|
Try this:
BOOL DelTree(CString cstrPath)
{
BOOL bRetVal = FALSE;
CString cstrTemp = cstrPath;
CString cstrOldDir;
char buffer[MAX_PATH];
CFileFind cFind;
CString cstrFileName, cstrTempFile;
cstrFileName.Format("%s%s",cstrPath,"\\*.*");
if (cFind.FindFile(cstrFileName))
{
BOOL bFound = TRUE;
while (bFound)
{
bFound = cFind.FindNextFile();
if (cFind.IsDots())
continue;
else
{
cstrTempFile = cFind.GetFilePath();
bRetVal = DeleteFile(cstrTempFile);
if (!bRetVal) break;
}
}
}
cFind.Close();
if (bRetVal)
bRetVal = ::RemoveDirectory(cstrPath);
else
return bRetVal;
}
Jason Henderson start page ; articles
henderson is coming
henderson is an opponent's worst nightmare
* googlism *
|
|
|
|
|
Jason,
Your solution appears correct. However, I'd like to point out a small detail which caught my eye. Your function's signature is BOOL DelTree(CString cstrPath) . Your parameter is a CString value, rather than a constant CString reference, which would be more appropriate: BOOL DelTree(const CString& cstrPath) .
I just wanted to point this out to you and hope that you understand why it's usually much better to pass objects by const reference rather than by value. I realize that the CString class has a copy-on-write scheme which makes passing by value a lot less expensive than it otherwise be. But, passing by const reference is still the most efficient way to pass most objects requiring "by-value" semantics.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Thanks.
Actually, I took this code from a COM dll and modified it rather quickly. I really didn't look it over all that well.
Jason Henderson start page ; articles
henderson is coming
henderson is an opponent's worst nightmare
* googlism *
|
|
|
|
|
The only problem I see is that it is not recursive, so it will not work like deltree, deleting all sub-directories and their contents too.
|
|
|
|
|
Hey you're right. Good catch.
It would be easy to modify though.
Jason Henderson start page ; articles
henderson is coming
henderson is an opponent's worst nightmare
* googlism *
|
|
|
|
|
Jason gave you the clean solution. However, here's another one similar to your "system" one, except that it doesn't show the DOS window:
::WinExec("deltree blah", SW_HIDE);
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
But this way (and also the "system" call) relies on "deltree.exe" being present on the system. On my w2k I don't have "deltree.exe" so the app won't work. I think it's better to use Jasons way.
--
karl
|
|
|
|
|
Hi all you guys !!! Many thanks for all your input - I've taken all the points that you've raised, and, as my ap is only for private "consumption" can live with the WinExec solution - I just "hated" droping into a DOS window in the middle of a Windows program but now that I can hide it,I'm happy !!!
Doug
|
|
|
|