0

I'm trying to create child form on other process form without activation, everything is ok except that my form appearing in front of screen when showing - after f.Visible=true - but i need to keep both of them somewhere behind.

Here's code:

public class OSD {
    public class OSD_form:Form {
        protected override bool ShowWithoutActivation {
            get { return true; }
        }
        protected override CreateParams CreateParams {
            get {
                CreateParams p=base.CreateParams;

                //p.Style |= 0x40000000; // WS_CHILD
                p.ExStyle|=0x8000000; // WS_EX_NOACTIVATE
                p.ExStyle|=0x00080000; // WS_EX_LAYERED
                p.ExStyle|=0x0020; // WS_EX_TRANSPARENT

                return p;
            }
        }
    }
    private OSD_form f=null;
    public IntPtr AttachedTo=IntPtr.Zero;

    public OSD() {
        f=new OSD_form();

        f.FormBorderStyle=FormBorderStyle.None;
        f.ShowInTaskbar=false;
    }

    public void Show() {
        long l2=winapi.GetWindowLong(f.Handle,winapi.GWL_EXSTYLE);
        l2|=winapi.WS_EX_LAYERED;
        l2|=winapi.WS_EX_TRANSPARENT;
        winapi.SetWindowLong(f.Handle,winapi.GWL_EXSTYLE,new IntPtr(l2));
        winapi.SetLayeredWindowAttributes(f.Handle,0,(255*90)/100,winapi.LWA_ALPHA);

        window w=new window(AttachedTo);
        f.Width=160;
        f.Height=60;
        f.Left=w.Client.Left+4;
        f.Top=w.Client.Top+4;

        f.Show(new WindowWrapper(AttachedTo));

        f.Visible=true;

    }
}
4

0 回答 0