|
you're right, I had to read once more to discover in MFC FindFile opens the search but does not return the first file, so FindNextFile is needed to find even the first file; this is different from how Win32 works, and IMO quite confusing (FindFile should have been named PrepareFileSearch or something similar).
This also means the first reply (by Frank) is wrong, and the wrong count hasn't been explained yet.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thank you, David! I tried your code, and it works like a charm!!
I'm still not certain what was wrong with the original function, but that investigation has to wait for another day! Anyhow, thank you all for your help, David in perticular!
|
|
|
|
|
Mr_Gbg wrote: The code below is supposed to return 13.301 files for my image library...
According to what?
Mr_Gbg wrote: strDir +=+ _T("\\*");
What is +=+ ?
Mr_Gbg wrote: if(f.FindFile(LPCTSTR(strDir)))
Why the superfluous cast?
Mr_Gbg wrote: The code below is supposed to return 13.301 files for my image library, but
comes with 12.110... Can anybody see what my mistake is??[Rose]
To make sure your recursion logic is sound, you might try moving count outside of CountFiles() , either by making it global or a member variable.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Good Questions, both of them! Sloppy programming I guess is the answer. Fixed now, thanks!
I've tried the whole global count variable thing as well, I still can't see a way around this... Grrr!
|
|
|
|
|
what is telling you there would be 13.301 files?
and how many folders are there?
some ideas:
- hidden files (your code would see them all, or throw an exception, so can't really be that);
- maybe folders also count as files in the tool that said 13301;
- there may be something fishy with empty extensions;
- there might be a difference between * and *.*;
- there is something peculiar (and silly) in the way Windows treats wildcards in extensions; I don't recall the details.
- I wouldn't be surprised if some of the above would depend on the actual file system (FAT, NTFS, ...).
I suggest you try your tool and your code on a pretty small set of files and folders, and experiment a bit.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hey
I am opening the Disk Defragmenter from inside my C++ WIN32 app using the ShellExecuteEx function.
Now i want to make sure that the Disk Defragmenter is a modal dialog, so that User is not able to click any part of my app.
I set one window to EnableWindow(FALSE), but there are other frame windows which can be clicked by User and then the Disk Defragmenter will go hiding or to back ground.
Is there one generic way of making the Disk Defragmenter a modal window so that nothing else on the back ground can be clicked?
From the ShellExecuteEx function, i can get the process handle to Disk Defragmenter.
Thanks in advance.
|
|
|
|
|
You can try blocking using the following
WaitForSingleObject(m_hProcess, INFINITE);
This won't make DD modal, it will just block your app until DD is finished.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
I think I know how to do so in .NET, and I assume unmanaged code could do similar things:
- give your app a modal form F, and make it sufficiently large to hold DD's main form;
- let that form F call DD and set DD's main form's parent to F. I assume this function[^] does that.
Now DD itself should behave as a modal dialog to your app.
I have a managed app (C#) that does similar things with e.g. MS Word.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
On my computer I have various network connection wi-fi , ethernet , USB . Now I want to know the mac address and IP address of the connection and the Active network i.e. which is enabled
Trioum
|
|
|
|
|
Have you experimented with GetAdaptersInfo() , GetInterfaceInfo() , GetAdaptersAddresses() , GetNumberOfInterfaces() , etc?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I tried but only able to get MAC address. not understand to get IP address and not able to find active network .
Trioum
|
|
|
|
|
trioum wrote: not understand to get IP address and not able to find active network .
How about showing the code you used for this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
DWORD destRedColor = 0;
DWORD destBlueColor = 0;
DWORD destGreenColor = 0;
DWORD destAlphaColor = 0;
DWORD SrcRedColor = 0;
DWORD SrcBlueColor = 0;
DWORD SrcGreenColor = 0;
DWORD SrcAlphaColor = 0;
int src_const_alpha = 0;
for ( int i = ( ( bm.bmWidth * bm.bmHeight ) - 1 ); i >= 0; --i )
{
COLORREF clrRef = ptPixels[i];
clrRef = COLORREF2RGB( clrRef );
DWORD redDest = GetRValue( clrRef );
DWORD greenDest = GetGValue( clrRef);
DWORD blueDest = GetBValue( clrRef);
BYTE *ptrAlphaDest = reinterpret_cast<BYTE*>( &clrRef );
DWORD alphaDest;
alphaDest = ptrAlphaDest[0];
DWORD redSrc = GetRValue( _cNewColor );
DWORD greensrc = GetGValue( _cNewColor );
DWORD blueSrc = GetBValue( _cNewColor );
BYTE *ptrAlphaSrc = reinterpret_cast<BYTE*>( &_cNewColor );
DWORD alphaSrc;
alphaSrc = ptrAlphaSrc[0];
src_const_alpha = int( m_intensity * 2.55 );
SrcRedColor = redSrc * src_const_alpha / 255.0;
SrcGreenColor = greensrc * src_const_alpha / 255.0;
SrcBlueColor = blueSrc * src_const_alpha / 255.0;
SrcAlphaColor = alphaSrc * src_const_alpha / 255.0;
destRedColor = SrcRedColor + ( 1 - SrcAlphaColor ) * redDest;
destGreenColor = SrcGreenColor + ( 1 - SrcAlphaColor ) * greenDest;
destBlueColor = SrcBlueColor + ( 1 - SrcAlphaColor ) * blueDest;
destAlphaColor = SrcAlphaColor + ( 1 - SrcAlphaColor ) * alphaDest;
ptPixels[i]
= (destAlphaColor << 24 ) |
(destRedColor << 16 ) |
(destGreenColor << 8 ) |
(destBlueColor);
}
|
|
|
|
|
I expect there is a question in here somewhere but I can't quite see it.
I must get a clever new signature for 2011.
|
|
|
|
|
Perhaps elaborate on what you are trying to do so that we can help you better.
Also note that Bitmap pictures pad each scanline to a multiple of 4 bytes.
If your bitmaps are 32bit, then you can ignore this.
That is if your picture is 5 pixels wide, each pixel taking 3 bytes (24 bits) then each scanline would be 5 * 3 = 15bytes wide.
Since that is not a multiple of 4 some bytes (1 in this case) are added to align the next scanline.
Note: The MSDN page for BITMAP[^] says they are WORD (2 byte) aligned, but from previous experience I have found that they are DWORD (4 byte) aligned.
This means that you must iterate through bm.bmHeight , and then for each iteration of that, iterate through bm.bmWidth .
BYTE *pBitmapData = (BYTE *)XXX;
int nBytesPerPixel = bm.bmBitsPixel / 8;
for (int y = 0; y < bm.bmHeight; ++y) {
for (int x = 0; x < bm.bmWidth; ++x) {
COLORREF clrRef = *((COLORREF *)pBitmapData);
pBitmapData += nBytesPerPixel;
}
pBitmapData += (nBytesPerPixel * bm.bmHeight + 3) & 3;
}
|
|
|
|
|
Actually there is one Picture In Picture( PIP ) module in the application. There is a shadow functionality is available with masking for the front layer. My mask( like heart shape ) is a bitmap file ( of 32 bpp ) which is put in the place of front layer( picture ). It's shadow looks like the same.
We can give shadow color of my choice as well( it is a provision ). Shadow will have selected color. So as it should be shown a transparent look I have used AlphaBlend() function to show transparent and semi-transparent pixels present in mask bitmap.
For the BLENDFUNCTION structure( m_blendfunc ) I given at Initialization
m_blendfunc.BlendOp = AC_SRC_OVER;
m_blendfunc.BlendFlags = 0;
m_blendfunc.SourceConstantAlpha = 0;
m_blendfunc.AlphaFormat = AC_SRC_ALPHA;
We can change the intensity of shadow as well( it's a provision ). It's rage from 0 to 100.
So that In OnPaint() I have changed the SCA value as per intenisty value.
m_blendfunc.SourceConstantAlpha = int( m_intensity * 2.55 );
As per the MSDN I have taken the red, green, blue and alpha value from Source( mask bitmap ) and mix up with destination colors ( of selected shadow color ) by this type of calculation
Src.Red = Src.Red * SourceConstantAlpha / 255.0;
Src.Green = Src.Green * SourceConstantAlpha / 255.0;
Src.Blue = Src.Blue * SourceConstantAlpha / 255.0;
Src.Alpha = Src.Alpha * SourceConstantAlpha / 255.0;
Dst.Red = Src.Red + (1 - Src.Alpha) * Dst.Red
Dst.Green = Src.Green + (1 - Src.Alpha) * Dst.Green
Dst.Blue = Src.Blue + (1 - Src.Alpha) * Dst.Blue
Dst.Alpha = Src.Alpha + (1 - Src.Alpha) * Dst.Alpha
The shadow is not getting proper it's look like some type of animation when I change the intesity.
Are I am making any mistake for taking source and destination colors or there is some mistake in calculation of new colors.
I have tried ur suggetsion of iterating through bitmap height & width but the result is same.
|
|
|
|
|
Hi!
How to represent Unicode strings? I want to enter e.g "UserName" in an XML file. How to represent the above string in the XML file using Unicode? I also have to read and display this string from C++ and display its Chinese and Korean representation. How to do this?
|
|
|
|
|
Unicode is merely text, you do not need to do anything special apart from ensuring that your project uses Unicode as its standard for all character based fields. To display Korean, Chinese or any other Asian language you just need to use a font in that specific language.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi!
If I've a label called "label1" and its Text(Read from XML file) as "UserName",
then will the following suffice to display "UserName" in Chinese?
label1->Font = "Required Chinese Font"
|
|
|
|
|
It looks like you're confusing UNICODE issues with translation ones. You need to translate the text into Chinese, using the proper UNICODE characters.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
As Carlo notes below, you will need the word "UserName" in Chinese to start with.
I must get a clever new signature for 2011.
|
|
|
|
|
Richard MacCutchan wrote: As Carlo notes below, you will need the word "UserName" in Chinese to start with.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You were below when I was composing my message; only after I posted did I notice ...
I must get a clever new signature for 2011.
|
|
|
|
|
(pardon).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
pix_programmer wrote: How to represent the above string in the XML file using Unicode?
For storing strings in XML file, you should best encode them as UTF-8.
pix_programmer wrote: I also have to read and display this string from C++ and display its Chinese and
Korean representation.
By "display" I guess you mean using Win32 API. In that case, you'll need to convert the text you read from the XML file from UTF-8 to UTF-16, set a font that supports the script your text belongs to and draw it on the screen.
|
|
|
|