|
Check out CPhysicalDiskFile, part of the Win32 Foundation Class (WFC). See links below.
www.samblackburn.com/wfc/CPhysicalDiskFile.htm
www.samblackburn.com/wfc/
Mike
|
|
|
|
|
i wanna create 100 buttons in dialog with code and when clicking one button, it will display a message with the content is the id of the button.
help me please
|
|
|
|
|
can you please explain a bit furthur...
Old United Airlines Brochure:
If you cannot read this please ask a superintendent to help you... LOL, for real!!!
|
|
|
|
|
Creating code-wise buttons requires several steps:
1. Add CButton (or derived) member variables to the dialog class's header file. You can use an array here if you want.
2. For each member variable/array member, call it's Create member method. See MSDN and CButton for parameters of this function.
3. When all buttons are created, you need to show them by using ShowWindow method.
4. Either add a message-map entry to your application for every button ID (ON_BN_CLICKED) or overwrite the window procedure of the application. Now display a message box using AfxMessageBox global method. If you want to map all control IDs to a single handler, you need to use a ON_CONTROL_RANGE message map entry. See MSDN for more details.
To customize the message of the message box, create a CString object and call it's 'Format' to do printf-style formatting for the string. You need to get the ID from the message. Buttons, when clicked, send BN_CLICKED message to the parent. In this message, the control ID is in the low-order word of wParam. See MSDN for more details.
I hope this'll help you get started
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
How do I copy/convert a character array to a std::string?
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
1. Create a string object
2. Use it's member method 'operator +=' to append characters to string, specifying the start of the array as the parameter.
Example:
#include <string>
using namespace std;
<DIV>
... Later in the code...
<DIV>
<DIV>
string myString;
<DIV>
myString += &charArray[0];
<DIV>
Not completely sure if this will work, haven't tested it. But according to the Standard C++ Library Reference, it should go like this
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks for replying.
I had tried the same technique you offered (plus about maybe 20 others) before posting the question, and nothing has worked!
Short of writing a routine to specifically transfer one character at a time from the array to the string, I thought the resiliency of string might have something that would do the job for me. No luck so far.
William
Fortes in fide et opere!
|
|
|
|
|
|
Thanks for replying.
While it is true the program compiles and links without any error, I believe the reason why I am NOT getting the desired behavior is due to a known bug a fix from MS doesn't seem to have corrected.
William
Fortes in fide et opere!
|
|
|
|
|
UNICODE issues?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
try using wstring.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I am right now in the process of trying to make the computer search for a certain string. I am looking in text files, also I'm using console(don't ask)
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Read in all data from your file into a CString, and search for a pattern with CString::Find.
CString sString;
CFile file("c:\\pathtoyourfile.dat",CFile::modeRead);
file.Read(sString.GetBuffer(file.GetLength()),file.GetLength());
sString.ReleaseBuffer(file.GetLength());
sString.Find("Your pattern",0);
Take a look in MSDN at CFile, and CString.
Peter Molnar
|
|
|
|
|
Very well, but how can you do this in the console c++?
Old United Airlines Brochure:
If you cannot read this please ask a superintendent to help you... LOL, for real!!!
|
|
|
|
|
Use a FILE structure in combination with 'fopen', 'fclose' and 'fread' functions. Read the entire file to a LARGE char array (say 'char myArray[8000]'). Then use stricmp function to compare the file with your match string.
Of course, if your file is larger, you should use the heap memory instead of stack. Just create a 'char* ptrArray = new char[80000]' and read it there. Remember to delete it when finished.
See Run-Time Library Reference for more details on file handling.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Yes, I will allocate some memory since the file will be in constant change and allocation is a very good memory manager.
Old United Airlines Brochure:
If you cannot read this please ask a superintendent to help you... LOL, for real!!!
|
|
|
|
|
Create a console application with MFC support, and use the above code.
If you don't use MFC: The CString is part of the Win32 library in VS 7.0 and upwards, so you only have to change the file read in operation (see CreateFile,ReadFile Win32 functions).
Peter Molnar
|
|
|
|
|
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
|
|
|
|