{"id":140,"date":"2010-06-30T17:08:00","date_gmt":"2010-06-30T17:08:00","guid":{"rendered":"http:\/\/madprogrammer76.wordpress.com\/2010\/06\/30\/dotnet-windows-form-image-transparency"},"modified":"2010-06-30T17:08:00","modified_gmt":"2010-06-30T17:08:00","slug":"dotnet-windows-form-image-transparency","status":"publish","type":"post","link":"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/","title":{"rendered":"DotNet Windows Form Image Transparency"},"content":{"rendered":"<p>Recently during a project I had a need to overlay an image on a windows form in order to indicate a status of inability.\u00a0 This image had a semi-transparency quality as well as a full transparency background.\u00a0 To my dismay, the semi-transparency rendered in full color and the full transparency background seemed to inherit the parent form, but not show the controls behind it as one would expect.<\/p>\n<p>After sometime of researching the issue, I came to a determination that what I was trying to do could only be done in web development (HTML).\u00a0 From my research I had assembled some ideas in how to make transparencies work.\u00a0\u00a0 I took ideas from several sources and came up with the following.<\/p>\n<p><strong>Step By Step ( see Sample Code )<\/strong><\/p>\n<p>1. Create a class that extends System.Windows.Forms.Control<br \/>\n2. Place code from sample cod<br \/>\n3. Compile Project<br \/>\n4. Add new control to the Form ( remember this is for a windows application )<br \/>\n5. Set Background Image<\/p>\n<p><strong>Sample Code<\/strong><\/p>\n<pre>\n<span class=\"Apple-style-span\" style=\"font-family:Consolas, Monaco, monospace;font-size:12px;line-height:18px;white-space:pre;\">\nprotected override CreateParams CreateParams\n{\n     \/\/ Make window transparent\n     get\n     {\n          CreateParams cp = base.CreateParams;\n          cp.ExStyle |= 0x20;  \/\/ WS_EX_TRANSPARENT return cp;\n     }\n}\n\nprotected override void OnPaintBackground(PaintEventArgs pevent)\n{\n\/\/ Do not paint the background\n}\n\nprotected override void OnPaint(PaintEventArgs e)\n{ \n     \/\/ Paint background image \n     if (BackgroundImage != null)\n     {\n          Bitmap bmp = new Bitmap(BackgroundImage);\n          bmp.MakeTransparent(Color.White);\n          e.Graphics.DrawImage(bmp, 0, 0, Width, Height);\n     }\n}<\/pre>\n<p><strong>Note:\u00a0 <\/strong>When you overlay an image &#8211; even transparent, you may see the controls behind, but you will not be able to access them.\u00a0 This is true in both web and windows development.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently during a project I had a need to overlay an image on a windows form in order to indicate a status of inability.\u00a0 This image had a semi-transparency quality as well as a full transparency background.\u00a0 To my dismay, the semi-transparency rendered in full color and the full transparency background seemed to inherit the &hellip; <a href=\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">DotNet Windows Form Image Transparency<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,13,23,25],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>DotNet Windows Form Image Transparency - LDNDeveloper<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"DotNet Windows Form Image Transparency - LDNDeveloper\" \/>\r\n<meta property=\"og:description\" content=\"Recently during a project I had a need to overlay an image on a windows form in order to indicate a status of inability.\u00a0 This image had a semi-transparency quality as well as a full transparency background.\u00a0 To my dismay, the semi-transparency rendered in full color and the full transparency background seemed to inherit the &hellip; Continue reading DotNet Windows Form Image Transparency\" \/>\r\n<meta property=\"og:url\" content=\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/\" \/>\r\n<meta property=\"og:site_name\" content=\"LDNDeveloper\" \/>\r\n<meta property=\"article:published_time\" content=\"2010-06-30T17:08:00+00:00\" \/>\r\n<meta name=\"author\" content=\"andrewpallant\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:creator\" content=\"@ldnDeveloper\" \/>\r\n<meta name=\"twitter:site\" content=\"@LdnDeveloper\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"andrewpallant\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/\"},\"author\":{\"name\":\"andrewpallant\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97\"},\"headline\":\"DotNet Windows Form Image Transparency\",\"datePublished\":\"2010-06-30T17:08:00+00:00\",\"dateModified\":\"2010-06-30T17:08:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/\"},\"wordCount\":198,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\"},\"articleSection\":[\"Better Coding\",\"C#\",\"Deployment\",\"DotNet\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/\",\"url\":\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/\",\"name\":\"DotNet Windows Form Image Transparency - LDNDeveloper\",\"isPartOf\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#website\"},\"datePublished\":\"2010-06-30T17:08:00+00:00\",\"dateModified\":\"2010-06-30T17:08:00+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/andrewpallant.ca\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DotNet Windows Form Image Transparency\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#website\",\"url\":\"http:\/\/andrewpallant.ca\/wordpress\/\",\"name\":\"LDNDeveloper\",\"description\":\"Learning, Growing and Sharing.\",\"publisher\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/andrewpallant.ca\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\",\"name\":\"ldnDeveloper\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg\",\"contentUrl\":\"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg\",\"width\":512,\"height\":512,\"caption\":\"ldnDeveloper\"},\"logo\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\"},\"description\":\"Andrew Pallant (@LdnDeveloper) has been a web, database and desktop developer for over 16 years. Andrew has worked on projects that ranged from factory automation to writing business applications. Most recently he has been heavily involved in various forms for ecommerce projects. Over the years Andrew has worn many hats: Project Manager, IT Manager, Lead Developer, Supervisor of Developers and many more - See more at: http:\/\/www.unlatched.com\/#sthash.8DiTkpKy.dpuf\",\"sameAs\":[\"http:\/\/www.andrewpallant.ca\",\"https:\/\/x.com\/LdnDeveloper\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97\",\"name\":\"andrewpallant\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"caption\":\"andrewpallant\"},\"url\":\"http:\/\/andrewpallant.ca\/wordpress\/author\/andrewpallant\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"DotNet Windows Form Image Transparency - LDNDeveloper","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/","og_locale":"en_US","og_type":"article","og_title":"DotNet Windows Form Image Transparency - LDNDeveloper","og_description":"Recently during a project I had a need to overlay an image on a windows form in order to indicate a status of inability.\u00a0 This image had a semi-transparency quality as well as a full transparency background.\u00a0 To my dismay, the semi-transparency rendered in full color and the full transparency background seemed to inherit the &hellip; Continue reading DotNet Windows Form Image Transparency","og_url":"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/","og_site_name":"LDNDeveloper","article_published_time":"2010-06-30T17:08:00+00:00","author":"andrewpallant","twitter_card":"summary_large_image","twitter_creator":"@ldnDeveloper","twitter_site":"@LdnDeveloper","twitter_misc":{"Written by":"andrewpallant","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/#article","isPartOf":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/"},"author":{"name":"andrewpallant","@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97"},"headline":"DotNet Windows Form Image Transparency","datePublished":"2010-06-30T17:08:00+00:00","dateModified":"2010-06-30T17:08:00+00:00","mainEntityOfPage":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/"},"wordCount":198,"commentCount":0,"publisher":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84"},"articleSection":["Better Coding","C#","Deployment","DotNet"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/","url":"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/","name":"DotNet Windows Form Image Transparency - LDNDeveloper","isPartOf":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/#website"},"datePublished":"2010-06-30T17:08:00+00:00","dateModified":"2010-06-30T17:08:00+00:00","breadcrumb":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/andrewpallant.ca\/wordpress\/dotnet-windows-form-image-transparency\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/andrewpallant.ca\/wordpress\/"},{"@type":"ListItem","position":2,"name":"DotNet Windows Form Image Transparency"}]},{"@type":"WebSite","@id":"http:\/\/andrewpallant.ca\/wordpress\/#website","url":"http:\/\/andrewpallant.ca\/wordpress\/","name":"LDNDeveloper","description":"Learning, Growing and Sharing.","publisher":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/andrewpallant.ca\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84","name":"ldnDeveloper","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg","contentUrl":"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg","width":512,"height":512,"caption":"ldnDeveloper"},"logo":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/"},"description":"Andrew Pallant (@LdnDeveloper) has been a web, database and desktop developer for over 16 years. Andrew has worked on projects that ranged from factory automation to writing business applications. Most recently he has been heavily involved in various forms for ecommerce projects. Over the years Andrew has worn many hats: Project Manager, IT Manager, Lead Developer, Supervisor of Developers and many more - See more at: http:\/\/www.unlatched.com\/#sthash.8DiTkpKy.dpuf","sameAs":["http:\/\/www.andrewpallant.ca","https:\/\/x.com\/LdnDeveloper"]},{"@type":"Person","@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97","name":"andrewpallant","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g","caption":"andrewpallant"},"url":"http:\/\/andrewpallant.ca\/wordpress\/author\/andrewpallant\/"}]}},"_links":{"self":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts\/140"}],"collection":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":0,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"wp:attachment":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}