What's The Difference?


Active Member
Licensed User
Hi all, A question I should have asked as soon as I got into programming is what is the difference in a window and a control? E.G. is an edit field a window or a control? is a window simply a form like they are in Basic4ppc? Thanks.


Licensed User
At the lowest level everything in the Windows OS itself that you can interact with on the screen is a window. Each will be associated with a block of code called a Window Procedure (WndProc) which the OS calls passing Windows Messages. Each message comprises a number that identifies the message and two Int32 parameters called wParam and lParam. The contents of lParam and wParam depend upon the message. One of the most important messages is WM_PAINT that tells a window to draw itself.

From a higher point of view the distinction between Forms/Windows and Controls is what their WndProcs are written to do rather than how they are implemented. Forms are the top level containers that can host controls and other Forms. Controls provide the base level of user interaction accepting input and displaying results. However both are still based upon the Control class within .NET which as the documentation says "Defines the base class for controls, which are components with visual representation" so semantically, within .NET, nearly everything is a Control.