Click here to Skip to main content
15,891,431 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: NaN comparison in vc6 & vc8 Pin
David Crow8-May-09 2:45
David Crow8-May-09 2:45 
GeneralRe: NaN comparison in vc6 & vc8 Pin
dotnetkoders8-May-09 3:02
dotnetkoders8-May-09 3:02 
QuestionRe: NaN comparison in vc6 & vc8 Pin
David Crow8-May-09 3:46
David Crow8-May-09 3:46 
AnswerRe: NaN comparison in vc6 & vc8 Pin
Stuart Dootson8-May-09 3:25
professionalStuart Dootson8-May-09 3:25 
QuestionRe: NaN comparison in vc6 & vc8 Pin
CPallini8-May-09 5:53
mveCPallini8-May-09 5:53 
QuestionDynamically place .NET controls on Win32/MFC windows. Pin
rwe18128-May-09 2:24
rwe18128-May-09 2:24 
AnswerRe: Dynamically place .NET controls on Win32/MFC windows. Pin
Stuart Dootson8-May-09 8:24
professionalStuart Dootson8-May-09 8:24 
GeneralRe: Dynamically place .NET controls on Win32/MFC windows. Pin
rwe181210-May-09 22:42
rwe181210-May-09 22:42 
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


GeneralRe: Dynamically place .NET controls on Win32/MFC windows. Pin
Stuart Dootson10-May-09 23:27
professionalStuart Dootson10-May-09 23:27 
QuestionHow to Recognise a window Pin
john56328-May-09 2:12
john56328-May-09 2:12 
AnswerRe: How to Recognise a window Pin
_AnsHUMAN_ 8-May-09 2:16
_AnsHUMAN_ 8-May-09 2:16 
QuestionRe: How to Recognise a window Pin
David Crow8-May-09 2:35
David Crow8-May-09 2:35 
AnswerRe: How to Recognise a window Pin
john56328-May-09 2:43
john56328-May-09 2:43 
QuestionRe: How to Recognise a window Pin
David Crow8-May-09 2:53
David Crow8-May-09 2:53 
AnswerRe: How to Recognise a window Pin
john56328-May-09 3:12
john56328-May-09 3:12 
QuestionRe: How to Recognise a window Pin
David Crow8-May-09 3:47
David Crow8-May-09 3:47 
AnswerRe: How to Recognise a window Pin
john56328-May-09 6:53
john56328-May-09 6:53 
QuestionRe: How to Recognise a window Pin
john56328-May-09 3:42
john56328-May-09 3:42 
GeneralBasics Pin
Anil Kumar.Arvapalli8-May-09 2:04
Anil Kumar.Arvapalli8-May-09 2:04 
GeneralRe: Basics Pin
_AnsHUMAN_ 8-May-09 2:11
_AnsHUMAN_ 8-May-09 2:11 
QuestionHelp in win32 dll & c# Pin
ashish8patil8-May-09 1:40
ashish8patil8-May-09 1:40 
AnswerRe: Help in win32 dll & c# Pin
_AnsHUMAN_ 8-May-09 1:51
_AnsHUMAN_ 8-May-09 1:51 
GeneralRe: Help in win32 dll & c# Pin
ashish8patil8-May-09 2:10
ashish8patil8-May-09 2:10 
GeneralRe: Help in win32 dll & c# Pin
_AnsHUMAN_ 8-May-09 2:14
_AnsHUMAN_ 8-May-09 2:14 
QuestionMulti-thread Synchronization with Mutex [modified] Pin
barot8-May-09 1:31
barot8-May-09 1:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.