简体   繁体   中英

Overlay an InkCanvas on a custom WinForms control

I have a custom WinForms control that displays some graphics. I need to overlay an InkCanvas on top of this control. The InkCanvas should be "see through" (transparent background, visible ink). This InkCanvas allows the user to sketch on the graphics being displayed.

I know about the airspace issue in WPF/WinForms interop (the fact that WinForms elements hosted in a WPF window will always stay on top of all other components). So obviously I cannot achieve the desired effects in WPF. I decided to go about the problem the other way around (host an InkCanvas in a WinForms form and overlay the InkCanvas on my custom control).

The problem is that the WinForms ElementHost cannot be made "see through" (no transparency can be set). I tried deriving ElementHost with the following override

protected override CreateParams CreateParams
{
    get
    {
        const int WS_EX_TRANSPARENT = 0x20;
        CreateParams cp = base.CreateParams;
        cp.ExStyle = cp.ExStyle | WS_EX_TRANSPARENT;
        return cp;
    }
}

But this will make the whole thing completely transparent (the sketches are not visible any more).

How can I have the "see through" InkCanvas with visible ink overlayed on the WinForms control?

基于评论和缺乏答案,我们可以放心地假设除非要进行@Hans Passant提到的“窗口分层”黑客,否则我想做的事情是不可能的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM