|
Then do what I said. The other person who replied told you exactly what I was trying to remember.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Try using:
SetMapMode(dc, MM_ISOTROPIC);
then,
SetWindowExtEx(), SetViewportExtEx().
...cmk
Save the whales - collect the whole set
|
|
|
|
|
UpdateData (1);
for(int m=1;m<=m_edit1.GetLength ();m++)
{
CString tr=m_edit1.Left (m);
tr.Delete (0,m-1);
ch=tr.GetAt (0);
tr.Format ("%d",ch);
data =(double)ch;
//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
int a,b;
// char buffer[50];
CString s=_fcvt(d,0,&a,&b);
if(s.GetLength()<2)
{
s.Insert(0,"00");
}
else if(s.GetLength()>1&&s.GetLength()<3)
{
s.Insert(0,'0');
}
UpdateData (1);
m_edit6 +=s;
UpdateData (0);
this is a code for encryption .here first i converted the string in the edit box 1 to its corresponding ascii value.after that i found the double value for that.for concatenating the values, i converted the double value into string&i stored that value into m_edit6.
for decryption i have to convert that string value in the edit6 to double using "strtod()".
plz help me with this..
|
|
|
|
|
nehathoma wrote:
for decryption i have to convert that double value in the edit6 to string using "strtod()".
Well, that's just plain impossible. strtod converts a string to a double, not a double to a string.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
sorry ,actually i meant string to double conversion.
|
|
|
|
|
if you want to convert string to double use this:
CString string;
char *temp;
double dNumber;
temp = string.GetBuffer(string.GetLength());
sprintf(temp,"%f",dNumber);
Eli
|
|
|
|
|
eli15021979 wrote:
CString string; <br />
char *temp; <br />
double dNumber; <br />
temp = string.GetBuffer(string.GetLength()); <br />
sprintf(temp,"%f",dNumber);
Well, using your code exactly as shown is incorrect because [1] the string has no contents, so calling CString::GetLength() to size the returned buffer is incorrect, [2] you did not call CString::ReleaseBuffer() to relock the written-to buffer, and [3] you did not enforce the length of the data written to the buffer (memory overrun potential).
(Mis)using CString :
<br />
CString string; <br />
char *temp = string.GetBuffer( 32 + 1 ); <br />
double dNumber = 12345.54321; <br />
<br />
_snprintf( temp, 32, "%f", dNumber );
temp[ 32 ] = '\0';
string.ReleaseBuffer();
You will want to add proper exception handling and testing of the pointer returned by CString::ReleaseBuffer() .
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Don't you think he should try to do the work by himself?????
I just wanted to give him general direction.
BTW:
I just realized that he wanted convertion from string to double(i.e this wasn't the suitable example) so :
CString string = "1234.5678";
char *temp;
double dNumber;
temp = string.GetBuffer(string.GetLength());
sscanf(temp,"%f",dNumber);
<big>string.ReleaseBuffer();:laugh:</big>
Regards,
Eli
|
|
|
|
|
eli15021979 wrote:
Don't you think he should try to do the work by himself?????
I just wanted to give him general direction.
Given general direction is fine, but at least give proper direction; do not lead someone down a path that will cause them problems in the future.
-And, actually, your example is wrong, too...!
You need to pass the address of dNumber to sscanf(...) . Better to use a function designed for this specific purpose, like strtod(...)/_tcstod(...) instead of a more general purpose function, like sscanf(...) .
Calling GetLength() in the context shown above will still return an incorrectly sized buffer.
<br />
double dNumber1 = ::_tcstod( _T( "1234.5678" ) ); <br />
double dNumber2 = ::strtod( "1234.5678" ); <br />
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Is google broken on your PC ? I've answered this question a few times lately ( I assume you're asking over and over, or all your class is looking for help on the same assignment ) and I've just been cutting and pasting the demo code from the first match google hits.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Here is
char *t;
double dt=::strtod(m_edit6,&t);
CString str;
//check is we got correct double value
str.Format("%e",dt);
MessageBox(str);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
how can i convert this double value into its corresponding ascii value??
|
|
|
|
|
|
hello,
i write a service and do something,but what can i do to not allow others to stop my service or modify the start type,status of the service?who can help me?
best regards
|
|
|
|
|
When you create the service via CreateService() specify the desired access rights.
You can not prevent an admin from stopping or modifying a service.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hi,
Anybody knows about software modems. Or any helpful links to know about?
Actually my objective is to test the (already present)software modem in
my system. Diagnostics purpose.
Thanks
Tom
|
|
|
|
|
Hi..
I had posted this query few days back also.. i am still not able to get the solution..
I need to maintain a log file that should contain the entries for the time a playback started and the time it ended. I am playing the wave files using Directx's DirectSound.. A separate thread takes care of the playback..
Mr. cedric had told me to find out what the callback function does.. the SetCallback function gets the audio stream data..
Is it possible to record the start and end times of the playback???
I am giving the related code here...
==================================================
void CPhoneDlg::OnPlay()
{ ......
CTime theTime=CTime::GetCurrentTime();
CString startTime=theTime.Format( "%H:%M:%S, %B %d, %Y" );
WriteLogFile(startTime);
m_pMyDS->Play();
m_timerID = timeSetEvent(500, 100, TimerProc, (DWORD)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
CTime getTime=CTime::GetCurrentTime();
CString endTime=getTime.Format( "%H:%M:%S, %B %d, %Y" );
WriteLogFile(endTime);
......
}
void CPhoneDlg::WriteLogFile(const char* szString)
{
FILE* pFile = fopen("logFile.txt", "a");
fprintf(pFile, "%s\n",szString);
fclose(pFile);
}
//Some methods in the MyDirSound Class
void CALLBACK TimerProcess(UINT uTimerID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
CMyDirSound *pDDS = (CMyDirSound *)dwUser;
pDDS->TimerCallback();
}
void CMyDirSound::SetCallback(LPGETAUDIOSAMPLES_PROGRESS Function_Callback, LPVOID lpData)
{
m_lpGETAUDIOSAMPLES = Function_Callback;
m_lpData = lpData;
}
void CMyDirSound::Play()
{
//Check if the DirectSound was created successfully
..........................
//Check if the callback function is valid
..........................
//Check if SetFormat successfully
..........................
if (0 == m_dwCircles1)
{
//Get audio data by callback function
DWORD dwRetSamples = 0, dwRetBytes = 0;
m_lpGETAUDIOSAMPLES(m_lpAudioBuf, m_WFE.nSamplesPerSec, dwRetSamples, m_lpData);
dwRetBytes = dwRetSamples*m_WFE.nBlockAlign;
//Write the audio data to DirectSoundBuffer
.....
//Lock DirectSoundBuffer
.....
//Copy Audio Buffer to DirectSoundBuffer
.....
//Unlock DirectSoundBuffer
....
}
//Beging Play
m_lpDSB->Play(0, 0, DSBPLAY_LOOPING);
//timeSetEvent
m_timerID = timeSetEvent(300, 100, TimerProcess, (DWORD)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
}
==============================================================
The waveforms which i play are all greater than 10ms.. even then the start and the end times of playback are coming same..
If someone can tell if it can done and if so how.. i will very thankfull..
regards
pallavi
|
|
|
|
|
I presume there's a callback you can register for that will notify you when the file stops playing.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi..
thank you..
Can you explain it in a bit detail.. I am new to DirectSound and programming multimedia applications.. What i should do exactly?
regards
pallavi
|
|
|
|
|
Have a look at the IDirectSoundNotify interface.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
iam using Doc - View architecture for an MDI application.
I need to scroll the MDI child windows using horizontal and vertical scroll bars.
can anyone let me know the procedure.
thanx in advance
laiju
|
|
|
|
|
Hi guys
I am having a small problem on refreshing screen, because when i insert digital gates that i created on Bitmap they were disappear immediately if i minimize or maximize the screen, any one can give me a hand thanks
From: Guibert
|
|
|
|
|
when u refresh screen , u must reinsert digital gates. Or u can store digital gates in bitmap.
|
|
|
|
|
Does anybody know how you can disable Microsoft Word's Spell check engine using VC++??
Any help would be greatly appreciated.
|
|
|
|
|
Hi,
The codes below used to create a window to display something. Could some of you tell me that how can I display the real time clock (H:M:S) inside this window... Thanks!
hwnd = CreateWindow(
szWinName, /* name of window class */
"Capture Testing", /* title */
WS_OVERLAPPEDWINDOW, /* window style - normal */
CW_USEDEFAULT, /* X coordinate - let Windows decide */
CW_USEDEFAULT, /* Y coordinate - let Windows decide */
480, /* width - let Windows decide */
320, /* height - let Windows decide */
HWND_DESKTOP, /* no parent window */
NULL, /* no menu */
hThisInst, /* handle of this instance of the program */
NULL /* no additional arguments */
);
g_inst=hThisInst;
/* Display the window. */
ShowWindow(hwnd, nWinMode);
UpdateWindow(hwnd);
hWndG=hwnd;
SetTimer(hWndG,1,100,NULL);
|
|
|
|
|