tags:

views:

267

answers:

6

Is there any difference between using vcl components in Delphi and WinApi functions to create gui application.

+4  A: 

Well, sure, VCL requires a Borland compiler. The Win32 API works for any language. The point of using a GUI class library, like VCL, is to make the effort of creating a GUI enabled program easier. Doing so using only Win32 is quite punishing.

Hans Passant
Well, there is always Freepascal/lazarus.
Marco van de Voort
+7  A: 

@Azad I think there are 2 big differences: the first is the ease of use of the VCL that enables you to drag and drop controls on a form (window), change its properties and assign events, giving you high productivity in the development of the GUI.

The other big difference is the size of the final application, if you create an application using only WINAPI calls, your final application will be smaller than using the VCL.

I recommend you see the project KOL (KOL - Key Objects Library is a set of objects to develop power (but small) 32 bit Windows GUI applications using Delphi but without VCL (or Free Pascal). It is distributed free of charge, with source code.).

alt text

RRUZ
+2  A: 

time, time and then even more time.

Marco van de Voort
Do you mean WinApi is faster?
Azad Salahli
I believe he means that VCL is much faster to learn and to use than doing everything "by hand" with WinApi.
Mason Wheeler
What Mason says. And mostly to use.
Marco van de Voort
+5  A: 

The VCL is a complete framework wrapping the Windows API and insulating the developer from the gory details, making it so much easier to develop Delphi applications.
You gain big in productivity and compatibility over Windows version changes...

François
+1. This, plus what RRUZ mentioned about the visual form designer, is the major difference. The VCL is a wrapper around WinAPI that makes it much easier to work with.
Mason Wheeler
+5  A: 

Almost all real-world Delphi applications use the VCL, and also make OCCASIONAL direct calls to the Win32 API. The VCL framework calls Win32 calls, in the end, anyways. So, you will almost always be using both.

The guy who mentioned KOL is suggesting yet another "middle" layer, because going direct is sublimely painful.

Microsoft has (in historical order), MFC, and ATL for C++, and .NET for the C#/VB.net language, as "framework" layers that live between your application and the raw Win32 API, for their MS Visual Studio products.

People who write anything more complicated than Notepad.exe going straight to the "metal" (Win32 API raw) are rare. So, it's harder, it takes longer to learn, and do everything. And in the end, it's not significantly faster or better. If you really need to be small (like you are writing a virus) maybe you might want to go Win32 native.

Warren P
"sublimely painful" +1 for understatement of the week :-)
Allen Bauer
A: 

You use WinAPI to do things that VCL is not "able" to do.

This is sort of an approach that the Visual Basic crowd got used to. You need some funny thing that the built in components and helper functions couldn't do in visual basic, you call a WinAPI call. Of course in Delphi it's easy to do most common Win32 API calls. Just add "Windows" if it's not already in your Uses clause, and call any function from Windows. For other APIs you need an API library, like the JEDI Windows API Library, to help with things like ACLs (Access control lists), or other stuff.
Warren P
Putting a bit of abstraction there might help in future portings though.
Marco van de Voort