|
Anu_Bala wrote: AfxMessageBox(WSAGetLastError());
WSAGetLastError() returns an integer and you are passing it on to AfxMessageBox() . Talk about horror.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Make sure that WSAStartup() or AfxSocketInit() has been called successfully before you call any socket winsock functions.
cheers
Varghese Paul
|
|
|
|
|
Can anybody help me in finding the number of files in a particular folder.
I am using VS 6.0.
With regards
Deepu.
|
|
|
|
|
Do you need to CFileFind Class or FindFirstFile?
|
|
|
|
|
I am using CFileFind
Is that possible by using CFileFind::FindFile and CFile::FindNextFile.
If so can you tell me the procedure.
|
|
|
|
|
This exampl eis on the MSDN.
CFileFind finder;
BOOL bWorking = finder.FindFile(_T("*.*"));
while (bWorking)
{
bWorking = finder.FindNextFile();
TRACE(_T("%s\n"), (LPCTSTR)finder.GetFileName());
}
|
|
|
|
|
Hi Hamid and Machael
I came across a strange situvation
If i have to find the files in the "*.*" , it is working.But if i have to find in any other directories i have to append "\\*" to the end of the directory name and finally reduce the the count by 2;
CFileFind finder;
int NoOfFiles = 0;
BOOL bWorking =finder.FindFile( "D:\\Directory\\Subdirectory\\*") ;
while(bWorking)
{
bWorking = finder.FindNextFile();
NoOfFiles++;
}
NoOfFiles-=2;//Now it will give the actual number of files
}
why it so.I got the output but it is strange!!
|
|
|
|
|
Deepu Antony wrote: ...and finally reduce the the count by 2;
Most likely because you are counting the current and parent folders. Check out the CFileFind::IsDirectory() method.
"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
|
|
|
|
|
yes the first two values is directories.
But even if there are more than 2 directories
for eg e:\dir\subdir\subsubdir..
the first two values are showing only as directories.
still the count should be reduced by 2.
|
|
|
|
|
If you are only wanting to count files, then you must exclude those that are directories. If you are wanting to count everything except the current and parent directories, then you must exclude those directories whose name begins with a dot, like:
while (bWorking)
{
bWorking = finder.FindNextFile();
if (! finder.IsDots())
NoOfFiles++;
}
"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
|
|
|
|
|
Ah, but filenames can begin with a dot. It's best to check the attributes OR if the filename is nothing but dots.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Joe Woodbury wrote: Ah, but filenames can begin with a dot.
Of course, and I believe my comment accounted for that.
Joe Woodbury wrote: It's best to check the attributes...
Which is exactly what IsDirectory() and IsDots() does.
"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
|
|
|
|
|
Sorry, misread your comment.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Use FindFirstFile() and FindNextFile() to enumerate the files.
There are articles here on Code Project, there are also Google and MSDN. Search!
|
|
|
|
|
Hi there,
I have a CWnd derived class that displays bitmap data in its client area using the BitBlt function of a compatible CDC object.
This works fine in the usual case on one PC.
However, if I run my application on a remote PC using WinXP's Remote Desktop, the client area of my display CWnd is not updated, it displays instead a copy of the underlying windows contents.
Debugging (via Remote Desktop) the drawing process does not yield any error in the following procedure I use for drawing the content of my CBitmap *pbMyBitmapToDisplay:
{
CPaintDC dcpaint(this);
CRect rClient;
GetClientRect(&rClient);
CDC dc;
if (!dc.CreateCompatibleDC(&dcpaint)) {
return;
}
CBitmap* pOldBitmap = dc.SelectObject(m_pbMyBitmapToDisplay);
dcpaint.BitBlt(0, 0, rClient.Width(), rClient.Height(), &dc, 0, 0, SRCCOPY);
dc.SelectObject(pOldBitmap);
}
Can someone please give me a clue what is causing the strange display behaviour via Remote Desktop?
Kind regards.
Juri
|
|
|
|
|
What function is that code in?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The code is within the OnPaint() message handler of the CWnd.
|
|
|
|
|
Cool, thanks.
I would suspect the bitmap is not compatible with the DC
so the SelectObject call is failing.
How is the bitmap created? What class is it?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark, your questions already contain the wanted clue
The bitmap is a class derived from CBitmap.
For creation I use the CreateBitmap(..) member.
I suspect you want me to use the CreateCompatibleBitmap(pDC,...) where pDC is a pointer to a CDC which is compatible with my CWnd derived object I use to display the bitmap? I will try this.
Thx again
Juri
modified on Thursday, September 18, 2008 11:31 AM
|
|
|
|
|
JuriB wrote: I suspect you want me to use the CreateCompatibleBitmap(pDC,...)
If you're going to use a device dependent bitmap, then yes,
it HAS to be compatible with the device. If you choose to use
CreateCompatibleBitmap(), make sure you use the paint DC, not
the compatible DC (otherwise you'll get a monochrome bitmap).
For an alternative, use a DIBsection bitmap instead of a DDB.
You can select a DIBSection into a non-compatible DC.
For a DIBSection, use the CImage class instead of CBitmap.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Problem solved.
I have switched to drawing via a CImage object. This works fine now also when the application is run over Remote Desktop.
Thanks for your help Mark
Best regards
Juri
|
|
|
|
|
JuriB wrote: This works fine now also when the application is run over Remote Desktop.
Cool Thanks for the update!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi!
Does anybody use CEGUI(Crazzy Eddie's Graphical User Interface) here? CEGUI site( is down? I've some doubts. Where can I get a guidance regarding CEGUI?
|
|
|
|
|
|
I'm getting some errors in VS2008 while they dont happen in VS 2006.
There are three projects
1. dll project
2. library project
3. exe project
Second(library) and third(exe) projects use some functions of first(dll) project. Second(Library)is also used by third(exe) project.
During building second(Library) project i dont need to include
first(dll) in project settings under additional dll option in linker because i include this dll(dllname.lib) in project settings of third(exe) project.
When i build first, second and third(exe) projects in VC6 they are builded successfully without any error.
While if i build them in VS 2008(vc9) first and second build successfully while third(exe)gives some errors "unresolved external symbols".
These are the errors of those function of first dll which are used in second(library) project. But since i have include this dll in project setting(under linker) in exe project so linker should search their definitions here. I'm surprised why it's happening. I have set the option enable incremental linking in project settings of second and third projects.
Please suggest any solution.
|
|
|
|