C
C#14mo ago
Tim

❔ HwndHost not rendering embedded window

protected override HandleRef BuildWindowCore(HandleRef hwndParent)
{
SetParent(_hostedHandle.Handle, hwndParent.Handle);
SetWindowLongPtr(_hostedHandle, WINDOW_STYLE, new IntPtr(WINDOW_STYLE_CHILD | WINDOW_STYLE_CLIP_SIBLINGS | WINDOW_STYLE_MAXIMIZE | WINDOW_STYLE_VISIBLE));
MoveWindow(_hostedHandle.Handle, 0, 0, 500, 500, true);
ShowWindow(_hostedHandle.Handle, 3);
return _hostedHandle;
}
protected override HandleRef BuildWindowCore(HandleRef hwndParent)
{
SetParent(_hostedHandle.Handle, hwndParent.Handle);
SetWindowLongPtr(_hostedHandle, WINDOW_STYLE, new IntPtr(WINDOW_STYLE_CHILD | WINDOW_STYLE_CLIP_SIBLINGS | WINDOW_STYLE_MAXIMIZE | WINDOW_STYLE_VISIBLE));
MoveWindow(_hostedHandle.Handle, 0, 0, 500, 500, true);
ShowWindow(_hostedHandle.Handle, 3);
return _hostedHandle;
}
I have this code in a class overriding HwndHost. The process is correctly parented, and I can even send input to the embedded window. It however doesn't show anything (see added image)
No description
8 Replies
Tim
TimOP14mo ago
Is there some native windows methods I could try calling on the window to make it show? As you can see I tried ShowWindow, MoveWindow and SetWindowLong with maximize and whatever Is there mayb a function to set z-ordering?
Omnissiah
Omnissiah14mo ago
by doesn't show anything you mean you don't see the "child" window? not even before manipulating it?
Tim
TimOP14mo ago
It doesn't render. I can give it input (for example the child window has a text input, which I can type into) However, I just now found out that if I set my main (parent) form to not allow transparency, it works. AllowsTransparency="True" <- This makes it so the child window doesn't get shown Is there mayb a solution to that? or at least an explanation? At this point it's just curiosity, the final application doesn't really require transparency Oh ^-^ when I do a random call to make the window style layered it works with transparency SetWindowLongPtr(_hostedHandle, WINDOW_STYLE_EX, new IntPtr(WINDOW_STYLE_EX_LAYERED)); Windows is weird
Omnissiah
Omnissiah14mo ago
it's not weird, it's that they are limited and maybe you don't 100% know what you are doing have you tried going one style at a time, to understand which one is messing up the form also are you creating the form or are you taking one already instantiated because if you are creating it (or i should say them) there should not really be many problems the container is an mdi right?
Jester
Jester14mo ago
i almost always make my windows layered (might have to call setlayeredwindowattributes as well) it makes the window better in subtile ways
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Tim
TimOP14mo ago
Well theres almost no docs on this Like yes there is information on the facts, but not on common problems and solutions Ah well it's fixed anyways. No style was messing it up, just needed to make it layered It was my own form, and the window I wanted to embed was from a process I started in C#, outside of my general control. Hmm yeah just annoying that I've not seen layered style come across when I was googling my issue All feels so obscure but maybe that is my lack of knowledge
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server