|
Is it your code or some other exe? If it's some other EXE, why can't you read the console ouput?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Let me explain what I am trying to do. I have one executable file that shows the tracking data at console as 0utput. I want to write a c++ code that can read the tracking data in loop from console. I want to use that tracking data in my own application.
I hope now the question is clear.
Wali
|
|
|
|
|
Perhaps it would be easier to understand your question if you told us exactly what you are trying to do.
Are you trying to determine how the application derives the output before it is actually written to the console?
|
|
|
|
|
Wajid Ali wrote: Is it possible to read that console output anyway?
Certainly. Read here and here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks! I will try it soon.
|
|
|
|
|
Use > operator at command prompt. For ex. if the file name is hello.exe use
c:\hello.exe>output.txt and all the console output will be stored in output.txt file.
Now you can use this file.
|
|
|
|
|
Hi, I've got 17 error codes to #define with some "context" for them and I'm searching for a quick way to do so.
Besides writing them out "longhand" I decided to try the paste (##) operator by doing this:
<br />
<br />
#define ERROR_CONTEXT_CODE(context,code) \<br />
#define ERR_##context (code+00) \<br />
#define ERR_##context##_ERROR1 (code+01) \<br />
#define ERR_##context##_ERROR2 (code+02) \<br />
#define ERR_##context##_ERROR3 (code+03)<br />
<br />
I expect to have about 8 contexts and 17 error codes per context. The context is important because when there is an error I'd like to trace it back to the (code+0x) value so I'd be able to pinpoint the error to, say, file access vs HTTP access (or whatever the context is).
I intend to this code
ERROR_CONTEXT_CODE(FILE,7100)
ERROR_CONTEXT_CODE(HTTP,7200)
to output:
<br />
#define ERR_FILE (7100+00) \<br />
#define ERR_FILE_ERROR1 (7100+01) \<br />
#define ERR_FILE_ERROR2 (7100+02) \<br />
#define ERR_FILE_ERROR3 (7100+03)<br />
<br />
#define ERR_HTTP (7200+00) \<br />
#define ERR_HTTP_ERROR1 (7200+01) \<br />
#define ERR_HTTP_ERROR2 (7200+02) \<br />
#define ERR_HTTP_ERROR3 (7200+03)<br />
I *think* I've made my intention clear at this point.
How can I accomplish this? I was thinking of incorporating the stringize(#) and paste(##) operators to do this.
(ed-Fixed a copy/paste error in second code block)
|
|
|
|
|
How would I go about using a windows style of WS_EX_COMPOSITED with an MFC View window? (I don't want to know about other methods of double buffering, just how to set this style.)
Thanks!
|
|
|
|
|
I would recommend reading the docs for CreateWindowEx() -
specifically anything there related to WS_EX_COMPOSITED.
To use the style in MFC, specify the WS_EX_COMPOSITED extended style
when calling CreateEx() to create a window.
This style can also be set in a window class' PreCreateWindow() override.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Thanks. Actually, I have already read up on that, and have no problem with WS_EX_COMPOSITED when not using MFC. However, I am not seeing the expected results when I use WS_EX_COMPOSITED with MFC. I am overriding the PreCreateWindow method for a View in a MDI Doc/View application:
BOOL CMyProgView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.dwExStyle &= WS_EX_COMPOSITED;
return CScrollView::PreCreateWindow(cs);
}
but I still get flickering when I draw the window by overriding the OnDraw method. In OnDraw, I'm using a GDI+ Graphics object, and I use the Graphics::Clear method before doing my drawing. There is no flickering when NOT using MFC, even using Graphics::Clear, if the WS_EX_COMPOSITED window style is used.
I thought maybe MFC was using some conflicting window styles, but don't know. Just wondered if something more was required, such as changing some other window style(s) to be compatible with WS_EX_COMPOSITED, or something like that.
Thanks again.
|
|
|
|
|
Californian2 wrote: cs.dwExStyle &= WS_EX_COMPOSITED;
Maybe try
cs.dwExStyle |= WS_EX_COMPOSITED;
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Oops. Nevertheless,
cs.dwExStyle |= WS_EX_COMPOSITED;
does not work. There does seem to be some window style conflict.
|
|
|
|
|
Hmmm that should work.
Maybe try forcing styles identical to your non-MFC version by calling
the base class PreCreateWindow() FIRST, then overwrite the style and exstyle
with your values, something like:
BOOL CMyProgView::PreCreateWindow(CREATESTRUCT& cs)
{
if (CScrollView::PreCreateWindow(cs))
{
cs.style <font color="Red">=</font> WS_CHILD;
cs.dwExStyle <font color="Red">=</font> WS_EX_COMPOSITED;
return TRUE;
}
return FALSE;
}
How are you forcing it to draw so you see flicker? During resizing? With a timer?
If that doesn't work, note that the default CScrollView window class style has CS_HREDRAW | CS_VREDRAW
set...I don't know if that effects this at all.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Sorry to take so long to get back on this. The problem does indeed seem to be related to scrolling. Mostly I have problems with Graphics::DrawImage with large bitmaps. Everything is fine (except for flickering when resizing by dragging the lower right corner of the window, and some other times), until I add cs.dwExStyle |= WS_EX_COMPOSITED in a PreCreateWindow override. Then, my image flickers and sometimes completely disappears when it is scrolled. It comes back if the window is resized, but is lost again when the window is scrolled.
I'm not having much luck overriding the base class PreCreateWindow with other styles, but I'll double check whether I'm doing that correctly.
Thanks for any help you can give.
-- modified at 12:23 Wednesday 19th September, 2007
|
|
|
|
|
Hello 2 everyone interested!
I am looking for a function to convert data from DWORD, float,double and SYSTEMTIME (if possible, this last one) into string.
In fact, I want to dump variables of those data types into a log file. I am using MFC, with CFile and <filename>.Write() function, which expects a string as a parameter.
If I try using filename.Write(LPWSTR(var))(LPCWSTR, or any other string types...) i get conversion errors (sometimes that it requires 'explicit cast').
Any ideas ?
|
|
|
|
|
have you tired sprintf_s( )
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
I have, now. It doesn`t work, although I include stdio.h. It accepts the header (I mean, it finds it to include it), but when encountering sprintf_s() in sais "undeclared identifier".
I have also tried _itoa_s()
Link provided: http://msdn2.microsoft.com/en-us/library/0we9x30h(VS.80).aspx
When compiling, it seems ok, but when the application comes to using that part of the code, I get an application error code, and Windows asking me to send the info to microsoft.
I think that perhaps because I try to convert an unsigned int (DWORD - 64-bit unsigned integer.), using an int-converting function, might result in some buffer overflows. Can anyone suggest an alternative to _itoa_s (for using with unsigned int vars)? I can`t figure it out which is the one...
I think I should mention that I`m writing code for a Smart Device (pocket pc) using WM5.
|
|
|
|
|
sprintf_s will do the trick, I use it all the time... you are doing something wrong in the code?
can you try sprintf, maybe the api i provided earlier is not supported for smart device development?
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
Routine Required header
sprintf_s, <stdio.h>
_sprintf_s_l
Compatibility
Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003
It seems that it doesn`t support Windows Mobile. Similar results for sprintf
back to _ui64toa_s, I get an error, stating that radix outside of 2;36.
The code is here:
char* buffer;
int Radiux;
_ui64toa_s(GPSData.dwSatellitesInView,buffer,65,Radiux);
GPSLog.Write("Sats View:",15); GPSLog.Write(buffer,3);
_ui64toa_s(GPSData.dwSatelliteCount,buffer,65,Radiux);
GPSLog.Write("Sats Count:",15); GPSLog.Write(buffer,3);
where the 2 vars to be converted are DWORD.
Ideas ?
|
|
|
|
|
update to this:
I have initialised Radiux with 5 (just... picked it) and it won`t get out with error.
But I get strange data, when logging i get squares instead of some characters, yet some numbers are displayed, too. Who can tell me what does Radiux do ? I don`t understand from the function's description, found here: http://msdn2.microsoft.com/en-us/library/0we9x30h(VS.80).aspx
|
|
|
|
|
you have to set the radix value, which would be 10 for decimal.
try int Radiux = 10;
also try not to hard-code values...how is buffer defined? if it's defined like an array, and not alloacted on the heap you might want to change your ocde to something like this.
char buffer[100] = {0};
const int Radiux = 10;
...
_ui64toa_s( GPSData.dwSatellitesInView,
buffer,
sizeof(buffer),
Radiux );
(*)The "={0}" is a quick way to zero out the array
(*) if you use const int, the compiler is smart enough to replace put in the value (in this case 10) everwhere the variable show up, so no actual storage is required for the Radiux
I hope this helps!!!
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
Thanks a lot, for the code sample and especially for tips about hardcoding (though I've copy-pasted code provided on msdn2.microsoft.com !
Now... how about double to string and more important systemtime to double ?
|
|
|
|
|
I am glad to hear you got something working!
But if you're using a fixed declared array like I showed you then it's better to use sizeof().
Also you can't use strlen on a zeroed out buffer, right? you will get a size of zero!!!
Moreover, you are reading data into the buffer, strlen is the wrong function to use, your code has a bug in it.
If you're using the buffer again, just make sure to zero it out before the call to _ui64toa_s( )
memset( buffer, 0 ,sizeof(buffer) );
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
Well, I now did write sizeof(buffer) instead of fix size, and I understand the benefits, thanks to you.
I wonder how you found out about me using strlen, was just a trial (it wasn`t that obvious for me that was wrong before trying it), and I've modified the post when I`ve discovered that it doesn`t work. Indeed,learned on the hard way, strlen on a buffer is a No-No.
Thank's for the tip about zeroing the buffer before calling _ui64toa_s(). It does ring a bell, now., though in my application this part of the code comes to execution only when data exists in all fields I convert, so it's not posibile to have to convert an old value. Anyway, for future practice...
Concerning double to string, I used var-(int)var (where var was of type: double) to get the integer part (which was... int) and used _itoa_s to convert it into a string, and the rest I started multiplying by 10 (I only needed 4 digits after .) .
SYSTEMTIME is a structure type, in which all components are of type WORD. So perhaps _itoa_s() - or someone in it`s family - will do the trick.
Thanks again for all your help!
Best wishes!
---
One chance in a million is still a chance!
|
|
|
|
|
hey all!
is RichText Box supports the emoticons like we ve got in Msn or Yahoo? if Yes thn wats the procedure to include them using codes? and wat about the source of that images?
|
|
|
|
|