|
Remove the static keyword and initialize the variable in the constructor initialization list (errr... I always forget how this is called ):
MyClass::MyClass() :
MY_CONST_STRING("Constant String"),
MY_SECOND_CONST_STRING("Another String")
{
}
|
|
|
|
|
I appreciate your help but defining the string constant as you have suggested will yield the following error when a DLL client attempts to reference it:
error C2597: illegal reference to non-static member 'MyClass::MY_CONST_STRING'
I would like clients using my DLL to be able to reference the string constant directly like this:
CString newString(MyClass::MY_CONST_STRING);
or say, like this:
::AfxMessageBox(MyClass::MY_CONST_STRING);
...without having to create an instance of MyClass or having MyClass define any static methods which return the value of MY_CONST_STRING.
Any ideas?
Peter
|
|
|
|
|
Hi,
In my project simply encrypt data using XOR operator ,Then write encrypted data in file using fwrite function in MFC.
Problem is occure only possible to decrypt pice of data from encrypted file.
For example ,
File1:Input File size(6kb)
FIle2:Encrypt File size(5kb)
File3:Decrypt File size(1kb)
coding:
Encrypt:
while(!feof(file1))
{
int iout;
fread(&iout,sizeof(iout),1,file1);
iout^=1300;
fwrite(&iout,sizeof(iout),1,file2);
}
Decrypt:
while(!feof(file2))
{
int iout;
fread(&iout,sizeof(iout),1,file2);
iout^=1300;
fwrite(&iout,sizeof(iout),1,file3);
}
Note :
NoProblem occur when if XOR with value of 10
while(!feof(file1))
{
int iout;
fread(&iout,sizeof(iout),1,file1);
iout^=10;
fwrite(&iout,sizeof(iout),1,file2);
}
Please replay me urgently
-- modified at 8:40 Thursday 26th April, 2007
|
|
|
|
|
mohindar_kks wrote: Problem is occure only possible to decrypt pice of data from encrypted file.
This is a bit unclear. What exactly is the problem? Are you concerned that file1 (the original) and file3 (the decrypted) are not the same? You'll likely see the same problem even if you omitted the XOR statement.
Try:
while (! feof(file1))
{
char iout;
if (fread(&iout, sizeof(iout), 1, file1) == 1)
{
iout ^= 1300;
fwrite(&iout, sizeof(iout), 1, file2);
}
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
In my project simply encrypt data using XOR operator ,Then write encrypted data in file using fwrite function in MFC.
No problem in Decryption if successfully retrive data from encrypted file until EOF. But some time encrypted file automatically return EOF after postion of data retrive this data also decrypted successfully.
For example ,
File1:Input File size(6kb)
FIle2:Encrypt File size(5kb)
File3:Decrypt File size(1kb)
coding:
Encrypt:
while(!feof(Inputfile))
{
int iout;
fread(&iout,sizeof(iout),1,Inputfile);
iout^=1300;
fwrite(&iout,sizeof(iout),1,encryptfile);
}
Decrypt:
while(!feof(encryptfile))
{
int iout;
fread(&iout,sizeof(iout),1,encryptfile);
iout^=1300;
fwrite(&iout,sizeof(iout),1,decryptfile);
}
Note :
NoProblem occur when if XOR with value of 10
while(!feof(Inputfile))
{
int iout;
fread(&iout,sizeof(iout),1,Inputfile);
iout^=10;
fwrite(&iout,sizeof(iout),1,encryptfile);
}
Please replay me urgently
|
|
|
|
|
char iout;
...
iout ^= 1300;
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Bad, yes. Part of the problem, no. His two major problems were not checking the return value from fread() , and trying to read byte s from the disk as int s.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
When using the SHFileOperation function to copy a folder from one destination to another, but the folder already exists, and the SHFileOperation function brings up a dialog that asks whether or not to replace the existsing folder, Q: is it possible to send a message to that dialog to answer the question, so that the user is not involved.
Makes sense??
Many Thanks.
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
|
Yeah I'd recommend using the FOF_SILENT flag
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all!
I want to develope an ActiveX TextBox control with additional features
that doesn't exist in the current textbox component.
Requirements
1) I want to use existing textbox control and enhance it to my requirements.
2) Is there any way using which we don't have to draw the control manually as it is
in the case of VisualBasic?
If anybody is having anykind of reading stuff give me the links.
Viral Joshi.
|
|
|
|
|
Why ActiveX ? Why not just derive a class from CEdit (assuming you're using MFC) and add the required features in the derived class ?
|
|
|
|
|
Thanks for your reply but let me know how is it possible in Activex.
But if i derived a class from CEdit then is it the ActiveX? And how can i
use it as a control like textbox in other applications?
Viral Joshi
|
|
|
|
|
I have this :
CString sEx;
m_ex.GetWindowText(sEx);
m_ex = CEdit ;
i whant somethig like that : 16.0697 to 16.0700 !!!!!!!!
round!
How?????
Please someoane help me !!!!
(visual c++)
Bravoone
|
|
|
|
|
Try this function:
<br />
void RoundString(CString& str)<br />
{<br />
float fVal = 0;<br />
swscanf_s(str, L"%f", &fVal);<br />
int nTemp = (int)((fVal + 0.005)*100);<br />
fVal = (float)((float)nTemp/100);<br />
str.Format(L"%.4f", fVal);<br />
}<br />
|
|
|
|
|
i dont understand , can you explain me on my example ?
thank you ! so mutch !
Bravoone
|
|
|
|
|
Bravoone_2006 wrote: can you explain me on my example ?
He gave you an example!
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i need something more simple, its not exist something more simple then this?
thank you !
Bravoone
|
|
|
|
|
Bravoone_2006 wrote: its not exist something more simple then this?
no.
|
|
|
|
|
you idiot.
someone gives you a function you just have top copy/paste in your code and call, but always you complain.
|
|
|
|
|
The function I gave you receives a CString object by reference, puts the value into a float variable, rounds it to 2 numbers after the decimal point and converts the new (rounded) value back into the CString object.
|
|
|
|
|
i need something more simple, its not exist something more simple then this?
thank you !
Bravoone
|
|
|
|
|
Sorry, but this is as simple as it gets ...
|
|
|
|
|
More simple than a copy/paste ??
|
|
|
|
|
That's two operations, Cedric. Can't you trim it down to one? Quit making folks work so hard.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|