Click here to Skip to main content
15,916,527 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: c LANGUAGE PROGRAM Pin
Erudite_Eric20-Oct-11 7:49
Erudite_Eric20-Oct-11 7:49 
QuestionProblem with overlapping alphablended lines in GDI+ Pin
Code-o-mat6-Oct-11 0:56
Code-o-mat6-Oct-11 0:56 
AnswerRe: Problem with overlapping alphablended lines in GDI+ Pin
PJ Arends7-Oct-11 9:55
professionalPJ Arends7-Oct-11 9:55 
GeneralRe: Problem with overlapping alphablended lines in GDI+ Pin
Code-o-mat7-Oct-11 10:25
Code-o-mat7-Oct-11 10:25 
QuestionShort cut key is not working properly Pin
Amrit Agr6-Oct-11 0:43
Amrit Agr6-Oct-11 0:43 
AnswerRe: Short cut key is not working properly Pin
Richard MacCutchan6-Oct-11 5:55
mveRichard MacCutchan6-Oct-11 5:55 
AnswerRe: Short cut key is not working properly Pin
PJ Arends7-Oct-11 11:31
professionalPJ Arends7-Oct-11 11:31 
QuestionResizing a WPF Window that is a child to a CView Pin
nadine123455-Oct-11 22:01
nadine123455-Oct-11 22:01 
Dear all,

I am facing a weird problem and I need your help. I have an MFC MDI application, and I am trying to create a WPF Window as a child of the opened CView.

I was able to successfully do that by handling the OnCreate message in my CView, and creating the WPF window. I also set the CView to be the parent of the WPF window so it behaves as its child.

Here is what I did:

C#
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CView::OnCreate(lpCreateStruct) == -1)
        return -1;

    m_windowWrapper.Create(this->GetSafeHwnd());

    return 0;
}

void CMyWindowWrapper::Create(HWND hParent)
{
    m_myWindow = gcnew MyWindow();
    m_myWindow->Show();

    IntPtr^ hChildWnd = m_myWindow->GetHwnd();
    ::SetParent((HWND)hChildWnd->ToPointer(), hParent);
}

public partial class MyWindow : Window
{
        public MyWindow()
        {
            InitializeComponent();
            MouseLeftButtonDown += (o, e) => DragMove();
        }

        public IntPtr GetHwnd()
        {
            return (new System.Windows.Interop.WindowInteropHelper(this)).Handle;
        }
    }ndows.Interop.WindowInteropHelper(this)).Handle;
        }
}



The WPF window appear as expected. Now the problem happens when I try to resize the WPF window. Suddenly the controls inside the window are streched and re-positioned as if the new size of the WPF window is the size of the parent CView! I tried to handle the SizeChanged event, and found that the NewSize was much larger than the size of the WPF window and was most probably the size of the containing CView.

I tried to remove the SetParent call, and the resizing worked correctly. I wonder what is going wrong in resizing and WPF window whose parent is a CView.

I uploaded a sample application illustrating the problem:
http://cid-a059807de2e23c43.office.live.com/self.aspx/.Public/ResizeProblem.zip

Please help me.
Thank you.

modified 6-Oct-11 10:01am.

AnswerRe: Resizing a WPF Window that is a child to a CView Pin
TheGreatAndPowerfulOz6-Oct-11 11:05
TheGreatAndPowerfulOz6-Oct-11 11:05 
GeneralRe: Resizing a WPF Window that is a child to a CView Pin
nadine123456-Oct-11 21:34
nadine123456-Oct-11 21:34 
GeneralRe: Resizing a WPF Window that is a child to a CView Pin
TheGreatAndPowerfulOz7-Oct-11 4:47
TheGreatAndPowerfulOz7-Oct-11 4:47 
GeneralRe: Resizing a WPF Window that is a child to a CView Pin
nadine123458-Oct-11 9:09
nadine123458-Oct-11 9:09 
AnswerRe: Resizing a WPF Window that is a child to a CView Pin
TheGreatAndPowerfulOz18-Oct-11 7:33
TheGreatAndPowerfulOz18-Oct-11 7:33 
QuestionHow do you const your references? Pin
User 5838525-Oct-11 18:35
User 5838525-Oct-11 18:35 
AnswerRe: How do you const your references? Pin
Stefan_Lang6-Oct-11 0:53
Stefan_Lang6-Oct-11 0:53 
GeneralRe: How do you const your references? Pin
TheGreatAndPowerfulOz6-Oct-11 5:55
TheGreatAndPowerfulOz6-Oct-11 5:55 
GeneralRe: How do you const your references? Pin
Stefan_Lang6-Oct-11 6:09
Stefan_Lang6-Oct-11 6:09 
GeneralRe: How do you const your references? Pin
TheGreatAndPowerfulOz6-Oct-11 6:37
TheGreatAndPowerfulOz6-Oct-11 6:37 
GeneralRe: How do you const your references? Pin
Stefan_Lang6-Oct-11 6:48
Stefan_Lang6-Oct-11 6:48 
GeneralRe: How do you const your references? Pin
TheGreatAndPowerfulOz6-Oct-11 7:07
TheGreatAndPowerfulOz6-Oct-11 7:07 
GeneralRe: How do you const your references? Pin
Stefan_Lang6-Oct-11 22:07
Stefan_Lang6-Oct-11 22:07 
AnswerRe: How do you const your references? Pin
«_Superman_»6-Oct-11 6:05
professional«_Superman_»6-Oct-11 6:05 
QuestionPostMessage with WPARAM does not work Pin
Vaclav_5-Oct-11 17:43
Vaclav_5-Oct-11 17:43 
AnswerRe: PostMessage with WPARAM does not work Pin
Richard MacCutchan5-Oct-11 21:39
mveRichard MacCutchan5-Oct-11 21:39 
AnswerRe: You can't simulate keyboard input with PostMessage Pin
Software_Developer5-Oct-11 21:50
Software_Developer5-Oct-11 21:50 

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.