Thread: Transparent panels overlapped

  1. #1
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120

    Post Transparent panels overlapped

    I have a question about transparent panels or other containers.

    Is there a way to make the actual panel or container transparent but the things it contains still remain visible? I have tried a few things but nothing seems to do it. When I set the background to transparent, it only sets the background to the same background the main form uses, its not really transparent because if you drag it over buttons or other items on the form, it is blocked out.

    Is there a way to make this transparent completely?

    What i am trying to accomplish is i am messing with making an electronic version of the game Cathedrals, The game of the Mediaeval City.

    The issue i have is the pieces in the game (that i am trying to make drag able easily) are of different shapes, as seen here.

    I have tried placing a grid of picture boxes (for skin-ability) inside a panel and setting the panels background to transparent but that doesn't work. I have also just had a couple of picture boxes for each piece but then i end up having some overhead on figuring out what the orientation of the piece is and then moving each pic box accordingly.

    You think maybe there is another method to achieve this? I cant think of any other ways to easily drag the pieces around no matter what orientation they are in.

    Does my question make sense or is this just a useless ramble? heh.
    Any thoughts or ideas or help is much appreciated.
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

  2. #2
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120
    Here is sort of an example of the game to give you an idea. I did not write this version, and it is in flash and i was not able to get the pieces to rotate but it gives you a little hands on with the actual game.
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

  3. #3
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120
    Dang, I tried creating my own control and it had the same effect as a panel full of items.

    I used UserControl to inherit from and overrode the OnPaint method to draw one of the odd shapes of the pieces but I get the same issue of the overlap.

    Is there a better way to draw the custom control?

    here is the detail in my class

    Code:
    protected override void OnPaint(PaintEventArgs e)
    {
        Graphics graphics = e.Graphics;
        SolidBrush brush = new SolidBrush(Color.Gold);
        graphics.FillRectangle(brush, 80, 0, 40, 40);
        graphics.FillRectangle(brush, 40, 40, 80, 40);
        graphics.FillRectangle(brush, 0, 80, 80, 40);            
    }
    and initialized like

    Code:
    CustomShape1 custShape1 = new CustomShape1();
    custShape1.Location = new System.Drawing.Point(12, 12);
    custShape1.Name = "custShape1";
    custShape1.Size = new System.Drawing.Size(120, 120);
    is there another way where I can only have it draw my rectangles to create the shape without drawing the entire containing rectangle?

    As always, thanks in advance!
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

  4. #4
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120
    ok, figured it out

    in the OnPaint method do something like this
    Code:
    System.Drawing.Drawing2D.GraphicsPath myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
    myGraphicsPath.AddRectangle(new Rectangle( 80, 0, 40, 40));
    myGraphicsPath.AddRectangle(new Rectangle( 40, 40, 80, 40));
    myGraphicsPath.AddRectangle(new Rectangle( 0, 80, 80, 40));
    button1.Region = new Region(myGraphicsPath);
    this creates the viewable areas and you can drag it over other items and see the other items where this is not drawn.

    i used a button in the above example.
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Transparent, Editbox, HOLLOW_BRUSH, Marking text?
    By Dampy in forum Windows Programming
    Replies: 6
    Last Post: 09-22-2008, 07:17 PM
  2. Transparent bmp on top of webcam feed?
    By h3ro in forum Windows Programming
    Replies: 4
    Last Post: 08-06-2008, 09:45 AM
  3. Having Buffer Problems With Overlapped I/O --
    By Sargera in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 04:46 PM
  4. OSD or transparent window
    By Mox in forum Windows Programming
    Replies: 5
    Last Post: 01-28-2003, 06:31 PM
  5. Overlapped I/O and Completion Port :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 10-30-2002, 05:14 PM