Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7969043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:10:29+00:00 2026-06-04T07:10:29+00:00

My WPF application has more than one window, I want to attach some of

  • 0

My WPF application has more than one window, I want to attach some of these windows to a window of another process. My problem is that once I attach my window it becomes invisible.

I’m trying this with the following code:

public static bool setParentWindow(IntPtr hWndChild, IntPtr hWndNewParent)
    {
    IntPtr previousParent = SetParent(hWndChild, hWndNewParent);
    return (previousParent == null ? false : true);
}

[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

setParentWindow(myWindowHwnd, newParentHwnd);

So, the above code successfully attaches the window, but unfortunately makes it invisible.

My reason for doing this is that I’m trying to extend an application by building “Widgets” for it, my widgets will hook in and show the user extra information.

Both windows have the following styles: WS_OVERLAPPEDWINDOW, WS_OVERLAPPED, WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:10:31+00:00Added an answer on June 4, 2026 at 7:10 am

    I found that I could do this without even using the setParent call. I used HwndSource class as follows:

    MyWindow window = new MyWindow();
    window.ShowActivated = true;
    
    HwndSourceParameters parameters = new HwndSourceParameters();
    
    parameters.WindowStyle = 0x10000000 | 0x40000000;
    parameters.SetPosition(0, 0);
    parameters.SetSize((int)window.Width, (int)window.Height);
    parameters.ParentWindow = newParent;
    parameters.UsesPerPixelOpacity = true;
    HwndSource src = new HwndSource(parameters);
    
    src.CompositionTarget.BackgroundColor = Colors.Transparent;
    src.RootVisual = (Visual)window.Content;
    

    This is working great now without any problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a WPF/C# application and I'm having more of a design problem than
There is a similar question at WPF versus Windows Forms which has some good
I am developing a big modular WPF application one of these modules are widgets
Im writing a WPF application that has a zoom and pan ability, but what
I have a DataGrid in a WPF application which has for its ItemsSource a
I need to write an WPF(4.0) application which has a DB but no tables
I need to convert my WPF application, which has a Ribbon , to use
It seems that when a WPF application starts, nothing has focus. This is really
I'm building WPF client application. I'm following MVC pattern. The project solution has many
I am working on a WPF MVVM application. It has a custom canvas class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.