Click to See Complete Forum and Search --> : VB build-in VS API


vchapran
April 2nd, 2001, 12:19 PM
Is there any advantages to use API function, if VB has build-in function with the same features. For example MessageBox API and VB MsgBox.

Vlad

Clearcode
April 2nd, 2001, 12:24 PM
The advantages are that you usually get more flexibility - for example the API call MessageBox allows you to specify the handle of the owner window. Thus, you can pass HWND_DESKTOP if your app has not loaded its main form yet and it won't cause problems.

The performance difference (in most cases) is negligible.

HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com

shree
April 2nd, 2001, 12:27 PM
In my opinion, what VB does is just wrap up Windows functions in a more usable form, so it is never more expensive to use an API function (you would call the Windows function, instead of VB doing it) and you get more flexibility (usability and power are generally inversely proportional) but at the cost of stability. Using VB functions only gives you a certain degree of stability that you lose when you resort to APIs(you have to remember all the chores of freeing up things, and in the correct order etc.)

vchapran
April 2nd, 2001, 12:32 PM
Thank you, guys. Actually my question was just about performance and something else - not flexibility. I know, that many things either cannot be done in VB (I use API), or can be, but with restrictions (I use API again).

Vlad