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
Printable View
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
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
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.)
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