3
votes

I would like to provide highly styled form elements for a client within an MFC application.

I am coming to the conclusion that 'Web-2.0'-style widgets are simply not possible in the MFC universe without major custom painting/programming work.

I include screenshots to compare:

  • A desired 'Web 2.0'-style edit widget, and
  • the 'best' edit widgets straightforwardly available in the MFC universe.

Example A: Here is a screenshot of a (randomly chosen) nicely styled edit widget that is easily available and trivial to use in the web programming world with HTML/CSS:

Web-2.0 style widgets are easy in HTML!

Example B: In contrast, here is a screenshot taken from one of BCGSoft's MFC library's example applications. This very example application is titled "Edit Box Demo", and provides - it seems - the best edit widgets available in the MFC universe:

The best MFC edit widgets don't cut it

You can see that there is a 'generation of difference' between easily-available HTML edit widgets, and the seemingly best-available MFC/C++ widgets for Windows desktop applications.

My question is therefore straightforward: How is it possible to style a CEdit control with rounded corners and shadow in MFC?

1
You have to make your own ownerdraw controls to get those rounded edges. Or use CDHtmlDialog. It won't necessarily look good in Windows 8 & 10 which are big on square edges.Barmak Shemirani

1 Answers

1
votes

Just pointing you to Example B you used

Using CBCGPEdit it should be simple and straight forward to overwrite OnNcPaint.

But! Usually you can instruct the BCG to use a visual manager and in this case the visual manager will be responsible to draw the controls frame. And the visual manager will use round corners if it is designed to do so... I know even no visual manager that uses round corners ;) (CBCGPVisualManager::OnDrawControlBorder)

But feel free to write your own.