• 0

[C#] Non-Rectangular Forms with soft edges


Question

I've been searching on Google about borderless forms and non-rectangular forms and I've found lots of examples on how to achieve this. However, every single example has one little issue, all the edges of the form are pretty rough and I'm looking for soft edges. I don't want my form to look all pixelated but I can't find a way to achieve this.

Is this possible at all in .NET? How?

Recommended Posts

  • 0

Yes, I know how to use Photoshop and make the shape I want with soft edges, that's not the Issue. The only way I know to create a form the shape I want is to make my image with the shape I want and a background color like 255, 0, 255 (magenta). Then, on the form, set this image as background image and set the transparent key color to magenta. But this won't produce soft edges. I want to do something like Photoshop splash screen for instance. Rounded square with a shadow...

  • 0
  Menge said:
save the image in photoshop as PNG without the magenta backgroudn... just NO background, so it's fully transparent where it should be... then in the form, add it to the background. that's it.

I just tried it, that doesn't work... I still have the background from the form.

  • 0

Yeah, I've already found that article on the code project and was going to take a deeper look later. We'll see if it helps but if anyone has any other solution, more easy to implement, let us know...

WPF crossed my mind actually but I'm waiting for VS2008 final version and also for it to be available through MSDNAA which could take a while.

  • 0

Looking at Layered Windows but I don't think it will help me.

My idea is to designed my own form borders and caption and if Menge suggestion did work, it was the simplest way. I know I can pain the non-client area, but that is a bit harder than I thought and also doesn't support alpha transparency as far as I know.

  • 0

Layered Windows is the type of route you want to take,

Another article - http://www.codeproject.com/useritems/Translucent_Windows.asp

When you come across a development problem (you seem to have many), do you search first, or come straight to Neowin?

  • 0

I always search first. But I never find what I want everytime... If I had posted every development problem I've had since I started learning C#. I would have 5 times more the posts I have. Belive me, I always search first, sometimes I just don't know exactly the words to search for. For instance, I would never search for "layered windows"...

I'll take a look at that project. Thanks.

  • 0

I just took a look at that Translucent Windows article but I found the code too confusing with all those Forms and pieces of the code here and there. I've been reading a lot about these "layered windows" and I don't know if it's exactly possible to do what I want using layered windows. I mean, I want a form that is non-rectangular of course (in fact it's rectangular, but with round soft corners) that is able to:

1) Be resizeable just like any other form. Dragging the corners or the sides, top or bottom.

2) I can add controls (textboxes, labels, etc...) just like any other form.

After everything I read, I'm not sure Layered Windows helps me achieve what I want. Can anyone confirm if these 2 things are even possible using this technique?

Now, if it is, can someone provide me an example but less confusing? If that's too much work, don't bother if you don't want. Or, if you know of another example about layered windows that's easier and simple to understand, let me know. I'll do another search about layered windows later on though.

  • 0

If you have to put controls on the form, and users will be using it, odds are you shouldn't be doing what you're trying to do. (I recall your last asking for UI tips thread.)

For something like a splash screen, which is mostly decorative, of course something like this can look cool. But 99.99% of the time, you should be letting the OS draw its own window borders. They generally look better, and they always follow the user's theme settings. (For instance, what if a user hikes up his border padding?)

And let's face it. They're easier to work with most of the time, rather than trying to reimplement every last little detail that Windows handles automatically for you. (And let's face it, you won't remember to implement every little detail, no one can. Or you'll get something like the area that triggers resize cursor off by a few pixels, and cause general frustration for your users.)

  • 0

Why shouldn't I? Because many people say that? I'm sorry but I don't agree with that... There are applications and applications. Some might look horrible skinned, for instance, ATi CCC, everyone knows that. But there are other applications that it just fits and looks good. Besides, I don't want to skin the application, just the borders and caption, that's it.

I've already done a mock up of the UI and I really like it and I think it's pretty cool, although it's not finished and it can take a while. And trust me, most people that use or would like to use this application would probably like it. They may not like it but it's going to be because they don't like the design itself and not cause it doesn't fit their theme settings. Like I said, there are applications and applications and I'm doing something that just looks good and looks better than windows default theme for it's purpose. It's like winamp: Forget for a couple of seconds that Winamp is not skinable, and now look at the default skin of version 5. Do you think people would like winamp if it just had a border and a caption like all windows applications? I don't think so and that's all I'm trying to say.

I agree with you for a part. Most of time, we should just use the default stuff and let windows do the job so everything looks consistent and just fits, but there are some applications that they will look much better if they are different. And I believe that my application fits that category. That's my opinion and I respect yours but I won't going to change my mind because I don't agree that every single application has to look "default" and not have "it's touch".

It's like, look at WPF. Why did Microsoft develop it? Why did they offer all that functionality with WPF? Everyone can really customize the look of their applications with WPF easier than ever. Why did they do that if it's not for people to make their applications look the way they want? I just want my application to look more like a gadget or something that to a real application. It's a simple application that in fact as functionality looking more like a gadget than anything else. Like I said, there are applications and applications...

About handling every little detail, you might be right. But the truth is, I might not need every functionality windows provides and the functionality I need, I may be able to reimplement it. If not, well, that's a problem and I'll deal with that when and if the time comes.

You have the right to your opinion has I have the right to mine and I think your thinking about the UI design and the whole thing about just going standard for every application just doesn't make any sense. Looks like there is a rule or something and everyone should follow it otherwise they are wrong. Well, I don't like to think like that, I like to understand the rule and see if the rule makes any sense and then break it or live by it. That's how I am. I wanted to explain this a little better but cause English is not my main language and I don't know the words I want to use, not even in my own language so I can't translate me. I just don't know exactly how to explain this so you understand what I'm saying.

If I sounded harsh or offensive, sorry, it wasn't my intention. I'm just trying to explain my point of view.

  • 0
  Quote
It's like, look at WPF. Why did Microsoft develop it? Why did they offer all that functionality with WPF? Everyone can really customize the look of their applications with WPF easier than ever.

Just because they give you the power, doesn't mean they intend for you to use it like that.

  Quote
I think your thinking about the UI design and the whole thing about just going standard for every application just doesn't make any sense

It's not even just about the looks (They're a big deal too. But we'll ignore that for the next few sentances.) You're going to have to reimplement a relatively non-trivial thing that the user interacts with and is going to expect to behave exactly like everything else in the system. You'll have to test at various DPIs, and probably find problems that you'll have to code around, and you should probably be polling some settings from the user's "Advanced" Appearance settings, too. My point is that with something like this, it's best to just let the OS handle it. That's why we have it.

  Quote
But there are other applications that it just fits and looks good

Very, very few. I won't try to convince you anymore -- this deviates too far from the point of your topic, but I thought it'd just be a good idea to point out one of the largest annoyances with non-standard UIs: The window frame.

Edited by MioTheGreat
  • 0

If you look at the majority of a Windows applications you can see that they try to conform to the standard Windows UI. The reasons aren't just for the sake of being lazy, it's for usability. If you have two applications, which perform the same function, one looks like an eyesore (I'm not saying yours will), and then other fits in with the user's theme, which one are they likely to use. People like conformance, they like everything to fit in well (heck, look the Customisation forum to see that; they more than often produce a Winamp skin, a dock skin, etc. just to make sure everything looks the same), IMO it's human nature.

I'm not saying that you shouldn't skin your form, but I truly think that it is an unecessary evil. The basics of the Windows UI hasn't changed since Windows 95, just the vibrance and fidelity has increased, the reasons for this is because that it is easy to approach and use. Microsoft spend billions each year reasearching and developing their UIs, and thus far they haven't really gone wrong (Bob doesn't count :p).

Remember, sometimes better to be useable, than to look good.

  • 0

About implementing the functionality, I don't think that will be a problem but I'm not sure yet. If I can do what I want, if I follow and understand every little detail of the article I just found, I don't think I'll have to reimplement everything. Everything will just work as it should. I think... I'm not going to have smooth borders as I wanted but that's the price to pay. I'm also going to look more to WPF to see if it's possible/easier to implement this without any bigger problems. Like I said, this is a problem (reimplementing the functionality), I agree with you, but for now, I just don't care. I'll try to implement it and go from there, if I'm not able to produce it right, I'll do it differently...

About the looks, it's like I already said many times. There are applications and applications. My applications is not the average type of windows applications it's more like a gadget that could have been developed for Windows Sidebar or any program like that. I just didn't develop it like for a few reason: 1) I started this project long ago when these applications were not well developed. 2) I don't really like any of the existing applications that do this kind of stuff. 3) I don't want to learn how to code a gadget.

I think that Windows UI guidelines are overrated, I said this before. I like conformity and consistency through out the system but doesn't mean that every single application needs to conform with one another and the system. What if the application looks good and is usable at the same time? I prefer that...

  • 0

I'm sorry I revived such an old topic but I just found something weird that I can't understand. Maybe you guys can make any sense out of this, cause I cant...

Do you see the project attached by Menge? This project has code and pre-compiled exe. The code is basically a form without borders and with a alpha transparent (png) background image and that's it.

I took the compiled splash.exe and tried in Vista and XP (VMware). As you can see in my post #11, the background is drawn. Then I tested the same exe on the XP machine and wow, it worked, the background was fully alpha-blended. Conclusion: it worked on XP but not on Vista.

Now, I opened Menge's solution which was on VS2003 and converted it to VS2008 solution, recompiled and guess what? Both XP and Vista show the fom background instead of alpha blend it as it happened with the pre-compiled exe on XP.

What does this mean? Two questions:

1) How come it works on XP and not on Vista?

2) How come it doesn't work if I do no changes at all to the code and just recompile it?

Something's weird going on...

  • 0

maybe the conversion process changed it into a .Net 2.0/3.0 applcation, which might have different configurations for the behavior of PNGs as form backgrounds?

have you tried deleting the picture and then re-setting the picture in VS.Net 2008?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • There are too many people doing nothing and just cruising at MS because of how the previous culture was (rest and vest).
    • AMD Ryzen AM4 16-core 5900XT processor has never been priced cheaper by Sayan Sen While AMD's newest processor platform with DDR5 and PCIe 5.0 goodness is AM5, the preceding Socket AM4 continues to be a great option for gamers shopping on a lower budget. One of the most powerful AM4 desktop chips, the 16-core Ryzen 9 5900XT, is currently priced at the lowest ever at just $230 (purchase links down below). The Ryzen 7 5900XT is based on the Zen 3 architecture supports DDR4, PCIe Gen4, and offers very good performance in both gaming and productivity. While users may not expect the same level of gaming throughput or latency improvement as the 5800X3D, it is certainly possible that titles that utilize more than 16 threads will favor the 5900XT over the 5800X3D. And the 5900XT has plenty of L3 cache as well at 64 MB. So while not 3D stacked V-cache, it should still be a decent gaming chip. And all that cache as well as cores/threads will be excellent for non-gaming tasks of course. The CPU has a base clock of 3.3 GHz and boosts up to 4.8. It has a TDP of 105 watts so the available power envelope certainly helps with that. It can tolerate temperatures of up to 90 °C and there is no boxed cooler with it. So you need an aftermarket one, ideally a 280 mm or 360 mm AIO liquid cooler or an excellent air cooler. Also since this is a 16-core 105-watt chip, make sure to run it on an AM4 board that has good quality VRM and cooling with lots of power (ideally an X570 motherboard). Another consideration is that it does not have integrated graphics so you need a separate dedicated GPU for display out. Get the AMD Ryzen 9 5900XT at the links below: AMD Ryzen 9 5900XT - No Integrated Graphics Desktop CPU Processor - 100-100001581WOF: $229.99 (Amazon US) || : $279.00 (Newegg US + Corsair 32GB DDR4-3200 RAM) This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • OnlyOffice 9.0.0 by Razvan Serea OnlyOffice Desktop Editors is an open-source office suite distributed under AGPL v.3 that combines text, spreadsheet and presentation editors allowing to create, view and edit documents stored on your computer. The application does not require constant connection to the Internet and allows youto create, edit, save and export text, spreadsheet and presentation documents. It is fully compatible with Office Open XML formats: .docx, .xlsx, .pptx. One pack - five editors - multiple features Create, view and edit text documents, spreadsheets and presentations of any size and complexity. Work on documents of most popular formats: DOCX, ODT, XLSX, PDF, ODS, CSV, PPTX, ODP, etc. Deal with multiple files within one and the same window thanks to the tab-based user interface. Highest compatibility with Microsoft Office formats. Real-time collaboration within your favorite cloud Connect ONLYOFFICE Desktop Editors to the cloud platform of your choice: ONLYOFFICE, Nextcloud or ownCloud to collaborate on documents with your team – co-edit in real time, review, comment and interact using chat. Extending your editing capabilities Take the most of your editing with the collection of third-party plugins. Insert a YouTube video, add special symbols or a ClipArt object, automatically translate any word or sentence, highlight code, etc. Do even more! Create your own plugin using the API documentation and ready-to-use examples available on GitHub. OnlyOffice key features: View, edit, and collaborate on docs, sheets, slides Build fillable PDF forms and fill them in online Read and edit PDFs, export/import to/from PDF Convert docs to Markdown and HTML Turn your textbooks into e-books Generate texts with the AI helper OnlyOffice 9.0 changelog: New features All Editors Redesigned interface of the main application window Added new interface themes: Modern Light and Modern Dark Added saving of the last selected languages in spellcheck lists Added Arabic spellcheck dictionary used in sixteen dialects Added AI-powered macro generation from descriptions and VBA-to-JavaScript conversion Added the interface translation into Urdu (ur-PK, Urdu (Pakistan)) Added support for TextArt text settings inside chart labels Added support for drawing the Up/Down Bars chart elements Merged local and cloud template lists into a unified view The list of templates is now processed on the client side, not on the server The installed system languages are now displayed at the top of the text/document/dictionary list Added a contrast-reducing effect for control buttons in inactive windows Added the option to select a printer in the print preview menu The Print using the system dialog option has been added to the print preview menu The ability to configure format associations for modern Windows OS in the EXE package installation wizard has been unlocked Document Editor Added correct display of previews for paragraph numbers for RTL Improved positioning and settings of TextArt for RTL Improved drawing of borders and fill for paragraphs with RTL direction Enabled accurate cursor navigation with arrow keys based on the paragraph's text direction Added the ability to display numbers using Hindi digits Added a setting in the File menu for selecting the preferred font size: Western/Chinese for the Chinese interface language (Chinese (Simplified)) Added a Borders button to the Home toolbar to quickly set paragraph settings Added support for the MD format for reading Spreadsheet Editor Added support for displaying bidirectional text Added the ability to select external data from another spreadsheet Presentation Editor Added the ability to set the paragraph direction (Text Direction > RTL) on the toolbar and in the advanced settings Added the ability to view animations with text Added the "Preserve" option to the Slide Master context menu Forms Changed the appearance of the Signature and Image fields: the placeholder and signature icon are now always displayed Improved user experience when filling in the Signature and Image fields Added a new "type": "signature" for the Signature field, used in the process of filling out forms PDF Editor Added the ability to set RTL direction for text The Edit Text option is available in the Community Edition build Implemented a PDF form editor Added copying pages between PDF files Diagrams Release of the first version of the Diagram Viewer with the ability to open VSDX files for viewing Convert Added conversion of the XLSB format to the editor's internal format, allowing editing and saving in XLSX without preliminary conversion Download: OnlyOffice 64-bit | 273.0 MB (Open Source) Download: OnlyOffice 32-bit | 252.0 MB Download: Windows XP 64-bit | 467.0 MB Download: Windows XP 32-bit | 457.0 MB View: OnlyOffice Website | Screenshot | Release Notes Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Awesome! Can't wait to get the stable version on my Surface Pro.
  • Recent Achievements

    • Week One Done
      Wayne Robinson earned a badge
      Week One Done
    • One Month Later
      Karan Khanna earned a badge
      One Month Later
    • Week One Done
      Karan Khanna earned a badge
      Week One Done
    • First Post
      MikeK13 earned a badge
      First Post
    • Week One Done
      OHI Accounting earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      687
    2. 2
      ATLien_0
      268
    3. 3
      Michael Scrip
      204
    4. 4
      +FloatingFatMan
      172
    5. 5
      Steven P.
      145
  • Tell a friend

    Love Neowin? Tell a friend!