|
Hello,
Try this one:
CString Valeur="1250.20";
int Fractional = ((atof(Valeur) - atoi(Valeur)) * 100.0);
change 100 to 100.0
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Result of atof-atoi is converted to int before multiplication.
Pavel
Sonork 100.15206
|
|
|
|
|
Hello there,
How can i get ADO version ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hello there,
Is there any API function for registering ActiveX or DLLs ??
Or i have to use WinExec to run regsvr32 to regestring ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Try something like:
typedef HRESULT (STDAPICALLTYPE *FnDllEntryPoint)(void);
HMODULE hMod = ::LoadLibrary( pszDllName );
if ( hMod != NULL )
{
FnDllEntryPoint lpDllEntryPoint = (FnDllEntryPoint)::GetProcAddress( hMod, "DllRegisterServer" );
if ( lpDllEntryPoint != NULL )
{
if ( SUCCEEDED( (*lpDllEntryPoint)() ) )
{
// Success
}
else
{
// Registration failed
}
}
else
{
// Failed to find entry point - probably not a COM object
}
::FreeLibrary( hMod );
}
else
{
// Failed to load library
}
Dave
|
|
|
|
|
That's it
Thanks aloooooot !
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi!
I've created a MFC Dll. I have exported a function which must display a dialog box. I have tried to use the CDialog class but the dialog doesn't appear.
Here a portion of my code(CreatePageDlg is the dialog class of the dialog I want to display):
#include "stdafx.h"
#include "web.h"
#include "CreatePageDlg.h"
__declspec(dllexport) void __cdecl ShowDialog(CString FileName)
{
CCreatePageDlg dlg;
dlg.DoModal ();
if (dlg.DoModal ()==IDOK)
{
}
}
What's wrong.
Thks in advance!
Appstmd
|
|
|
|
|
Have you tried debug stepping into the DoModal function, this should give you more clues to what the problem. Also the sample code provided will show the dialog twice.
Is the DLL's resource identifier range different to the applications's resource id range?
Michael
Programming is great. First they pay you to introduce bugs into software. Then they pay you to remove them again.
|
|
|
|
|
You might have been bitten by MFC dialog creation code that tries to load the resource with the same name or ID from the executable, not from the DLL itself.
You must make your DLL an "MFC extension DLL". How to do this is reasonably well documented in e.g MSDN.
|
|
|
|
|
Where can I find the registry key for the path of the current WebBrowser / EmailReader?
Who can I get/read the icons from these exe-files ?
Please, give me an answer ...
Stefan-Mihai MOGA
info@mogamihai.ro
|
|
|
|
|
default browser: HKEY_CLASSES_ROOT\http\shell\open\command
|
|
|
|
|
Thank you, but what about the default email reader (outlook / outlook express / ...) ???
Thanks again ...
|
|
|
|
|
Hmm.. maybe this !?
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail
----------------------------
never stop coding.
|
|
|
|
|
Thank you very much for your quickly response, but...
what can you tell me about the fallowing keys ?
1. HKEY_CLASSES_ROOT\mailto\shell\open\command
2. HKEY_CLASSES_ROOT\Microsoft Internet Mail Message\shell\open\command
3. HKEY_CLASSES_ROOT\Microsoft Internet News Message\shell\open\command
---------------------------------------------
start small, think big ...
---------------------------------------------
Stefan-Mihai MOGA
info@mogamihai.ro
|
|
|
|
|
hi!
I'm working on a Consumer - producer program. It is required to measure the time that the producer producing, waiting and the consumer consumes and waiting. However i'm having some trouble measuring those. Does anyone have any ideas?
The following is my code that i've written so far:
<br />
#include "buffer.h"<br />
#include <windows.h><br />
#include "screen.h"<br />
HANDLE NFull, NEmpty;<br />
HANDLE mutexProTime, mutexConTime;<br />
int sleepTimePro = 100;
int sleepTimeCon = 200;
<br />
void Buffer::BufInit(void)<br />
{<br />
bufferSize = 8; <br />
NxtIn = 0;<br />
NxtOut = 0;<br />
NFull = CreateSemaphore(NULL, 0, bufferSize, 0);<br />
NEmpty = CreateSemaphore(0, bufferSize, bufferSize, 0);<br />
mutexProTime = CreateMutex(NULL, TRUE, 0);<br />
mutexConTime = CreateMutex(NULL, TRUE, NULL);<br />
proTime = proWaitTime = 0;
conTime= conWaitTime = 0;
<br />
}<br />
void Buffer::BufPut(char c)<br />
{<br />
<br />
if(WaitForSingleObject(NEmpty, 10) != WAIT_OBJECT_0)<br />
proWaitTime += 100;<br />
<br />
buffer[NxtIn] = c;<br />
NxtIn = (NxtIn+1) % bufferSize;<br />
if (NxtIn == 0)<br />
{<br />
scrWriteAt(0, 5, " ");<br />
scrWriteAt(0, 5, "Producer is waiting");<br />
}<br />
else<br />
{<br />
scrWriteAt(0, 5, " ");<br />
scrWriteAt(0, 5, "Producer is generating ");<br />
}<br />
ReleaseSemaphore(NFull, 1, 0);<br />
Sleep(sleepTimePro);<br />
<br />
proTime += sleepTimePro;<br />
<br />
<br />
}<br />
char Buffer::BufGet(void)<br />
{ <br />
char s; <br />
if(WaitForSingleObject(NFull, 10) != WAIT_OBJECT_0)<br />
conWaitTime += 100;<br />
s = buffer[NxtOut];<br />
NxtOut = (NxtOut+1) % bufferSize;<br />
<br />
if (NxtOut == 0)<br />
{<br />
scrWriteAt(0, 7, " ");<br />
scrWriteAt(0,7,"Consumer is waiting " );<br />
}<br />
else<br />
{<br />
scrWriteAt(0, 7, " ");<br />
scrWriteAt(0, 7, "Consumer is consuming ");<br />
}<br />
ReleaseSemaphore(NEmpty, 1, 0);<br />
Sleep(sleepTimeCon);<br />
conTime += sleepTimeCon;<br />
return s;<br />
<br />
}<br />
long Buffer::TimeProducerProduces()<br />
{<br />
<br />
<br />
return proTime;<br />
}<br />
long Buffer::TimeProducerWaits()<br />
{<br />
return proWaitTime;<br />
}<br />
long Buffer::TimeConsumerConsumes()<br />
{<br />
return conTime;<br />
}<br />
long Buffer::TimeConsumerWaits()<br />
{<br />
return conWaitTime;<br />
}<br />
it seems to me that the above does not work, and it always produce the same answer each run.
|
|
|
|
|
What OS do you design the program for? For example, you could get a quite accurate execution time of a thread using GetThreadTime().
Kuphryn
|
|
|
|
|
it is for 2k! How about i just want to measure time of a part of thread? Thanks
|
|
|
|
|
Have a look at QueryPerformanceCounter and QueryPerformanceFrequency. It however displays the amount of "real" time used, not only CPU time for that thread. For the latter you can try GetThreadTimes.
|
|
|
|
|
I highly recommend Programming Applications for Microsoft Windows Fourth Edition by Jeffrey Richter. He demonstrates powerful Win32 API tools including the use of GetThreadTimes().
Kuphryn
|
|
|
|
|
Hi,
In a follow up to my post below, there is going to be quite a bit of text displayed in the edit control. Insteaed of using multiple .Replacesel statement, can I store the text as a string resource and then display it using a single .ReplaceSel statement.
Also is the resource file the preffered method or this ?
Many thanks
Mike
Sunday coding with a huge hangover
|
|
|
|
|
You can use CString::LoadString to load the string from string resource and then use the loaded strind in ReplaceSel.
It is of course better to construct the text in memory and then call ReplaceSel once.
MJ32 wrote:
is the resource file the preffered method or this ?
If the text is static then yes, it's good for localization.
Pavel
Sonork 100.15206
|
|
|
|
|
Try the following:
CString str;
str.LoadString(<string resource ID>);
m_ctrEditLocation.ReplaceSel(str);
Gary R. Wheeler
|
|
|
|
|
Hi guys,
I am trying to output some information to a user in a dialog based app.
I would like to use an edit control (multiline) to dislay several lines (30-50).
Is an edit ctrl the best way to do this ?
Also when using the
m_ctrEditLocation.ReplaceSel(_T("LINE 1 \n\n\r"));everything appears on the same line.
Could anyone suggest any ideas on how to split text up on multiple lines / improvements to enable me to do this.
Many thanks
Mike
|
|
|
|
|
MJ32 wrote:
("LINE 1 \n\n\r"
You need to insert "\r\n" as line delimitter.
You can use this[^] modified edit control.
Pavel
Sonork 100.15206
|
|
|
|
|
Many thanks Pavel,
I can't beleieve i didn't think of just reversing the delimmitters I used
Call me Bit-Fik of the week
Thanks again
Mike
|
|
|
|