Haven't tried it, but what if you set the parent form class bits to
~WS_CLIPCHILDREN?
--
Alex Feinman
---
Visit
http://www.opennetcf.org [quoted text, click to view] "Sylvain Fortin" <SylvainFortin@discussions.microsoft.com> wrote in message
news:209D8665-AB3E-46D3-B26B-6970F92460FD@microsoft.com...
> Hi everyone,
>
> First of all, why am I having this problem... I need a REAL transparent
> label control. My custom label control needs to be able to be the child of
> any other control and must only display text, not a background image or
> color.
>
> So I created a control derived from System.Windows.Control, the problem is
> that the parent control doesn't draw under my custom control, probably
> because the parent thinks that the child will do it. However, I need the
> parent to completely draw itself. Is there a way to do it?
>
> Any help is appreciated, thanks!
>
> Sylvain Fortin
>
> public class ctrlLabel : Control
> {
> protected Brush m_brsBlack = null;
>
> ...
>
> // OnPaintBackground
> protected override void OnPaintBackground(PaintEventArgs pe)
> {
> }
>
> // OnPaint
> protected override void OnPaint(PaintEventArgs pe)
> {
> RectangleF rcArea = RectangleF.Empty;
>
> // Calling base class OnPaint
> base.OnPaint(pe);
>
> try
> {
> if (m_brsBlack == null)
> m_brsBlack = new SolidBrush(Color.Black);
>
> rcArea = new RectangleF(0, 0, this.Width, this.Height);
> pe.Graphics.DrawString(this.Text, this.Font, m_brsBlack, rcArea);
> }
> catch (Exception)
> {
> }
> }
> }
Hi Alex,
Thanks for the quick reply. This is a very good idea and I didn't think
about it. However, I tried it and it didn't work. I tired it on the custom
control parent (which is another custom control) and I also tried on the main
form (the only form in the application).
Here is my code sample, just in case I made a mistake.
Thanks for your help,
Sylvain Fortin
....
// Retrieve the main form HWND
Capture = true;
IntPtr hWnd = MyUtils.GetCapture();
Capture = false;
// Get the current window style
lWindowStyle = MyUtils.GetWindowLong(hWnd, -16/*GWL_STYLE*/);
// Change the style of the main form
nReturn = MyUtils.SetWindowLong(hWnd, -16/*GWL_STYLE*/, (int)(lWindowStyle &
~0x02000000L)/*WS_CLIPCHILDREN*/);
Hah... been there, done that... Not possible. The transparency is not
supported on the system level...
--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com |
www.opennetcf.org [quoted text, click to view] "Sylvain Fortin" wrote:
> Hi Alex,
>
> Thanks for the quick reply. This is a very good idea and I didn't think
> about it. However, I tried it and it didn't work. I tired it on the custom
> control parent (which is another custom control) and I also tried on the main
> form (the only form in the application).
>
> Here is my code sample, just in case I made a mistake.
>
> Thanks for your help,
>
> Sylvain Fortin
>
> ...
>
> // Retrieve the main form HWND
> Capture = true;
> IntPtr hWnd = MyUtils.GetCapture();
> Capture = false;
>
> // Get the current window style
> lWindowStyle = MyUtils.GetWindowLong(hWnd, -16/*GWL_STYLE*/);
>
> // Change the style of the main form
> nReturn = MyUtils.SetWindowLong(hWnd, -16/*GWL_STYLE*/, (int)(lWindowStyle &
> ~0x02000000L)/*WS_CLIPCHILDREN*/);
>
Don't see what you're looking for? Try a search.