|
If you want portability, use the STL and don't bother with the Win32 API calls.
// read a file
std::ifstream f("localfile.txt"); // this will get localfile.txt in the current directy
if(f)
{
std::string contents;
std::ostringstream ss;
ss << f.rdbuf();
ss.str().swap(contents);
// file buffer is now in contents
}
f.close();
// write a file
std::ofstream f("localfile.txt");
f << "Bienvenidos a Mexico";
f.close();
|
|
|
|
|
Seenivasan Palaniappan wrote:
...porting to other system...
What other systems?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Does anyone have any experience embedding LISP within their application? Specifically, I am looking for a wrapper class to aid with the integration of the Common LISP engine.
There are a couple commerical LISP derivatives out there that are built on top of COM objects, but I cannot tell if they are ANSI compliant.
Any insight is greately appreciated.
Jim
QTExtender - The OFFICIAL addon for QuoteTracker.
|
|
|
|
|
CString tr=m_edit1.Left (m);
tr.Delete (0,m-1);
ch=tr.GetAt (0);
tr.Format ("%d",ch);
data =(double)ch;
i want to convert this double to ascii and then ascii to string.....
|
|
|
|
|
Are you sure you know what it is that you want? Converting something to/from ASCII is really a misnomer as all characters are from the ASCII set anyhow. Perhaps you wanted something like:
double d = 12.34;
CString str;
str.Format("%f", d); If not, please elaborate on what you are trying to achieve.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
c this is the main code:
i am supposed to decrypt a string :
int NO_BITS;
double c=0,d=1;
char bits[100];
double n=(double)m_n;
double data;//19;
long i,k;
CString str;
int sizeof_d=sizeof(double);
/*FILE *inFP, *outFP;
inFP=fopen(infile,"rb");
if(inFP==NULL)
{
str.Format("\nERROR: Couldn't open input file: %s\nAborting operation",infile);
DumpNotes(str);
return;
}
outFP=fopen(outfile,"wt+");
if(outFP==NULL)
{
str.Format("\nERROR: Couldn't create output file: %s\nAborting operation",outfile);
DumpNotes(str);
fcloseall();
return;
}*/
//change integer 'd' to binary
D_to_B(m_d,32,bits);
GetOnlyProperBits(bits);
k=NO_BITS = strlen(bits)-1;
// while(1)
for(int m=1;m<=m_edit2.GetLength ();m++)
{
//read from ip file into 'data'
/* if(fread(&data,sizeof_d,1,inFP)==0)
break;*/
data=strtod(m_edit2,NULL);
//calculate ((data)^e mod n) .i.e the remainder
c=0;d=1;
for(i=k;i>=0;i--)
{
c=2*c;
d=fmod(d*d,n);
if(bits[NO_BITS-i] == '1')
{
c=c+1;
d=fmod(data*d,n);
}//end of IF
}//end of for loop
//write to op file from 'd'
//unsigned char ch=(unsigned char)d;
unsigned char ch=(unsigned char)d;
fprintf(outFP,"%c",ch);
write(&ch,1,1,outFP); (c all i have to do is i have to change the fprintf and write statements b'coz they r used to decrypt to a file)
}//end of while loop
DumpNotes(CString("\nDecryption over..."));
//fcloseall();
plzzzz help me with this.........
i have got problem with those 2 stmts......
|
|
|
|
|
Hi*!
I have a listview in my application (basically a simple Win32 overlapped window). I am painting some bitmap as the background of the ListView. For that I subclass the ListView and paint the bitmap and the let the ListView paint the Items, I also paint my custom scroll bar also. Now my problem is when i want to scroll the ListView I send the LVM_SCROLL to the ListView and ListView scrolls but somehow i dont get the WM_PAINT message and background doesnt not get erased & looks messy like some items getting painted over some other items (probably it scrolls the WindowDC not generating the WM_PAINT at all), so I have to call invalidate/update ListCtrl after calling scroll, that makes the window look normal again but for a breif moment i see the window not getting painted properly. How can i avoid this situation??? I have tried using SET_REDRAW TRUE/FALSE but that doesnt help either , I still can see theat mess. My application is Win32 based. I am not using MFC. Any comments/suggestions are most welcome & appreciated....
Thanks for your time,
Regards,
Usman.
|
|
|
|
|
|
Thanks for the reply. But since I have to draw the scrollbars myself (i wasnt able to subclass the original scrollbars present in ListView) so i have to handle WM_PAINT for the ListCtrl.
Regards,
Usman.
|
|
|
|
|
Hi,
I'm trying to load a bitmap by following code but it always returns me a NULL handle
LoadBitmap(NULL,"bitmapfile.bmp");
any pointers for how to make the code work?
P.S.
Bitmap is in application folder, also I have tried with complete path.
Ciao
- Nilesh
|
|
|
|
|
LoadBitmap is used for loading resource bitmaps.
Try
http://support.microsoft.com/kb/q158898/
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
that works.. thanks a lot
- Nilesh
|
|
|
|
|
Use LoadImage API if you want to load from the disk.
Hope this helps,
Usman.
|
|
|
|
|
I want a small MFC application that picks up paramters from the command line.
There are command line parser examples but all of them assume you already have the command line to parse.
Any suggestions as the VC++ help refers to ocnsole apps.
Thanks.
Elaine
The tigress is here
|
|
|
|
|
m_lpCmdLine member of CWinApp class contains command line string. You may parse this string in InitInstance()
ARSALAN MALIK
|
|
|
|
|
or you could use __argc and __argv (double _ before arg)
|
|
|
|
|
Thanx, I didn't knew that before!!!
ARSALAN MALIK
|
|
|
|
|
|
|
You can try GetCommandLine() tooo
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
We are using Visual Studio .Net and dump a lot of debug info of our application to a console. Normally this is not a problem, however sometimes the console hangs and I cannot set the focus to the debugger anymore. And if I start the task manager, the whole system seems to hang.
We do use multiple thread to log information to the console, so I created the threads with _beginthreadex instead of CreateThread, but that does not seem to make any difference. Any one got a clue why this might be happening?
|
|
|
|
|
Maybe you need to make calls to printf thread safe, by using a CRITICAL_SECTION object....
void theadsafe_printf(char *lpzText) {
EnterCriticalSection(&cs);
printf("%s",lpzText);
LeaveCriticalSection(&cs);
}
Use InitilizeCriticalSection() to create the cs object.
and DeleteCriticalSection() when finished at the end of your app.
|
|
|
|
|
can anyone plz tell me how to convert an ascii to string and ascii to char using vc++
|
|
|
|
|
What you mean by "ascii"?? Do mean ascii value as an integer or ascii value as a string, i.e. Do you want to convert something like "979899" into "abc"?? Please clarify
ARSALAN MALIK
|
|
|
|
|
Hello to everyody,
I want to draw a line thta connect two points...
I have to paint the line of one color...until here it's ok
But the problem is that I have to paint a piece of it of another color from one point to a distance done.
How can i do it? Because maybe i will need a line equation?
Thanks
|
|
|
|