|
is this...
[CODE]
// .h file
class CduLine
{
static SolidBrush s_solidBrush;
...
};
actually this? (what is the CduLine class?)
[CODE]
// .h file
class DisplayLine
{
static SolidBrush s_solidBrush;
...
};
In CPP file, outside of any function...
SolidBrush DisplayLine::s_solidBrush(Color(255, 0, 255, 0));
|
|
|
|
|
Yes... My mistake... I was changing names to make things clear.
the definition is at the top of the file outside of any functions.
|
|
|
|
|
Geez at least SetColor should have worked
Beats me but I'll keep looking at it...I would expect it to work!
Mark
|
|
|
|
|
by my understanding of what i've found in msdn the folowing code should redirect the output of "ping www.google.com" to a file...and well...it doesn't. Where did i go wrong?
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInfo;
ULONG rc;
HANDLE hFakeStdOut = CreateFile(
"C:\\myfile.txt",
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if(hFakeStdOut==INVALID_HANDLE_VALUE)
{
printf("CreateFile failed with %d\n",GetLastError());
return;
}
memset(&StartupInfo, 0, sizeof(StartupInfo));
StartupInfo.cb = sizeof(STARTUPINFO);
StartupInfo.dwFlags = STARTF_USESTDHANDLES;
StartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
StartupInfo.hStdOutput = hFakeStdOut;//GetStdHandle(STD_OUTPUT_HANDLE);
StartupInfo.hStdError = hFakeStdOut;//GetStdHandle(STD_ERROR_HANDLE);
char sCurDir[1023];
GetCurrentDirectory(1023,sCurDir);
if (!CreateProcess( NULL,
"ping www.google.com",
NULL,
NULL,
TRUE,
NULL,
NULL,
NULL,
&StartupInfo,
&ProcessInfo))
{
printf("Failed with %d\n",GetLastError());
}
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc))
rc = 0;
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
CloseHandle(hFakeStdOut);
I've been reading about this for about an hour now and i can't get it. Please help
|
|
|
|
|
eusto wrote: if (!CreateProcess( NULL,
"ping www.google.com",
NULL,
NULL,
TRUE,
NULL,
NULL,
NULL,
&StartupInfo,
&ProcessInfo))
{
printf("Failed with %d\n",GetLastError());
}
I think that you should specify the full path to ping.exe (always a good habit, ask any *nix person, it prevents a command hijack), and put that path into the first parameter. Put the parameters to ping.exe (www.google.com) as the second parameter and see if that works.
I have had situations in the past where specifying everything as the command line fails, but breaking them up works. Dunno why, but try it.
Also, did you try using pipes as suggested in the MSDN article located at http://msdn.microsoft.com/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_output.asp[^]? Maybe it works with pipes but not with normal files? I would get the pipes version working first.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thanks but the full path is not the problem. Braking the args and actual module name did not work either.
This sucks msdn says that a handle can be anything that supports Read() and Write() so a hadle to a file created by CreateFile shoul work. I realy don't get it
|
|
|
|
|
The handle needs to be inheritable:
try
SECURITY_ATTRIBUTES SecurityAttributes;
SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
SecurityAttributes.lpSecurityDescriptor = NULL;
SecurityAttributes.bInheritHandle = TRUE;
HANDLE hFakeStdOut = CreateFile(
"C:\\myfile.txt",
GENERIC_WRITE,
FILE_SHARE_WRITE,
&SecurityAttributes,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL
);
|
|
|
|
|
Thanks...but it still does not work
|
|
|
|
|
if u want to redirect the out put u can use any of the following ways...
SHELLEXECUTEINFO stInfo = {0};<br />
stInfo.fMask = SEE_MASK_NOCLOSEPROCESS;<br />
stInfo.cbSize = sizeof(SHELLEXECUTEINFO);<br />
stInfo.lpVerb = _T("open");<br />
stInfo.lpFile = _T("cmd");<br />
stInfo.lpParameters = _T("/c ping www.google.com > c:\\result.txt");<br />
stInfo.nShow = SW_SHOW;<br />
ShellExecuteEx( &stInfo );<br />
WaitForSingleObject(stInfo.hProcess, INFINITE);
or
STARTUPINFO StartupInfo;<br />
PROCESS_INFORMATION ProcessInfo;<br />
ULONG rc;<br />
memset(&StartupInfo, 0, sizeof(StartupInfo));<br />
StartupInfo.cb = sizeof(STARTUPINFO);<br />
if (!CreateProcess( _T("c:\\windows\\system32\\cmd.exe"),<br />
_T("/c ping www.google.com > c:\\result.txt"),<br />
NULL,<br />
NULL,<br />
TRUE,<br />
NULL, <br />
NULL, <br />
NULL,<br />
&StartupInfo,<br />
&ProcessInfo ))<br />
{<br />
printf("Failed with %d\n",GetLastError()); <br />
}<br />
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);<br />
CloseHandle(ProcessInfo.hThread);<br />
CloseHandle(ProcessInfo.hProcess);
nave
|
|
|
|
|
|
Learn2LikeIt wrote: Exactly how does switch case work?
Exactly the way the tutorial describes it.
Keep at, hopefully it will begin to sink in. Also you might try this site[^]. But don't expect to actually "know" C++ in 21 days.
led mike
|
|
|
|
|
led mike wrote: But don't expect to actually "know" C++ in 21 days.
How how how how true .
|
|
|
|
|
Hi,
Could you specify what exactly gives you headache, please?
Regards
|
|
|
|
|
O.K well since I seem to be in the right forums I'm gonna have alot of questions scince I've never really used C++ or any other scripting language before. I hope I'm not a bother. Anywho I was wondering how functions can be applied, like can they have random things in them or do they follow a specific set? Generally I'd like to know a tad more on functions.
I'm a true failure.
|
|
|
|
|
Can you explain what do you need?
|
|
|
|
|
Learn2LikeIt wrote: I've never really used C++ or any other scripting language before.
First, C++ isn't a scripting language. Second, what books on C++ have you read?
The evolution of the human genome is too important to be left to chance.
|
|
|
|
|
How do i setup timers in a console application? Is it possible? does anyone know any tutorial on this matter?
Thanks
|
|
|
|
|
It is fairly simple. Take a look at the MSDN documentation for CreateTimerQueueTimer()
led mike
|
|
|
|
|
Thanks! Didn't know about this one
|
|
|
|
|
See here.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Second time this has happened eh? I say TimerQueueTimer and you say WaitableTimer. 6 to one tomatoes to another.
led mike
|
|
|
|
|
Either one would work ... I've just used WaitableTimers more than TimerQueues so I knew that one off-hand.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
You can also use SetTimer using a callback function. The only tricky bit is that you need to run a message pump as this is where timer callbacks are performed; most people don't know this and since must apps are GUI the lack causes no problems.
Steve
|
|
|
|
|
Hi,
I'm using OpenCV library to access a webcam and display images from it in my dialog based application. I use 'cvNamedWindow' to create a window and 'cvShowImage' to display it. I dont know how to change any properties of the window except its position. So how do i make the window be always on top?
If possible pls let me know how to display using cvShowImage in one of my dialogs or windows
Thnx in advance
nalintharanga
|
|
|
|
|
SetWindowPos(SWPTOPMOST, 0,0,0,0,SWP_NOSIZE | SWP_NOMOVE);
That's some pretty rusty memory I'm relying on. I'm already thinking it may be swpTopMost. Anyhow, google for SetWindowPos to find out what that first parameter is, I'm not confident of the others.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|