Hello!

i have a windows form application which i have many controls such textboxes buttons and more.
that i need is to draw or add a control on top of all the form.but i need that control to be transparent so the user can see the textboxes and labels behind him but of course he can't perform any action because this control overlap all the form controls.

Thank you for your help

Dani AI

Generated

A quick practical summary and reliable approaches for the scenario described (an embedded PDF that still shows Adobe's hover icons):

Normal WinForms "transparent" child controls generally will not sit visually above windowed ActiveX controls (Adobe Reader, browser plugins, etc.) because those are separate HWNDs and Windows draws them differently. That is why simply making a control BackColor = Transparent won’t hide or block the Reader UI.

Two reliable ways to solve this

  • First, prefer disabling the PDF viewer UI via its API (least intrusive). Many embeddable viewers / ActiveX controls expose methods or properties to hide toolbars, context menus and printing. If the control you use exposes such flags, use them rather than fighting window z-order.

  • If you cannot change the viewer, create a top-level overlay window that visually lets the PDF show through while intercepting input. A simple WinForms approach is a borderless owned Form positioned over the PDF control, using a unique BackColor and setting TransparencyKey (or using layered-window Opacity) so the PDF remains visible while the overlay receives mouse events. Keep the overlay owned so it moves with the main form, and update its Bounds on the parent form's Move/Resize events.

Example pattern (C#):

var overlay = new Form {
  FormBorderStyle = FormBorderStyle.None,
  ShowInTaskbar = false,
  StartPosition = FormStartPosition.Manual,
  BackColor = Color.Magenta,
  TransparencyKey = Color.Magenta
};
overlay.Owner = this; // owner = main form
overlay.Bounds = this.RectangleToScreen(pdfControl.Bounds);
overlay.Show();
// keep overlay in sync with the main form
this.Move += (s,e) => overlay.Bounds = this.RectangleToScreen(pdfControl.Bounds);
this.Resize += (s,e) => overlay.Bounds = this.RectangleToScreen(pdfControl.Bounds);

Notes and cautions

  • Test on target Windows versions; TransparencyKey and layered windows behave differently under Aero/composited desktops. If TransparencyKey misbehaves, use a layered window with Opacity and a nearly invisible alpha (e.g., 0.01) to still intercept clicks.
  • The overlay blocks keyboard and selection on the PDF (intended). If you need selective passthrough, you must handle/forward specific input explicitly.
  • Rendering PDF pages to bitmaps (PDFium, MuPDF, etc.) and showing them in a PictureBox is an alternative: you get full control and can place ordinary child controls on top without HWND issues.

As noted, making editable fields read-only is the simplest fix for form controls — but for embedded PDF UI you’ll want one of the approaches above.

Recommended Answers

All 2 Replies

You can just set the ReadOnly property of the textBox to true and the user won't be able to edit it's contents, it's alot less work and more logical.

no i dont want this.the fact is that i display a pdf into the windows form,so i tried to set the security on the pdf itself,but the awful truth come with the new adobe reader,on mouse hover it shows the save and print icon.
so i want to add a control on top of the pdf.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.