|
s@tish wrote: Could please suggest any approach to read the dates greater than 2038.
Use COleDateTime.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
s@tish wrote: Date greater than 2038
Use COleDateTime: 1 January 100 – 31 December 9999
In theory you could use with your CDateTimeCtrl any date in the COleDateTime range.
Some things seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi All
how to convert LPBYTE to CString?Help me
|
|
|
|
|
cpvc++ wrote: how to convert LPBYTE to CString?Help me
If you are sure that LPBYTE contains a valid TCHAR* null terminated string then you can cast it to LPTSTR and assign to CString.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Nibu babu thomas can you give me example..
|
|
|
|
|
Other than actually typing it for you, he did.
PTBYTE name = _T("konnichiwa");
CString str = name;
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
The key thing to note here is the following qualifier:
Nibu babu thomas wrote: If you are sure that LPBYTE contains a valid TCHAR* null terminated string...
If you aren't absolutely sure about this then you could be in trouble. As a general principle, when you're serializing to and deserializing from a byte stream, it may be better to stick to a "char" or a "wchar_t" instead of "TCHAR" and then do the appropriate conversions. That's assuming you have complete control over the data stream (i.e. only your program writes to and loads from the data store). If you are implementing this on a web server extension for instance, or if you are loading the string from a file that can potentially be created and edited by other programs then you'll want to worry about text encoding and byte order marks.
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|
|
I have an MS Word COM-addin in which this example code
try
{
throw std::exception();
}
catch (std::exception&)
{
MessageBox(NULL, "Caught", "Caught", MB_OK | MB_ICONERROR);
}
works for Debug version, but crashes Word in Release version. Is this a problem with compiler flags? I have "Enable Exception Handling" option checked both in Debug and Release. Any help would be appreciated.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
|
Microsoft Word has probably installed a global Structured Exception Handler[^] and is catching the exception before your catch block.
Try changing your code to the following and tell me if it fixes your problem.
__try
{
throw std::exception();
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
MessageBox(NULL, "Caught", "Caught", MB_OK | MB_ICONERROR);
}
Best Wishes,
-David Delaune
|
|
|
|
|
hi....
im new to widgets....
i downloaded wxWidgets 2.8.9.....
i BUILD the wx.dsw file in all configurations....
but it failed in 4 configurations....namely
DEBUG DLL, RELEASE DLL, UNICODE DEBUG DLL AND UNICODE RELEASE DLL....
I DOWNLOADED THE SAMPLE "HELLO WORLD" wxWidgets
program from this site...... when i build it....
i get the error.....
...HelloWorld fatal error LNK1181: cannot open input file 'zlib.lib'
now what is the problem????
somebody please help me
|
|
|
|
|
Here[^] is an article about wxWidgets (it contains a section describing how to install it). It's a bit outdated but you can check if it is of any value to you.
|
|
|
|
|
There is a forum devoted exclusively to wxWidgets that is very good at helping wxForum[^]
Judy
|
|
|
|
|
Hi guys,
I'm using Visual Studio 2005 and I have few questions:
1. If I have function without parameters, what to do to skip () when invoking the function?
2. I have:
int Mem;
...
Mem = LocalAlloc(LHND, ...);
...
WriteFile(f, Mem,...)
Mem keeps address of memory block.
What expression to write in WriteFile(f, ???Mem,...) to write the memory block pointed by Mem in file?
3. Is there a way a class member field to be accessible just for reading without writing?
P.S. If you know the answer of at least 1 question, please share it.
modified on Friday, November 21, 2008 6:29 AM
|
|
|
|
|
akirilov wrote: 1. If I have function without parameters, what to do to skip () when invoking the function?
You can't. Why do you want to do such a thing ?
akirilov wrote: int Mem; - it keep address of memory block.
Why are you working with integers to store addresses ? Why not manipulate pointers directly, it will make your life much easier.
akirilov wrote: 3. Is there a way a class member field to be accessible just for reading without writing?
Make it private and provide a getter method and no setter method in the class.
|
|
|
|
|
Make it private and provide a getter method and no setter method in the class.
Invoking methods is slow. Is there any other way (Something like in Delphi - you can give read/write access to a member, without involving methods)?
Why not manipulate pointers directly, it will make your life much easier. Mainly, because I'don't know how and also I had problems with pointer arithmetics.
Anyway could you share a code fragment that will do the trick (with pointers) (if possible with int)?
|
|
|
|
|
akirilov wrote: Invoking methods is slow
no; using inline might help a little bit, and probably the compiler will optimize this also.
akirilov wrote: because I'don't know how
what a good occasion to learn.
This signature was proudly tested on animals.
|
|
|
|
|
akirilov wrote: Invoking methods is slow.
As a famous guy already said: "Premature optimization is the root of all evil". What it means here is that you try to have only optimization in mind even when it makes your code less readable or maintainable. Unless your function has to be called very often and is in a time critical part of your code, I think you can forget about the performances (and you can also rely on your compiler for a bit of optimizations).
If I take your way of thinking to the extreme, you can end up with one gigantic main function because you never wanted to make function calls...
akirilov wrote: Anyway could you share a code fragment that will do the trick (with pointers) (if possible with int)?
I think you should learn that because it provides type safety which is not the case when working with ints containing an address. What kind of data are you manipulating ? An array of ints ?
|
|
|
|
|
1. As far as i know there's no standard way to do that.
2. What do you mean? If you want the address of the Mem variable, then use &, so &Mem. If you store a memory location in Mem, then use a pointer type, like int *Mem, but if you want to convert int to a pointer, then you can use for example (void *)Mem.
3. You can declare const "variables" to which you specify a value and then it cannot be modified anymore. For example const int m_Constant;, you would give a value to this in the contstructor of yor class. If you want to modify a variable "inside" the containing class but not outside then declare it as protected or private amd supply either a Get method for it or a const reference to it. so if you have int m_variable; then you can do either const int &GetVariable() { return m_variable; } or you can do const int &m_constVariable; and initialize this in the constructor using m_variable.
|
|
|
|
|
2. With some code will be easier to explain:
int Mem;
...
Mem = LocalAlloc(LHND, ...);
...
WriteFile(f, (void *) Mem,...)
I receive exception during runtime, so my question is what expression to use so it will work properly (writes the pointed by Mem block to file)
|
|
|
|
|
Ok, new edit, i misread you there the first time. LocalAlloc gives you a handle to a memory location, not the memory location itself. Declare your variable as HANDLE, not int, since LocalALloc, unless specified differently, will give you a HANDLE. You have to use LocalLock and LocalUnlock to actually access the memory. But may i ask why you need to use LocalAlloc instead of new or malloc? So basicly, if you have to use LocalAlloc you have to LocalLock(handle), this will give you a void * pointer that points at the memory you allocated, you can feed this to WriteFile (didn't go into WriteFile itself so i assume you know what you are doing with that) and then use LocalUnlock to unlock the memory, also use LocalFree to free it.
modified on Friday, November 21, 2008 6:36 AM
|
|
|
|
|
LocalAlloc gives you a handle to a memory location, not the memory location itself
Actually, that depends on the first parameter.
In my case (for Windows Mobile) it always return the actual address, so it is OK.
|
|
|
|
|
As i said, "unless specified differently". So if you get a pointer at the memory location why do you store it in an int?
|
|
|
|
|
I agree. But if you insist, then you should just 'cast' it as a pointer when you Write -
<br />
WriteFile(...<br />
(long*)Mem,
...<br />
|
|
|
|
|
Can anyone tell me what is the main purpose of Dll? As we can get the data from Dll, can we put the data in Dll? I am not talking about code, talking about single Dll. If you know about Dll then please share your knowledge..
http://nnhamane.googlepages.com/
|
|
|
|