C
C#4w ago
nullptr

win32 island in wpf application has #f0f0f0 background colour

hii!! i'm working on a project which requires an embedded win32 control. however, the background of the island is always #f0f0f0 instead of #ffffff. this occurs even if the window is hosting no control and is just a child window. see the attached image for an example
No description
2 Replies
nullptr
nullptr4w ago
(the only parts in ControlHost which matter in this instance are BuildWindowCore and WndProc, which i'll provide below)
protected override HandleRef BuildWindowCore(HandleRef hwndParent)
{
// this is just for testing to see if command links are the problem (they aren't - the bg is still #f0f0f0)
hwndControl = CreateWindowEx(0, "static", "This half of the window is being rendered by a Win32 island via HwndHost. Notice how the background is #f0f0f0.",
WindowStyles.WS_VISIBLE | WindowStyles.WS_CHILD,
0, 0,
hostWidth, hostHeight,
hwndParent.Handle,
IntPtr.Zero,
IntPtr.Zero,
0);

return new HandleRef(this, hwndControl.DangerousGetHandle());
}

protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
handled = false;
return IntPtr.Zero;
}
protected override HandleRef BuildWindowCore(HandleRef hwndParent)
{
// this is just for testing to see if command links are the problem (they aren't - the bg is still #f0f0f0)
hwndControl = CreateWindowEx(0, "static", "This half of the window is being rendered by a Win32 island via HwndHost. Notice how the background is #f0f0f0.",
WindowStyles.WS_VISIBLE | WindowStyles.WS_CHILD,
0, 0,
hostWidth, hostHeight,
hwndParent.Handle,
IntPtr.Zero,
IntPtr.Zero,
0);

return new HandleRef(this, hwndControl.DangerousGetHandle());
}

protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
handled = false;
return IntPtr.Zero;
}
Omnissiah
Omnissiah4w ago
but did you set the background brush? (iirc)
Want results from more Discord servers?
Add your server