|
dotnetkoders wrote: In VC6, IF condition is true. Whereas in VC8, its failing.
Have you looked at the actual value in both? In VS6, the value of result is -1.#IND000 , indicating NaN for floating-point numbers.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Yes. In VC6, result value is -1.#IND000000000 whereas in VC8 -1.#IND000000000000
|
|
|
|
|
So rather than call pow() with invalid input, why not check the base value first, or call _isnan() on the result?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
dotnetkoders wrote: Could any one explain the reason, why its failing in VC8.
Because VC8 is compliant with IEEE754[^], whereas VC6 wasn't (did VC6 comply with any standards, I wonder, 'cause it didn't comply with the C++ standard either. Anyway.)
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
What is your definition of 'works fine'?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello,
I have a C++/MFC application, which can be extended by its users by means of a PlugIn interface. This interface uses simple dll mechanisms (no COM). Now I want to add a functionality to allow these PlugIns to be written in .NET languages. Therefore I created a wrapper PlugIn, which sits between the MFC application and the .NET user PlugIn. This works very well so far. However, I have one problem. Some PlugIns might require to extend the user interface of the MFC app by controls in order to apply specific settings. The method for this, which is to be implemented in the native dlls, has the following prototype:
HWND CreateSettingsWindow(HWND wndParent);
Where wndParent is the window handle of the parent window on which the control should be placed.
What I do in the wrapper is create a .NET form control from this handle and pass it to the wrapped .NET PlugIn like this.
HWND CreateSettingsWindow(HWND wndParent)
{
System::Windows::Forms::Control^ ctrl = System::Windows::Forms::Control::FromHandle((System::IntPtr)wndParent);
System::Windows::Forms::Control^ ctrlSettings = (*this->m_pWrappedPlugIn)->CreateSettingsWindow(ctrl);
if (ctrlSettings != nullptr)
{
return (HWND)ctrlSettings->Handle.ToPointer();
}
else
{
return NULL;
}
}
The wrapped .NET PlugIn now creates its control (derived from System.Windows.Forms.UserControl ) and attaches it to the controls collection of the parent window:
public override System.Windows.Forms.Control CreateSettingsWindow(System.Windows.Forms.Control parent)
{
MySettingsControl ctrl = new MySettingsControl();
parent.Controls.Add(ctrl);
return ctrl;
}
The control is created correctly and as it seems I can even access it from the MFC application (at least I can read its size). But it will not show up on the parent window. Regardless what I do (visible property, show method, ...) it will not become visible.
Any idea what could be wrong with my approach or what might be missing would be very helpful.
Thank you very much
|
|
|
|
|
Did you make the HWND you originally created visible as well as the .NET part of the deal?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Yes, I did.
I found the problem. Obviously System::Windows::Forms::Control::FromHandle fails for window handles, which were created by Win32/MFC and not with .NET. Thinking about it, this makes sense.
Luckily I found a nice tutorial on the web, which pointed me into the right direction:
http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.languages.vc/2005-07/msg00752.html
So I moved the code, which attaches to control to the parent window, from the .NET to the native code section.
The .NET control creation changed simply to the following:
public override System.Windows.Forms.Control CreateSettingsWindow()
{
return new MySettingsControl();
}
And the attachment to the parent uses the good old Win32 function SetParent :
HWND CreateSettingsWindow(HWND wndParent)
{
System::Windows::Forms::Control^ ctrlSettings = (*this->m_pWrappedPlugIn)->CreateSettingsWindow();
if (ctrlSettings != nullptr)
{
::SetParent((HWND)ctrlSettings->Handle.ToPointer(), wndParent);
return (HWND)ctrlSettings->Handle.ToPointer();
}
else
{
return NULL;
}
}
Might it be worthwhile to publish an article about this here on codeproject?
Thanks
|
|
|
|
|
rwe1812 wrote: Might it be worthwhile to publish an article about this here on codeproject?
Definitely - it sounds like something that a) could trip up other people, and b) isn't documented as clearly as it could be.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I am opening an application through another application using CreateProcess().
If the exe is running already I am sending a message through PostMessage otherwise I am opening run the exe and send message.
I found the running instance using FindWindow(). But some times FindWindow() is returning " NON-NULL" although app is not running.
I am confused with this behavior.
My Window Caption is "DDKK";
And My code to FindWindow() is:
HWND hWindow=NULL;
hWindow=::FindWindow(NULL,_T("DDKK"));
if(hWindow==NULL)
{
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
CreateProcess (CSanProApp::GetAppPath(0) + _T("abc.exe"),
_T(" und"),NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
Sleep(4000);
}
::PostMessage(hWindow,Opendialog,0,0);
Please suggest me any solution, why the FindWindow() is returning NON-NULL value although window is not running.
|
|
|
|
|
Check out EnumProcesses to find if a process is running
You can also use OpenProcess, if it returns NULL process is not running etc etc.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
MPTP wrote: ...although app is not running.
How are you verifying this?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
FindowWindow() takes 2 parameter: classname, windowname....
Is there any method to register window with desired name.
My app using below code to register window
<br />
if( !CFrameWnd::PreCreateWindow(cs) )<br />
return FALSE;<br />
<br />
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;<br />
cs.lpszClass = AfxRegisterWndClass(NULL,NULL,NULL,AfxGetApp()->LoadIcon(IDR_MAINFRAME));<br />
<br />
cs.style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;<br />
return TRUE;<br />
|
|
|
|
|
MPTP wrote: Is there any method to register window with desired name.
Yes, but that does not answer my question. When FindWindow() returns a non-NULL window handle, how are you verifying that the application is not running?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Just to see the exe name in Task Manager
|
|
|
|
|
MPTP wrote: ...in Task Manager
Which tab?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
FindowWindow() takes 2 parameter: classname, windowname....
Is there any method to register window with desired name.
My app using below code to register window
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(NULL,NULL,NULL,AfxGetApp()->LoadIcon(IDR_MAINFRAME));
cs.style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
return TRUE;
|
|
|
|
|
what an application wizard will do for a application?
who will create APPclass and Dialog Class for a application.
Are all controls are classes as that of VB.net controls.
|
|
|
|
|
munigantipravin wrote: what an application wizard will do for a application?
based on the type of application the files get generated and the editor is responsible for this.
once you select a console application depending upon your choice you get an empty project or cpp/h and stdafx's files
munigantipravin wrote: who will create APPclass and Dialog Class for a application.
the wizard will
munigantipravin wrote: Are all controls are classes as that of VB.net controls.
yes.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
HEllo All,
Can you please tell me ,can i exports data in dll .If i want to use that data in c# application.
e.g.:-
my dll file contain one class Demo{public int d;}
& i want to use that class Demo in my .cs file how should i use it.
Thank You.
|
|
|
|
|
I suggested you to write a RunTimeCallable Wrapper the last time you asked the same thing.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Can you please help me how to use it
|
|
|
|
|
you will have to create a wrapper over your win32 dll in case of RCW. Call the methods of this win32 dll using a COM object.
After that you can use tlbimp to generate the type lib.
and this can be used in C#
Read here[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Hi All,
Can someone point me in the right direction? This is a reference to the article: "Synchronized multi-threading in C++ (No MFC!)"
Synchronized multi-threading in C++ (No MFC!)
I have been using the thread code and it worked well for me. But this time around, nothing has changed and it returns an unhandled exception on "thread::wait", line "return false" when "wait("MyMutex")" is called during a receive from a worker thread.
unhandled exception in kernel32 (0xE06D7363) on Thread::wait ( line "return false")
Thread::wait(const char * 0x004768e8 `string', long 0x00001388)
Thanks for your help.
Code Section
bool Thread::wait(const char* m,long ms) {
HANDLE h = OpenMutex(MUTEX_ALL_ACCESS,FALSE,m);
if(h == NULL) {
throw ThreadException("Mutex not found");
}
DWORD d = WaitForSingleObject(h,ms);
switch(d) {
case WAIT_ABANDONED:
throw ThreadException("Mutex not signaled");
break;
case WAIT_OBJECT_0:
return true;
case WAIT_TIMEOUT:
throw ThreadException("Wait timed out");
break;
}
return false;
}
modified on Friday, May 8, 2009 8:49 AM
|
|
|
|