|
As a simple trick you can assign size 0 to the intended columns,
using SetColumnWidth( nCol, 0 )
It works, but the user can enlarge the columns if he wants...
|
|
|
|
|
Bravoone_2006 wrote: I have 7 columns ,(0,1,2,3,4,5,6,7)
excuse me, but from 0 to 7 , it gives you 8 ones !!!
|
|
|
|
|
Hi,
In a current tool, that copies Sources from a server, zips them and sends the zip-File to another server, I have to delete the intermediate zip-Files stored locally about after a week (so that they still are available if the recipient claims a transfer failure).
I can't use CTime procedures for determining that week as the tool itself was created as Win32 console application without MFC support, so I tried to get the Local Time with GetLocalTime(&now), convert this to a FILETIME and compare it with the FILETIME got from the creation date of the file to decide wether this file is to be kept or deleted. According to the help pages FILETIME holds intervals of 100 nanosecond, so a week would calculate to 7(days)*24(hours)*60(minutes)*60(seconds)*1000(milliseconds)*1000(microseconds)*10(intervals of 100 nanoseconds) = 6048000000000 intervals.
The help pages tell me that I have to copy the FILETIME to a LARGE_INTEGER before I can compare the dates so I tried the following code:
LARGE_INTEGER liNow,liFile;
liNow.LowPart = ftNow.dwLowDateTime;
liNow.HighPart = ftNow.dwHighDateTime;
liFile.LowPart = localDateCreated.dwLowDateTime;
liFile.HighPart = localDateCreated.dwHighDateTime;
if(liNow.QuadPart - liFile.QuadPart > 6048000000000)
{ ... }
Now I have the problem that none of my files reach the deletion part of the code, even files two weeks old only have a difference of 1604372500. Is something wrong with my calculation, my conversion to LARGE_INTEGER or is the whole approach faulty?
Hope anyone can help me
Martin Dietz
|
|
|
|
|
How do you obtain the creation time of the file?
|
|
|
|
|
When I use FindFirstFile, and FindNextFile in the loop afterwards, I get a lot of data stored in a WIN32_FIND_DATA structure, among others creationtime, lastAccessTime and LastWriteTime.
Hmm... Maybe I used the wrong member and should try ftLastWriteTime, as this doesn't change when copying. I'll try that approach and call back later (or tomorrow)
|
|
|
|
|
m.dietz wrote: When I use FindFirstFile, and FindNextFile in the loop afterwards...
Are you then calling FileTimeToLocalFileTime() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Yes, as I'm calling GetLocalTime the File time has to be converted to Local Time too. It seems I just looked at the wrong filetime member of WIN32_FIND_DATA struct; after looking at ftLastWriteTime instead of ftCreationTime the files older than a week were correctly identified.
|
|
|
|
|
Take a look to:
FileTimeToSystemTime and related API's. Maybe are helpful.
|
|
|
|
|
It is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
SYSTEMTIME structure is far less useful for calculating timespans than FILETIME. At SYSTEMTIME, the help pages even recommend converting it to FILETIME and then to LARGE_INTEGER structures before comparing (exactly what I was trying to do), but as I wrote above, I'll try to use a different timestamp item on the file to see if that corresponds with the real file date. Maybe simply the files were not recognized as one week old because they were moved in between...
|
|
|
|
|
Both of you have reason.
That stated, the following code works pretty well:
#include "stdafx.h"
#include <windows.h>
int main(int argc, char* argv[])
{
OFSTRUCT ofs;
if (argc <2) return -1;
HFILE hFile;
hFile = OpenFile(argv[1], &ofs, OF_READ);
FILETIME ct, lat, lwt[2];
SYSTEMTIME locTime;
GetLocalTime(& locTime);
BOOL bSuccess= SystemTimeToFileTime( &locTime, &lwt[0]);
bSuccess= GetFileTime( (HANDLE)hFile, &ct, &lat, &lwt[1]);
LARGE_INTEGER li[2], liresult;
li[0].LowPart = lwt[0].dwLowDateTime;
li[0].HighPart = lwt[0].dwHighDateTime;
li[1].LowPart = lwt[1].dwLowDateTime;
li[1].HighPart = lwt[1].dwHighDateTime;
liresult.QuadPart=li[0].QuadPart-li[1].QuadPart;
if (liresult.QuadPart> 6048000000000L)
{
printf("more than a week\n");
}
CloseHandle((HANDLE)hFile);
getchar();
return 0;
}
The program compare the file given as its argument with the current system
time. I tested it.
What about your code? Maybe you're considering the wrong attribute (I don't believe you're modifying the files...)
|
|
|
|
|
It's exactly that: The files were copied to their location shortly before I took that debug attempt and so the "creation" time was just a few hours ago and I had too look for the "modification" time. After I changed the code to ftLastWriteTime (from the WIN32_FIND_DATA structure) I could identify the files older than a week without problems.
Thanks for your help
Martin Dietz
|
|
|
|
|
|
Hi all
I have a CObList which stores list of objects of type CMyClass. CMyClass has a CString member say m_str . This list is populated with members coming from a dll which is compiled in ANSI mode whereas the application is compiled in Unicode mode . So in the list , if i expand the member m_str of CMyClass , I can see in debug auto windows m_str->ATL::CSimpleStringT (unsigned short ,1)
if the object is Unicode . And if the object is from dll (ie ANSI)
It appears m_str->ATL::CSimpleStringT (char,0). My problem is how to retreive this difference programmatically to distinguish between ANSI objects and Unicode objects ?
I tried IsTextUnicode() but could not succeed ..may be due to wrong usage .
Could any one help me pls ?
-- modified at 5:32 Tuesday 21st November, 2006
-- modified at 5:33 Tuesday 21st November, 2006
-- modified at 5:34 Tuesday 21st November, 2006
redindian
|
|
|
|
|
Maybe this can help you:
#ifdef UNICODE
. . .
#else
. . .
#endif
|
|
|
|
|
Hi Viorel
Thanks . But my problem is to find out if a CString variable is ANSI one or Unicode one .
redindian
|
|
|
|
|
Use the IsTextUnicode() function. But see this function is not foolproof. Read what the documentation[^] says.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Not sure if it is possible, but is there a way to evaluate the String's XCHAR type at runtime? Conceptually, something like:
if( sizeof( m_str::XCHAR ) == sizeof( wchar_t ) ) { Unicode };
if( sizeof( m_str::XCHAR ) == sizeof( char ) ) { ANSI }; But I am not that familiar with the new CString classes to be able to help further.
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!)
|
|
|
|
|
Hi all,
First of all, I would like apologize for creating a new thread, but I'm getting desperate.
This is the scenario:
I have this structure:
<br />
static struct<br />
{<br />
int ConnectSock;
int ConnectState;
ULONG BytesTrans;
ULONG FileLength;
ULONG TimeMark;
char Request[STRING_SIZE];
char FileName[STRING_SIZE];
char PathName[STRING_SIZE];
char PCName[STRING_SIZE];
ULONG BytesRec;
} gConnectData[MAX_CONNECT];<br />
Before I populate the PCName variale, I do the following, get an open slot for the next connection:
<br />
int FindFreeSlot(void)<br />
{<br />
int i, s;<br />
for(i=0;i<MAX_CONNECT;i++)<br />
{<br />
s = gConnectData[i].ConnectSock;<br />
if(s==-1)<br />
return i;<br />
}<br />
return -1;<br />
}<br />
main()<br />
{<br />
...<br />
while(1)<br />
{<br />
i = FindFreeSlot();<br />
...<br />
}<br />
}<br />
I when populate the PCName variable of the structure with data:
Please note that the for loop is part of the while loop.
<br />
for(i=0;i<MAX_CONNECT;i++)<br />
{<br />
...<br />
strcpy((char*)gConnectData[i].PCName,(char*)strDest);<br />
...<br />
}<br />
Ok, I'll try an explain this the best I can:
The thing is that the variable i does not move in a sequence (because of the server having to know which connection it's communicating with), for instance if I print the following the output would be:
<br />
strcpy((char*)gConnectData[i].PCName,(char*)strDest);<br />
printf("\n### Connection Sock -> %d Int Value -> %2d PC NAME VALUE -> %s\n",Sock,i,(char*)gConnectData[i].PCName);<br />
Connection Sock -> 0 Int Value -> 0 PC NAME VALUE -> PCOne
next cycle
Connection Sock -> 1 Int Value -> 1 PC NAME VALUE -> PCTwo
next cycle
Connection Sock -> 1 Int Value -> 1 PC NAME VALUE -> PCOne
Does it make sense
Can anyone help??
Many thanx in advance
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Never mind .... I got it working ....
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
anyway, keep thinking to use the <pre></pre> tags to post code samples
|
|
|
|
|
Hi!
I´m using the Windows Forms Template and found some, in my oppinion, odd behaviour. Whenever I add something like an event to a component it´s added in the header file.
Aren´t those header files just supposed to hold declarations of methods etc?
The following is a snippet of the generated code in Form1.h:
#pragma endregion<br />
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {<br />
}<br />
private: System::Void dateTimePicker1_ValueChanged(System::Object^ sender, System::EventArgs^ e) {<br />
mopped->Text = dateTimePicker1->Value.ToLongDateString();<br />
}<br />
private: System::Void dateTimePicker1_Enter(System::Object^ sender, System::EventArgs^ e) {<br />
MessageBox::Show("Das ist ein Test");<br />
}
This code doesn´t really do anything and is just an attempt to fiddle out how things work in VS Express C++.
Well I hope someone is able to understand what I mean (in respect to my germanish english) .
Thanks,
Michael
|
|
|
|
|
C++/CLI tends to put it all in the .h, which is valid C++. I believe you can move it without problem to the .cpp.
Christian Graus - C++ MVP
|
|
|
|
|
Hi all, i have a tree control in which i want to show the
popup menu when someone right clicks on item.
so that i hadled the NM_RCLICK message but the pop up menu comes
somewhere near start button!!
the code is as follows
void CTreeViewDlg::OnNMRclickTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
NM_TREEVIEW* pNmTreeVew = NULL;
pNmTreeVew =(NM_TREEVIEW*) pNMHDR;
if(pNmTreeVew)
{
CPoint point;
point.x = pNmTreeVew->ptDrag.x;
point.y = pNmTreeVew->ptDrag.y;/*
HMENU hMenu = LoadMenu(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_MENU1));
if(hMenu)
{
TrackPopupMenu(hMenu,0,point.x,point.y,0,pTreeCtrl->m_hWnd,NULL);
}
}
}
What can be the problem with this code?
actually when i debugged the code it point.y shows some big value
so please tell what is the problem
Thanks and regards
Harshal
|
|
|
|
|
Hi,
it retrieves you coordinates for the screen and you need convert it to client. Use ScreenToClient method of treectrl:
void ScreenToClient(
LPPOINT lpPoint
) const;
-----------
Mila
|
|
|
|