|
Hi,
In my database date is in text format (like 20030704)
and i've to display that date in CDatetimeCtrl, after getting year month and date i am assigning that to control as follows
CTime tm(yr,mn,dd,0,0,0);
CDateTimeCtrl.SetTime( &tm );
It is showing correct in case year is above 1970, and
showing currentdate if year is 1970-
'What could be the reason and any suggesstions how to solve it??
With Thanks and Regards
--Kamesh
|
|
|
|
|
CTime doesn't support dates before Jan 1st, 1970. This is due to the C runtime library not supporting these dates in the time_t type. Use COleDateTime instead of CTime to get a greater time range.
Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
If we keep on posting the same answers at the same time, I'll quit.
~RaGE();
|
|
|
|
|
Rage wrote:
If we keep on posting the same answers at the same time, I'll quit.
Don't do that!
I find that that happens a lot - I'm always posting at the same time as other people. I think it's just me
OT: I think I've got the record for the fastest reply . I posted a reply to a message last night so quickly that it showed up when the guy who posted the original message got back to the forum page after sending his message How's that for posting speed?
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I did not check back, but if I remember well, 1970 is the lowest date you can have in a CTime. So maybe you should use a COleDateTime, which is also DateTimeCtrl compliant and which can contain any date/time.
~RaGE();
|
|
|
|
|
I'm trying to develop a cad system using MFC and OpenGL. Since I'm not an expert, can anybody explained what is the best way to do plotting.. as we know cad drawing can be very big.. most example translate the opengl drawing into DIB but this wouldn't be practical when we have big drawing as it will require huge amount of memory. Anybody got any idea ro solution maybe. or do i should thick to translating the drawing to DIB?
Thanks
p/s: sorry for my english.
|
|
|
|
|
Hi,
I have a SDI application with a listcontrol. Some fields must be in BOLD.
I have tried something with LOGFONT, but when i try to get the current logfont?, Windows gives a error at the moment that the application starts.
gxListCtrl::gxListCtrl (CString Text) <br />
{<br />
...<br />
LOGFONT lfFont;<br />
GetFont()->GetLogFont(&lfFont);<br />
Regards,
Willem
|
|
|
|
|
whofmans wrote:
Windows gives a error at the moment that the application starts
Maybe that's because you make your call to GetFont() too early, and that no font had been loaded yet. Where does the app hang when debugging ?
~RaGE();
|
|
|
|
|
GetFont() doesn't return a valid value until the control is created. The earliest you can call the GetFont() function is from the control's OnCreate() handler.
Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Thanks for your help! Bold looks good.
|
|
|
|
|
I have opened a file and have a handel . Now how can i get file name back from that handel?
API GetFileInformationByHandle() returns lot of things but not file name...is there any other API that can help me out ??
thanks
|
|
|
|
|
If I remember correctly you cant in user mode, only in kernel mode.
if someone knows how to do it in kernel mode, I would very much like to know.
But if you have opened the file, then you should already have the file name.
Magnus
|
|
|
|
|
I did some research and found a way of doing it with a kernel call from user mode. Code below.
I would like to thank Felix Kasza as its his code to enumerate NTFS streams that I adapted to get the file name instead.
This is the actual code, that I have tested and it works on Win2000 Pro with .NET 2003. The filename you recive is in UNICODE. And this code have no error handling or cleanup. Thats left as an exercise for the reader
void Test()
{
NQIF nqif = NULL;
HMODULE hNtdll = LoadLibrary( "ntdll.dll" );
if ( hNtdll < (HINSTANCE) 33 )
{
return;
}
nqif = (NQIF) GetProcAddress( hNtdll, "ZwQueryInformationFile" );
if ( nqif == NULL )
{
FreeLibrary( hNtdll );
return;
}
HANDLE h = ::CreateFile( "D:\\series.txt", GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
DWORD rc;
IO_STATUS_BLOCK iosb;
FILE_NAME_INFORMATION* fni;
void* pMem = new char[1024];
fni = (FILE_NAME_INFORMATION*)pMem;
fni->FileNameLength = 1000;
rc = nqif( h, &iosb, fni, 1024, FileNameInformation );
if ( rc != 0 )
{
return;
}
fni->FileName[ fni->FileNameLength / 2 ] = L'\0';
}
You also need the following defs if you dont have the DDK.
typedef LONG NTSTATUS;
typedef struct _IO_STATUS_BLOCK {
union {
NTSTATUS Status;
PVOID Pointer;
};
ULONG_PTR Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
typedef enum _FILE_INFORMATION_CLASS {
FileDirectoryInformation = 1,
FileFullDirectoryInformation,
FileBothDirectoryInformation,
FileBasicInformation,
FileStandardInformation,
FileInternalInformation,
FileEaInformation,
FileAccessInformation,
FileNameInformation,
FileRenameInformation,
FileLinkInformation,
FileNamesInformation,
FileDispositionInformation,
FilePositionInformation,
FileFullEaInformation,
FileModeInformation,
FileAlignmentInformation,
FileAllInformation,
FileAllocationInformation,
FileEndOfFileInformation,
FileAlternateNameInformation,
FileStreamInformation,
FilePipeInformation,
FilePipeLocalInformation,
FilePipeRemoteInformation,
FileMailslotQueryInformation,
FileMailslotSetInformation,
FileCompressionInformation,
FileObjectIdInformation,
FileCompletionInformation,
FileMoveClusterInformation,
FileQuotaInformation,
FileReparsePointInformation,
FileNetworkOpenInformation,
FileAttributeTagInformation,
FileTrackingInformation,
FileMaximumInformation
} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
NTSYSAPI
NTSTATUS
NTAPI
ZwQueryInformationFile(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass
);
typedef struct _FILE_NAME_INFORMATION {
ULONG FileNameLength;
WCHAR FileName[1];
} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
typedef DWORD (__stdcall *NQIF)(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass
);
|
|
|
|
|
Well done! The only "problem" (as you probably realise) is that it only works on Win2k or later. FileNameInformation is not supported under NT4 or earlier (well, it's not in the NT4 DDK anyway )
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
No I didnt infact as I only have the 2000 pro ddk. Its to bad the DDK documentation isnt as good as the SDK one. Do you know of anyplace where you can easy find out os dependecy for kernel calls? I have looked in the MSDN docs but couldnt find any info.
And I also tried downloading an older DDK, but MS says its not needed any more, that you can use Win XP's DDK (which is bogus if you need to do drivers for NT4). So if any one know where I can get older DDK's (I have 2000 pro and XP and 2003 server).
Magnus
|
|
|
|
|
I've never actually done any DDK development. I just remembered that the docs for the NT4 DDK came with the copy of MSDN library I got with VS6. Anyway, I just looked up that function, and found no mention of getting the filename, so I assumed it wasn't supported.
Magnus Westin wrote:
And I also tried downloading an older DDK, but MS says its not needed any more, that you can use Win XP's DDK (which is bogus if you need to do drivers for NT4).
MS don't support NT4 any more, so they assume that nobody else should either
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Thanks alot ..it seems it will serve my purpose...
|
|
|
|
|
void CFDDDlg::OnClose() //A function to destroy the dialog
{
......
if(MessageBoxEx(NULL,"Are you sure to destroy the dialog?","Warning",
MB_YESNO,
0x0409 // language identifier:English
) ==IDNO )
Some Operations to Wait until a varible "m_bStop" is "true"
CDialog::OnClose();
}
What way can make the function to wait?
And that won't stop any other function from going on while waiting to execute CDialog::OnClose();
|
|
|
|
|
I'm not sure exactly what you want. Does your program have multiple threads? If not, then you can't just wait there. If you do, your entire program will stop executing - nothing will happen. If you're using multiple threads, you're better off using an event or a mutex and using WaitForSingleObject() /WaitForMultipleObjects() .
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Yeah,I am using multiple threads.
Thank you! I'll have a try.
|
|
|
|
|
What is the regexp to find (in VC++ 6.0) all occurencies of MyVariable = and not MyVariable == ? Seems like MyVariable* =\~= does not work.
~RaGE();
|
|
|
|
|
MyVariable =[^=] should do the trick.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
MyVariable =[^=] should do the trick.
Thanks, but nope, I had already tried that, and it's surprisingly not working...
~RaGE();
|
|
|
|
|
How doesn't it work? I tested it before I replied and it worked perfectly for me. If there's more than one space between MyVariable and the '=' then it won't work, but then you'll just need to use '\:b*' instead of ' ' in the rule.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I know that, but it did not work either.
~RaGE();
|
|
|
|
|