When looking at Delphi source code, I often see messages declarations from the Windows API, such as CN_NOTIFY
and WM_NOTIFY
. I would like to know the differences between them and when they should be used?
Asked
Active
Viewed 667 times
9

Felipe Morais
- 155
- 2
- 12
-
6CN_... and CM_... messages are proprietary VCL messages. You need to study VCL source code for any specific message, there's no general guide. – Sertac Akyuz Jul 29 '18 at 18:39
-
7The difference is WM stands for "Window Message", CN stands for "Control Notification", CM stands for "Control Message". – Sertac Akyuz Jul 29 '18 at 18:44
-
@IInspectable: CN-prefixed messages won't be in Petzold's book. They are Delphi-specific VCL internal messages. – Rudy Velthuis Jul 30 '18 at 05:47
-
@RudyVelthuis: I'm fairly sure the question changed in between me making that suggesting and now. It used to ask for different message types (commands and notifications). The difference between those is explained in Petzold's book. It's a fundamental distinction, that's relevant regardless of the GUI framework in use. – IInspectable Jul 30 '18 at 06:05
-
@IInspectable: the question was not edited, AFAICT. And CN_ messages are really Delphi specific, as I said, so yes, they are defined in the framework. They are very likely not found in Petzold's book. – Rudy Velthuis Jul 30 '18 at 07:08
1 Answers
12
WM
messages are used by the Win32 API, and end user code.
CM
and CN
messages are used internally by the VCL.
When the VCL processes certain WM
notifications from the Win32 API, like WM_COMMAND
and WM_NOTIFY
, which are sent from a child control to its parent window, the VCL reflects them as CN
messages (CN_COMMAND
and CN_NOTIFY
) back to the child that sent them. This allows VCL controls to handle their own notifications.

Remy Lebeau
- 555,201
- 31
- 458
- 770