|
I have this in the .h file:
typedef enum { _P1=0, _P2=15, _P3=6, _PDefault=15} PDef;
MyFunc(PDef a){...};
and when I use it .cpp file like this:
MyFunc( (PDef)1785);
is there a way I can overwrite the '(PDef)' convertion?
e.g.
(PDef)1785- will return _PDefault ?
or somthing like that
thanks
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject "
|
|
|
|
|
Nope, that's how enums work. An enum is implemented as an int. When you cast to PDef, it's up to you to make sure the number is within range of the enum.
--Mike--
http://home.inreach.com/mdunn/
You are the weakest link, GOODBYE!
|
|
|
|
|
Thanx to MSDN: MSDN Library/Technical Articles/Visual Tools/Visual C++/Detecting and Isolating Memory Leaks Using Microsoft Visual C++
I tried to detect, where i've got mem. leak.
As dedscribed, i insert
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
i my header.
but if there is #include <malloc.h> after those strings, i get
Compiling...
StdAfx.cpp
d:\program files\microsoft visual studio\vc98\include\malloc.h(105) : error C2059: syntax error : 'constant'
d:\program files\microsoft visual studio\vc98\include\malloc.h(105) : error C2733: second C linkage of overloaded function '_calloc_dbg' not allowed
d:\program files\microsoft visual studio\vc98\include\malloc.h(105) : see declaration of '_calloc_dbg'
d:\program files\microsoft visual studio\vc98\include\malloc.h(106) : error C2059: syntax error : 'constant'
d:\program files\microsoft visual studio\vc98\include\malloc.h(106) : error C2733: second C linkage of overloaded function '_free_dbg' not allowed
d:\program files\microsoft visual studio\vc98\include\malloc.h(106) : see declaration of '_free_dbg'
d:\program files\microsoft visual studio\vc98\include\malloc.h(107) : error C2059: syntax error : 'constant'
d:\program files\microsoft visual studio\vc98\include\malloc.h(107) : error C2733: second C linkage of overloaded function '_malloc_dbg' not allowed
d:\program files\microsoft visual studio\vc98\include\malloc.h(107) : see declaration of '_malloc_dbg'
d:\program files\microsoft visual studio\vc98\include\malloc.h(108) : error C2059: syntax error : 'constant'
d:\program files\microsoft visual studio\vc98\include\malloc.h(108) : error C2733: second C linkage of overloaded function '_realloc_dbg' not allowed
d:\program files\microsoft visual studio\vc98\include\malloc.h(108) : see declaration of '_realloc_dbg'
d:\program files\microsoft visual studio\vc98\include\malloc.h(116) : error C2059: syntax error : 'constant'
d:\program files\microsoft visual studio\vc98\include\malloc.h(116) : error C2733: second C linkage of overloaded function '_expand_dbg' not allowed
d:\program files\microsoft visual studio\vc98\include\malloc.h(116) : see declaration of '_expand_dbg'
d:\program files\microsoft visual studio\vc98\include\malloc.h(125) : error C2059: syntax error : 'constant'
d:\program files\microsoft visual studio\vc98\include\malloc.h(125) : error C2733: second C linkage of overloaded function '_msize_dbg' not allowed
d:\program files\microsoft visual studio\vc98\include\malloc.h(125) : see declaration of '_msize_dbg'
Error executing cl.exe.
|
|
|
|
|
|
I tried, but i get not a filename in report:
filenae:(stringnumber) : bytes, {blockcount}, memory dump, but
#FileName Error# :(stringnumber)...
|
|
|
|
|
|
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <malloc.h>
#include <crtdbg.h>
|
|
|
|
|
Use < and > instead of < and > - your #includes are lost and I'm not going to search for them in HTML source.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanx!
The thing is - iv'e just found my memory lek. But the source problem still exists
|
|
|
|
|
does anyone know how can I make .hlp file ?
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject "
|
|
|
|
|
I *live* on DALNet. But I joined and was deoped and alone...
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Don't forget that the channle is new.
If I built it, thay will come.;)
and if you want op/aop/sop just ask PokiDoki (that's me )
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject "
|
|
|
|
|
Hey, cool. Can I be an op please ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
sure.
just come and ask PokiDoki
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject "
|
|
|
|
|
How can I find articles about programming with serial port, parallel port, and usb?
Thanks.
Maer
|
|
|
|
|
Considering the amount of postings from some people, one could think that some people tried The Code Project before they tried MSDN.
|
|
|
|
|
Hey people!
I'm writing a winsock app. in Visual C++. The application needs to run in the background of the system. ie: there is no window and it is not on the task bar. Any suggestions?
Carl
|
|
|
|
|
Don't create a window. Or don't make it visible.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
http://www.codeproject.com/docview/notaskbaricon.asp
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
What Windows versions do you need it to run on?
If you don't need to support Win9x, I would make a Service...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I am having problems trying to get another window modal (eg. Windows Paint, or Calculator) from my program.
Here's is my meathod:
- Get the window (CWnd*) by using the FindWindow(...) function
- Use BeginModalState() to make it modal...
However, this makes my program stop responding and only makes the other window modal to my program (not anyother window open).
I would be very greatful if someone could help me...
Thanks in advance,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
You can't do that for at least 2 reasons: the target window belongs to a different thread (2) which is owned by a different process.
But you can bring the window to the top by calling SetActiveWindow(), SetWindowPos(), BringWindowToTop(), etc. You might also want to FlashWindow() to get the user's attention.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Is there any way that I can take ownership of the thread - I saw 2 functions,
SetParent() and SetOwner(). Would this work?
I've also had another idea - could I modify the style of the window to WS_EX_TOPMOST using ModifyStyleEx()?
Thankyou for your help,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
I am writing an application to do some batch processing. Basically it uses CreateProcess() to create a processes (with the desired command line arguments) over and over a number of times. Each run produces a text file which i will compile together.
My problem however is that the process i am executing will perform its job and NOT close. If i call CreateProcess() while the application is still opened it ignores my arguments and does nothing, so i need to close between each execution.
Can anybody offer any suggestions as to how to detect when the process has completed the work. I am confident that i can tell it to close, im just not sure how to determine when.
The processing time is unpredictable. The cpu is used intensively during the operation. I attempted using the ForegroundIdleProc() hook function to flag me when the foreground thread went idle, however this does not seem to work (the function is hooked ok, as it is called when i close the app as well as scroll around in the app, it just doesnt call it when i want it to!).
Any suggestions would be greatly appreciated.
Alex Deem
|
|
|
|
|
Call WaitForSingleObject() on the process handle:
STARTUPINFO si = {sizeof(STARTUPINFO)};
PROCESS_INFORMATION pi;
if ( CreateProcess(..., &si, &pi) )
{
WaitForSingleObject ( pi.hProcess, INFINITE );
CloseHandle ( pi.hProcess );
CloseHandle ( pi.hThread );
} Your thread will block in the Wait call until the child process exits.
--Mike--
http://home.inreach.com/mdunn/
You are the weakest link, GOODBYE!
|
|
|
|