|
Peter Molnar wrote:
The CString is part of the Win32 library in VS 7.0 and upwards
CString is still part of MFC/ATL, though you can use it by simply including atlstr.h .
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Using memory mapped file functionality, map the destination file. Then search it using one of the following implementations of a Boyer-Moore text search:
const char* TextSearch(const char* pSearchStr, const char* pStr, int textLen)
{
if (!pSearchStr || !*pSearchStr)
return pStr;
if (!pStr || !*pStr)
return NULL;
if (textLen < 0)
textLen = (int)strlen(pStr);
int searchStrLen = (int)strlen(pSearchStr);
int pSkipTable[256];
int i;
for (i = 0; i < 256; i++)
pSkipTable[i] = searchStrLen;
for (i = 0; pSearchStr[i]; i++)
pSkipTable[(BYTE)pSearchStr[i]] = searchStrLen - 1 - i;
register int right = searchStrLen - 1;
while (right < textLen)
{
int j;
for (j = searchStrLen - 1, i = right; j >= 0 && pSearchStr[j] == pStr[i]; j--)
i--;
if (j == -1)
return &pStr[i + 1];
right = max(i + pSkipTable[(BYTE)pStr[i]], right + 1);
}
return NULL;
}
const char* TextSearchNoCase(const char* pSearchStr, const char* pStr, int textLen)
{
if (!pSearchStr || !*pSearchStr)
return pStr;
if (!pStr || !*pStr)
return NULL;
if (textLen < 0)
textLen = (int)strlen(pStr);
int searchStrLen = (int)strlen(pSearchStr);
int pSkipTable[256];
int i;
for (i = 0; i < 256; i++)
pSkipTable[i] = searchStrLen;
char* pSearchStrUpper = (char*) _alloca(searchStrLen);
memcpy(pSearchStrUpper, pSearchStr, searchStrLen);
CharUpperBuffA(pSearchStrUpper, searchStrLen);
char* pSearchStrLower = (char*) _alloca(searchStrLen);
memcpy(pSearchStrLower, pSearchStr, searchStrLen);
CharLowerBuffA(pSearchStrLower, searchStrLen);
for (i = 0; i < searchStrLen; i++)
{
pSkipTable[(BYTE)pSearchStrUpper[i]] =
pSkipTable[(BYTE)pSearchStrLower[i]] = searchStrLen - 1 - i;
}
register int right = searchStrLen - 1;
while (right < textLen)
{
int j;
for (j = searchStrLen - 1, i = right; j >= 0 &&
(pSearchStrLower[j] == pStr[i] || pSearchStrUpper[j] == pStr[i]); j--)
i--;
if (j == -1)
return &pStr[i + 1];
for (j = searchStrLen - 1; j >= 0; j--)
{
if (pSearchStrLower[j] == pStr[i] || pSearchStrUpper[j] == pStr[i])
{
right = max(i + pSkipTable[(BYTE)pStr[i]], right + 1);
break;
}
}
if (j < 0)
right = max(i + searchStrLen, right + 1);
}
return NULL;
}
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I am getting this error when a specific class reaches the destructor in debug mode.
_CrtIsValidHeapPointer(pUserData)
The class is a template class, and the memory is allocated in the constructor of the class. There are no problems in Release mode, but I don't want to write the rest of this application without using the debugger. Is there a way of either turning this off, or convincing the computer that the memory actually exists in the heap?
If this is a common error, maybe some insight as to causes for receiving it would be great. Thanks a lot for any help!
I have never failed when programming. Instead I have succeeded in finding thousands of ways of crashing a computer!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
I'm currently working on a project,wherein i have to display the Tree structure of the directories as it is in (WINDOWS EXPLORER).Can anyone tell how to access the SHELL in Win32 Api(VC++) as im working in this platform.
NO MFC please..
|
|
|
|
|
|
Thanx for the link...but i'm working in plain win32 Api "NO MFC"...anyways thanx again for the help..if u find anything that has no MFC for displaying folders using SHELL in WIn32 please send me some reference..
|
|
|
|
|
MFC is nothing but a wrapper over the win32, so if you understand what that link is trying to say you can convert that logic into win32 calls in ur application.
but if you looking for spoon feeding anwers, then wait let me get my spoon.
The World is getting smaller and so are the people.
|
|
|
|
|
How can I get this icon into an application?
Is there any way I can use SHGetFileInfo() without knowing a head of time the name of any document in particular?
Thanks
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
1.
The path to the file containing the HTML icon can be found in the default value of the foloowing registry key:
HKEY_CLASSES_ROOT\htmlfile\DefaultIcon
which usually "C:\Program Files\Internet Explorer\iexplore.exe,1", that is the first icon stored in the iexplore.exe. You can extract it from there.
2.
Take a screenshoot of windows explorer when it shows an HTML file, and add this bitmap to your project.
3.
Alternatively you can feed an CImageList with all the default icons, among others with the html default icon:
HIMAGELIST hSystemImageList;
SHFILEINFO ssfi;
hSystemImageList = (HIMAGELIST)SHGetFileInfo((LPCTSTR)_T("c:\\"),0,&ssfi,sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_ICON);
m_ImageList.Attach(hSystemImageList);
pListCtrl->SetImageList(&m_ImageList,LVSIL_NORMAL);
And to find a path's index in the ImageList:
SHGetFileInfo((LPCTSTR)sPathToYourFile,0,&sfi,sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_ICON );
pListCtrl->InsertItem(nInsertPos,sPathToYourFile,sfi.iIcon);
where sPathToYourFile should contain a valid path to an html file.
Peter Molnar
|
|
|
|
|
Peter Molnar wrote:
HKEY_CLASSES_ROOT\htmlfile\DefaultIcon
Cool, thats what I was looking for
Thanks
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
Hi!
I want to duplicate an object previously instanced:
<br />
CMyClass* pMyVar1=new CMyClass ();<br />
pMyVar1->Var="Value";<br />
CMyClass* pMyVar2=new CMyClass ();<br />
CopyMemory (pMyVar2, pMyVar1, sizeof(pMyVar1));<br />
This code doesn't work, because I think that the sizeof is not correct.
Is there a way to copy an object with all his values?
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
Something along the lines of
*pMyVar2 = *pMyVar1;
I just made a simple program that does the same thing and it works.
#include <iostream>
using namespace std;
class Class1
{
public:
int var1;
int var2;
};
int main()
{
Class1 * object1 = new Class1();
Class1 * object2 = new Class1();
object1->var1 = 1;
object1->var2 = 3;
object2->var1 = 2;
object2->var2 = 4;
cout << "Object1 Var1 = " << object1->var1 << endl;
cout << "Object1 Var2 = " << object1->var2 << endl;
cout << "Object2 Var1 = " << object2->var1 << endl;
cout << "Object2 Var2 = " << object2->var2 << endl << endl;
*object2 = *object1;
cout << "Object2 Var1 = " << object2->var1 << endl;
cout << "Object2 Var2 = " << object2->var2 << endl;
delete object1;
object1 = NULL;
delete object2;
object2 = NULL;
system( "pause" );
return 0;
}
object2 was switched in the output so I don't know why it wouldn't work for a more complicated class.
The question "Do computers think?" is the same as "Can submarines swim?"
DragonFire Software
Jeryth
|
|
|
|
|
In theory what you did "could" work but in practice it is breaking so many rules that you should never do it.
In your case, "*pMyVar2 = *pMyVar1" should work, however, that assumes that if a default assignment operator isn't defined, that the default one (of just copying the elements blindly) would work. Many times it will not for an assortment of reasons. In those cases, you have to define your own assignment operator to handle the operation properly.
IMHO, the default assignment operator is more trouble than it is worth. Many people will thwart the default assignment operator if you shouldn't be performing that operation on the class. If your class can be used with an assignment operator, go to the trouble of defining one.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Very true, I hadn't thought of default = difficulties originally. If your class is just a bunch of int , double , etc the default = operator should work. But if you have char arrays, string s and other more complicated vars, definitely define your own = operator.
The question "Do computers think?" is the same as "Can submarines swim?"
DragonFire Software
Jeryth
|
|
|
|
|
Thks!
I've defined my own = operator for my class and it works now.
|
|
|
|
|
Hi All,
I have two DLLs. One is an MFC extension dll that is using MFC serialization with CArchive. Another one is a COM component. I am using MFC DLL from COM DLL in order to initialize some data. Data is supposed to be serialized. However, MFC serialization fails in MFC code when it tries to find a runtime class object in a list of its runtime classes. It cannot find one and returns NULL which then throws an exception. When I use MFC DLLs from another MFC application to do exactly the same thing (serialize data on the same class), everything works perfectly fine.
Should I do something else when I use MFC DLL from COM component? Please note, COM component has been created to support MFC.
I will appreciate any help on this subject.
Thank you All.
|
|
|
|
|
Hi,
I'm working on a chat program that uses TClientSocket & TServerSocket.
With these I guess the only way to send 'loose' information is with Socket->SendText and for FileTransfer use Socket->SendStream...?!
Now I've made a protocol, something like:
-Client opens connection to server<br />
-Server Acknowledges<br />
-Client sends login-request (LOGIN, USERID, USERPASSWORD, USERIP)<br />
-Server returns if user == ... etc
...okay, what is the best option to send this? With a String, a Buffer or...?! And IS this a good way to do this at all?!
And then what is the best way to 'read' the protocol...
With switch() or with if's... or a better way?
Thx a million in advance,
Jeroen(NL)
|
|
|
|
|
|
I have scanned msdn for a level 9.0 or 9.0b DirectX SDK that's available on CD and can't find it. The product is available as a 200+ MB download, but I would only do that if I were leaving for a two day holiday! Does anyone know where I can obtain a CD containg DirectX (for C++/MFC and Win32 development).
Many thanks for any help in this regard.
TFB
|
|
|
|
|
I have it on CD, it came with a book I got on DX 9.0 Rendering Engines. It's the DX 9.0a SDK I'm pretty sure. I've got the 8.1 SDK too if you like. If you'd trust me with an address I suppose I could mail you a burned CD of it. Wow, it'd actually be legal too since it's a free DL anyway! Just use the contact link on my website below to get in touch if you care to.
The question "Do computers think?" is the same as "Can submarines swim?"
DragonFire Software
Jeryth
|
|
|
|
|
Thanks Jeryth, I'll email you my address! I visited your website and think it's looking great. Thanks again!
Tom
|
|
|
|
|
So I've got a DirectX Project that rotates some polys around. My problem is that I get compile errors saying PI is an undeclared indentifier. I've got the #include cmath statement ( BTW anyone know how to get the <> brackets to show up in code statements? ) and if I hover the cursor over a PI anywhere I get a tooltip "#define PI 3.14159...." Any idea what the problem is?
The question "Do computers think?" is the same as "Can submarines swim?"
DragonFire Software
Jeryth
|
|
|
|
|
Not sure why your code won't compile. However, how about using this expression for defining pi?
const double PI = 4 * atan(1.0);
Kevin
|
|
|
|
|
And to get the bracets show in these messages, use their HTML escape sequence codes. For > it is "& + gt;" and for < it is "& + lt;" (Remove the + sign, the quotes and write the entire sequence togeter in order to actual display it)
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I just bought a PocketPC today, it is a HP iPAQ 2215 with
Windows Mobile 2003 OS and Intel PXA225 400MHz CPU.
Then I couldn't wait to download the SDK, then....
I downloaded the Microsoft Windows Mobile 2003 SDK from
Microsoft website, then it said in order to use VC++, I also
need to install eMbedded Visual C++ 4.0 and its service pack
before installing the SDK.
So I installed the eMbedded Visual C++ 4.0 and its service
pack 2, then I installed the SDK.
However after installing the Windows Mobile 2003 SDK, it only
contains the Pocket 2003 Emulator. The SDK itself is a console
application. It is prompting the SDK's tool directory. (it reminded
me the Java SDK) Isn't the Pocket PC 2003 SDK supossed to be
windows-based?
Then I opened the eMbedded Visual C++ 4.0, it looks exactly like
the Visual Studio 6.0 environment.
But I saw some people can use VS.Net environment to develop
the Pocket PC. There is also no new project type when I open
the Visual Studio .Net 2003.So I wonder if I have downloaded
the wrong tools? How can I use VS.Net to develop the Pocket PC?
Besides, on the SDK website, it said it can use C# and VB.Net
language. Why do I only get the Emulator and the console
prompt?
|
|
|
|