|
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
|
|
|
|
|
You will definitly need line equation. If you require only two colors (not graduated), i suggest you to draw two lines instead of one using different color. You need to find the coordinate of dividing point using line equation etc.
ARSALAN MALIK
|
|
|
|
|
Hi,
I change the font of the Window...and when i do DrawText it doen't work...with TextOut YES but with DrawText NOT...why? How can i do it with DrawText?
This is the code i use to set the font
CFont font;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT)); // zero out structure
lf.lfHeight = 12; // request a 12-pixel-height font
strcpy(lf.lfFaceName, "Arial"); // request a face name "Arial"
VERIFY(font.CreateFontIndirect(&lf)); // create the font
// Do something with the font just created...
CClientDC dc(this);
CFont* def_font = dc.SelectObject(&font);
dc.TextOut(5, 5, "Hello", 5);
dc.SelectObject(def_font);
// Done with the font. Delete the font object.
font.DeleteObject();
Thanks
|
|
|
|
|
Hi,
I want to create a DLL which puts and icon in the taskbar on click of tht icon an exe is run.
I wrote the following code.
The Compiler is not recognising the VERIFY Macro and AfxGetInstanceHandle method.
This code might be wrong becoz i ma jus trying .
Could someone help me out with this.
<br />
#include <windows.h><br />
#include <shellapi.h><br />
#include "example.h"<br />
#define MYWM_NOTIFYICON (WM_USER+2)<br />
<br />
BOOL WINAPI DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{<br />
return TRUE;<br />
}<br />
<br />
EXPORT void WINAPI Systray ()<br />
{<br />
DWORD dwMessage=NIM_ADD;<br />
NOTIFYICONDATA tnd;<br />
HWND m_hWnd;<br />
tnd.cbSize = sizeof(NOTIFYICONDATA);<br />
tnd.hWnd = m_hWnd;<br />
tnd.uID = IDR_TRAYICON;<br />
<br />
tnd.uFlags = NIF_MESSAGE|NIF_ICON;<br />
<br />
tnd.uCallbackMessage = MYWM_NOTIFYICON;<br />
<br />
<br />
VERIFY( tnd.hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE (IDR_TRAYICON)) );<br />
<br />
tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;<br />
<br />
<br />
Shell_NotifyIcon(dwMessage, &tnd);<br />
<br />
if(dwMessage == MYWM_NOTIFYICON)<br />
{<br />
if((LPARAM)tnd.uCallbackMessage==WM_LBUTTONDBLCLK)<br />
{<br />
if((WPARAM)tnd.uCallbackMessage==IDR_TRAYICON)<br />
{<br />
ShellExecute(NULL, "open", "http://www.brigsoft.com/", NULL, "", SW_SHOW);<br />
}<br />
<br />
}<br />
}<br />
}<br />
Thanks
U get wht u Give
|
|
|
|
|
Hello,
i need to load (from a file, or from a resource) a jpg to set dialog background.
Anybody can help me, please?
I only found solutions for bitmpap files
Lewix
|
|
|
|
|