Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
882 views
in Technique[技术] by (71.8m points)

delphi - Documentation and API Samples for drawing on Windows Aero Glass (DWM, GDI, GDI+) for all Win32 programmers

I am looking for good resources for learning to use the Win32/GDI APIs or whatever supercedes it to draw and paint directly using the Win32 API to a glass form.

While I am using Delphi, I tagged this as Delphi or Visual C++. Any code samples and articles that you can find would be appreciated. MSDN articles do not seem to be written about this.

As a goal, let's imagine you want to either: (a) Reproduce what Google Chrome does (tabs as part of the glass frame) (b) Reproduce what MS Office 2010 does (save button on the glass frame, referred to in MFC for VS 2010, as "Quick Access Toolbar" (see picture below).

I am not using MFC, but if examining the MFC sources would be a good source of information, I am curious to know where in the MFC sources or BCG original sources (I have both) are implemented the Quick Access Toolbar rendering/painting code.

alt text

Update: A related neato link from one of the answers below shows the NC (nonclient) Paint message, and how to handle it when painting on a glass frame, and an MSDN article about it here.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is a subset of my "Glass" bookmarks folder, the result of a lot of research / searching on this topic. I've found all of these useful for learning about glass and solving various problems drawing on it. Most of these include Delphi code, but I've noted where it's for another language.

Plain Glass links

  • Using translucent windows with Delphi: good introduction (from the very basics) for using Glass in Delphi forms
  • Custom drawing on glass: covers how to draw a bitmap or other image on a glass area of the window. Covers alpha channels etc too, good overview
  • Using glass in a VC++ project: covers turning glass on, drawing text, handling notifications etc - a good general introduction to how it works. A lot of the underlying details are handled by the VCL (eg the GlassFrame property and TForm internals look after a lot of this) but it's very useful to understand the basics of how it's implemented at an API level anyway
  • How to draw on the non-client area: this shows how to draw something like Office's toolbar in the title bar. .Net code, but translatable
  • Setting up a custom title bar: very detailed article about non-client-area drawing (in Delphi, so Delphi code). Followed up by part 2, which demonstrates completely taking over the entire window and mimicking the standard title bar yourself. These two articles will let you mimic Office and Chrome as you requested in the question
  • How to set up various VCL controls to work best on a glass area: the VCL does not support glass very well. You'll often get artifacts, or controls simply not drawing properly at all, no matter what you do to try and solve it. This article lists the basic VCL visual components (labels, buttons, progress bars, etc) and what to set up for each so they draw perfectly, or at least 'as well as possible' when they're placed on a glass area

Advanced, or tangentially related:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...