Click here to Skip to main content
15,922,584 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCSplitter and CTabCtrl - looking for ideas Pin
Vaclav_16-Feb-13 5:53
Vaclav_16-Feb-13 5:53 
Questioncalculator Pin
abhi sharma15-Feb-13 21:45
abhi sharma15-Feb-13 21:45 
AnswerRe: calculator Pin
Jibesh15-Feb-13 22:03
professionalJibesh15-Feb-13 22:03 
AnswerRe: calculator Pin
Thomas Daniels17-Feb-13 4:42
mentorThomas Daniels17-Feb-13 4:42 
AnswerRe: calculator Pin
庄伟东17-Feb-13 15:30
庄伟东17-Feb-13 15:30 
QuestionHo to add auto scroll feature on Dialog box? Pin
VCProgrammer15-Feb-13 20:11
VCProgrammer15-Feb-13 20:11 
AnswerRe: Ho to add auto scroll feature on Dialog box? Pin
Richard MacCutchan15-Feb-13 22:21
mveRichard MacCutchan15-Feb-13 22:21 
GeneralRe: Ho to add auto scroll feature on Dialog box? Pin
VCProgrammer17-Feb-13 17:30
VCProgrammer17-Feb-13 17:30 
AnswerRe: Ho to add auto scroll feature on Dialog box? Pin
_Flaviu17-Feb-13 19:54
_Flaviu17-Feb-13 19:54 
QuestionClient Certificates in WinHTTP Pin
basementman15-Feb-13 9:27
basementman15-Feb-13 9:27 
QuestionPossible to resolve the question ... in a short time Pin
Haiathem alhmoud15-Feb-13 7:48
Haiathem alhmoud15-Feb-13 7:48 
AnswerRe: Possible to resolve the question ... in a short time Pin
jeron115-Feb-13 8:08
jeron115-Feb-13 8:08 
AnswerRe: Possible to resolve the question ... in a short time Pin
David Crow16-Feb-13 14:56
David Crow16-Feb-13 14:56 
QuestionWindows 8 Modified Windows API List... Pin
Blake Miller15-Feb-13 7:35
Blake Miller15-Feb-13 7:35 
AnswerRe: Windows 8 Modified Windows API List... Pin
Richard MacCutchan15-Feb-13 22:18
mveRichard MacCutchan15-Feb-13 22:18 
Question_IID_IXMLHTTPRequest linker error Pin
Member 981141114-Feb-13 19:48
Member 981141114-Feb-13 19:48 
AnswerRe: _IID_IXMLHTTPRequest linker error Pin
Richard MacCutchan14-Feb-13 23:09
mveRichard MacCutchan14-Feb-13 23:09 
AnswerRe: _IID_IXMLHTTPRequest linker error Pin
David Crow15-Feb-13 5:31
David Crow15-Feb-13 5:31 
QuestionMCF Pin
FranksLIC14-Feb-13 10:55
FranksLIC14-Feb-13 10:55 
AnswerRe: MCF Pin
Jibesh14-Feb-13 11:12
professionalJibesh14-Feb-13 11:12 
AnswerRe: MCF Pin
jeron114-Feb-13 12:01
jeron114-Feb-13 12:01 
AnswerRe: MCF Pin
Maximilien15-Feb-13 1:20
Maximilien15-Feb-13 1:20 
AnswerRe: MCF Pin
SajeeshCheviry15-Feb-13 5:56
SajeeshCheviry15-Feb-13 5:56 
QuestionHosting .net window in MFC dialog Pin
Yunaless14-Feb-13 4:06
Yunaless14-Feb-13 4:06 
As the title says I am trying to host a .net modeless form inside an MFC dialog. I read the article Using WinForms controls in an MFC dialog[^] but I do not want to do it this was because I do not wish to compile the project that contains the MFC dialog in /clr.
So I tried a different path.
I created a /clr dll that exports a very simple function

XML
HWND getDotNetWindowHandler()
{
    HostedForm ^frm = gcnew HostedForm();
    return static_cast<HWND>(frm->Handle.ToPointer());
}


The hosted form is a .net form without borders. So my dialog takes the handler(by calling the dll, no need to show the implementation here) and places the form in a STATIC control window.

XML
m_pDotNetWnd = CWnd::FromHandle(getDotNetWindowHandler());
CWnd* pWndContainer = GetDlgItem(IDC_DOTNET_WND);
if(m_pDotNetWnd != NULL && pWndContainer != NULL)
{
   m_pDotNetWnd->SetParent(pWndContainer);
   m_pDotNetWnd->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_ASYNCWINDOWPOS | SWP_FRAMECHANGED);
   m_pDotNetWnd->ShowWindow(SW_SHOW);

   HWND hWndChild = m_pDotNetWnd->GetSafeHwnd();
   // reset the style
   DWORD style = GetWindowLong(hWndChild, GWL_STYLE);
   style &= ~(WS_POPUP|WS_CAPTION); //reset the "caption" and "popup" bits
   style |= WS_CHILD; //set the "child" bit
   SetWindowLongPtr(hWndChild, GWL_STYLE, style); //set the new style 

}


Everything seems to work just fine but after a while I am having a deadlock. The window freezes.
After a lot of research on the internet it seems to be a problem with the SendMessage when the child window is created from a different thread. I couldn't find any workarround though. Is there any? Can someone give me a clue?
QuestionCView::OnDraw - related question Pin
tagopi13-Feb-13 22:29
tagopi13-Feb-13 22:29 

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.