|
_MSC_VER is the version of Visual c++. 1100 is VC5, I believe. Either way, it's used to write code which can target multiple VC++ versions, where the versions differ.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Its compiler version.
From MSDN :-
_MSC_VER Defines the compiler version. Defined as 1200 for Microsoft Visual C++ 6.0. Always defined.
|
|
|
|
|
jana_dhana wrote: #if _MSC_VER >= 1100 will do. what does the value signify?
It says that
If Microsoft Compiler Version is Greater than or equal to 1100 compile the statements that is wrapped in side the block, else don't compile. It's a conditional compilation statement.
|
|
|
|
|
I want to list all the files in a certain directory which were created "after" certain date. I've thousands of ever growing files in that directory. If i enumerate these files using FindFirstFile method and then sort these on the basis of date, it take enormous amount of time.
Can anyone tell me better technique to do so. Is it possible with MS-DOS 'dir' command. If yes, then how and also how can i execute that dos command programatically ?
Imtiaz
|
|
|
|
|
Imtiaz Murtaza wrote: Is it possible with MS-DOS 'dir' command. If yes, then how and also how can i execute that dos command programatically ?
Yes...
The following command list all files in time based ascending order...
Dir /OD /A C:
|
|
|
|
|
You can use DlgDirList that fill listbox with files/folders and also you can use attributes of files/folders.if you want to use this function you can see two examples on MSDN.
|
|
|
|
|
Imtiaz Murtaza wrote: If i enumerate these files using FindFirstFile method and then sort these on the basis of date, it take enormous amount of time.
Rather than add them all to some data structure, sort the data structure, and then process the ones at the top (or bottom) of the data structure, just check the date as you are enumerating the files. Something like:
FindFirstFile(...);
while (...)
{
if (file_create_date < cutoff_date)
add_to_list();
FindNextFile(...);
} Now the list will only contain those files that were created after a certain date.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi how can i change the color of the caption(Title) bar?
|
|
|
|
|
Use of SetSysColors with COLOR_ACTIVECAPTION , would be one solution. But it applies to all windows.
|
|
|
|
|
Do you need to customize caption?
|
|
|
|
|
I jus want to chage the color the caption bar
|
|
|
|
|
|
This application has lot of bugs,
When i removed maximized button the output doesnt
And also when i excuted the application first time color of the caption bar not changing and logo doesnt comes..
I tried it before i post a question .......
|
|
|
|
|
You can do it in the OnNcPaint function by getting Window DC ( GetWindowDC )
Search CP for articles. You will get many.
-Sarath.
"Unhappiness is best defined as the difference between our talents and our expectations" - Edward De Bono
|
|
|
|
|
i have been able to get my program to compile correctly and added in code to view the returned result of the dword value from GetFileAttributes() which should display the file attributes of the given file but when the function is called all it returns is an error message saying "the process cannot access the file because it is being used by another process." yet i made sure that before it was called i had closed the file before the function was called and even tried the function on a file that was never opened and it still gave the same error.
here is the code for my function:
<br />
ReportAttributes(char filename[])<br />
{<br />
LPCTSTR pszCaption = "Debug Results:";<br />
DWORD attribList = GetFileAttributes(filename);<br />
<br />
if(!attribList)<br />
{<br />
MessageBox("An Error Has Occured", pszCaption, MB_ICONWARNING);<br />
}<br />
else<br />
{<br />
const DWORD dwFormatControl = FORMAT_MESSAGE_ALLOCATE_BUFFER |<br />
FORMAT_MESSAGE_IGNORE_INSERTS |<br />
FORMAT_MESSAGE_FROM_SYSTEM;<br />
<br />
LPVOID pTextBuffer = NULL;<br />
DWORD dwCount = FormatMessage(dwFormatControl, <br />
NULL, <br />
attribList, <br />
0, <br />
(LPTSTR) &pTextBuffer, <br />
0, <br />
NULL);<br />
if(0 != dwCount)<br />
{<br />
MessageBox((LPCSTR)pTextBuffer, pszCaption, MB_ICONERROR);<br />
LocalFree(pTextBuffer);<br />
}<br />
else<br />
{<br />
MessageBox("Unknown error", pszCaption, MB_OK);<br />
}<br />
}<br />
}<br />
i varied the icons in the messagebox calls to see which one came up when the error was displayed.
|
|
|
|
|
swatgodjr wrote: "the process cannot access the file because it is being used by another process."
Exactly this is the reason. Make sure that this file is not being used by another application or background process, or create a temporary file and call this function on this file and see what happens. If the problem persists then make sure that you have not opened this file before this call.
|
|
|
|
|
yea as i explained i also tried this on a file i had not even touched at all and got the same error in doing so. is there maybe something wrong with my code i posted?
|
|
|
|
|
swatgodjr wrote: yea as i explained i also tried this on a file i had not even touched at all and got the same error in doing so. is there maybe something wrong with my code i posted?
Well this I got from MSDN...
If the function fails, the return value is INVALID_FILE_ATTRIBUTES . To get extended error information, call GetLastError .
Do check for this value instead of !dwFileAttributes.
|
|
|
|
|
actually i originally had it checking for INVALID_FILE_ATTRIBUTES but no matter what i did it kept giving me an error saying it was an undeclared identifier so i just put !attribList so that it would compile so that i could at least test it out. i included the files it needed and everything and after quite a bit of looking around i just left it the way i have it now. the code i posted was actually modified from my getlasterror function which works nicely.
|
|
|
|
|
I don't get your code.
First, check the return value from GetFileAttributes().
If it's 0xFFFFFFFF, then call GetLastError() to get the error code.
Then, do a FormatMessage with the return value from GetLastError()!
(It's natural you always gets the same error message when you always calls FormatMessage with the same value, 0xFFFFFFFF).
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
swatgodjr wrote: if(!attribList)
You must read the docs a bit closer:
if (INVALID_FILE_ATTRIBUTES == attribList)
{
MessageBox("An Error Has Occured", pszCaption, MB_ICONWARNING);
}
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i tried to use INVALID_FILE_ATTRIBUTES and it returns an error on compiling saying that it was an undeclared identifier and also tried checking for the other error code but that just gives me the same error message i have been having when the function is called in my program. i have the correct files being included into my program so i really am not sure why it wotn let me use INVALID_FILE_ATTRIBUTES. also from what i have noticed, it never returns either error message as it goes to the main body of the function like it should.
|
|
|
|
|
I need extra eyes on this. Below are two examples of some code I have. My application is slowing down over time, so I suspect resource / memory leaks. My tools indicate the following chunk of code leaks a DC. Do you see it? I don't. Look for <<<<<
CWaitDlg::UpdateCursor(CPaintDC *pDC, int nImage)
{
CDC dcBitmap;
dcBitmap.CreateCompatibleDC(pDC); // <<<<<<<< this is where the leak is allegedly.
CBitmap * pOldBitmap = dcBitmap.SelectObject(&m_WaitImages[nImage]);
pDC->BitBlt(m_nCenterX, m_nCenterY, m_Size.cx, m_Size.cy, &dcBitmap, 0, 0, SRCCOPY);
dcBitmap.SelectObject(pOldBitmap);
dcBitmap.DeleteDC();
}
Example #2: this chunk of code is supposed to leak a solid brush. This follows the
typical pattern of create, select it in, use it, deselect, delete.
.
.
.
CBrush brush;
brush.CreateSolidBrush(N_WHITE); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
CBrush *pOldBrush = dc.SelectObject(&brush);
dc.Ellipse(radioRc);
dc.SelectObject(pOldBrush);
brush.DeleteObject();
dc.SelectObject(pOldPen);
pen.DeleteObject();
.
.
.
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
fwiw - this code only reports a resource leak in a release build mode - debug does not report this issue. Even if I compile in release mode with no optimization, it is still reported, but debug never.
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
How did you determine that there was a resource leak? What is being leaked?
Steve
|
|
|
|