Liberty BASIC Community Forum
« API's for Beginners »

Welcome Guest. Please Login or Register.
Dec 12th, 2017, 08:02am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 sticky  Author  Topic: API's for Beginners  (Read 1295 times)
Janet
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 4111
xx API's for Beginners
« Thread started on: Mar 29th, 2007, 08:53am »

Sooner or later, LB programmers are going to delve into the land of API's and DLL's. Some coders jump right in without any understanding whatsoever - copying sample CallDLL's here and there and just plugging in values to see what works and what doesn't. This seems to be a wildly popular, and wildly unsuccessful, approach to learning API's.

Coders are often referred to the MSDN Library. The MSDN Library is a great, comprehensive resource, but it assumes you have a working knowledge of API's in general.

What is that working knowledge? A working knowledge means you can answer questions like

* What does it mean to pass a value to the dll?
* What is a Windows constant?
* What is a struct?
* How do you create a struct?
* What is the difference between passing as long and passing as ulong?
* How is a string variable passed into the dll?
* When isn't the handle alone enough information?
* What is a Handle Instance?
* What is a Device Context?
* and so on and so on and so on.

You get the idea.

In an effort to bridge this knowledge gap, Alyce (who else? wink ) has begun a new series for the Liberty BASIC Programmer's Encyclopedia (LBPE) titled The ABC's of API's. Some of you may have already read the first two installments. The third installment is now ready for viewing as well.

Programming with API's can be a lot of fun, but it can also be quite frustrating. I am so psyched about this series and I think you will be, too. So, run over to Liberty BASIC Programmer's Encyclopedia (LBPE) and start reading The ABC's of API's. You'll be a better programmer for it!

As always . . .

Thanks, Alyce! You ARE the best!! grin
User IP Logged

Windows 7 Professional, SP1, 64 bit Intel Core i5-4200U CPU @ 1.60 GHz 2.30 GHz 6.00 GB

"I am very busy finding out what people mean by what they say." -
mack
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 147
xx Re: API's for Beginners
« Reply #1 on: Jun 27th, 2007, 06:38am »

I've worked my way through the first part of this tutorial and I have to say it has made API's a lot clearer. Looking forward to continuing it.

Thanks Alyce. Well written.

Robert
User IP Logged

jcherepy
New Member
Image


member is offline

Avatar




PM


Posts: 21
xx Re: API's for Beginners
« Reply #2 on: Jul 7th, 2007, 9:42pm »

Thanks to the tutorial I now understand API/DLL, but still do not understand how one goes about finding out what DLL you need. Also, are the functions in various DLL's documented somewhere?

Thanks,

Bill


User IP Logged

Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5300
xx Re: API's for Beginners
« Reply #3 on: Jul 8th, 2007, 03:20am »

The API functions shipping with Windows are documented at the MSDN Library.

The offline version is the Windows Server 2003 R2 Platform SDK, a ~300MB CD ISO-image download.

Which DLL includes the API function is listed at the end of each article.

Any other third party DLL is shipping with its own documentation.
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
benjamin805
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 419
xx Re: API's for Beginners
« Reply #4 on: Jul 8th, 2007, 2:08pm »

hello,

back in the day when i worked more with dll calls I had asked a question on how to pass an array of values to a DLL. Someone back then had posted an example how to do this. Would it be possible to have a new example added in a tutorial? since I have lost the old example and the zip file was removed from the site.

User IP Logged

Alyce Watson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Female
Posts: 14917
xx Re: API's for Beginners
« Reply #5 on: Jul 8th, 2007, 2:21pm »

Thanks for the suggestion, Ben. That subject wouldn't belong in a beginner's series, but it could certainly be added to LBPE. Until that happens, check out Dennis's article here:

http://babek.leland-enterprises.com/libertybasicfiles/lbnews/nl99/3.htm
User IP Logged

Alyce
Liberty BASIC Workshop - a complete IDE for Liberty BASIC


Alyce's Restaurant
for Liberty BASIC code, tools and references
mackrackit
Team Liberty BASIC


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 61
xx Re: API's for Beginners
« Reply #6 on: Jul 17th, 2007, 09:26am »

Just want to say thank you Alyce. I have been struggling with this for some time now. Decided to look on the forum and saw this thread.

Guess I need to visit more often. undecided
User IP Logged

horizon
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 9
xx Re: API's for Beginners
« Reply #7 on: May 8th, 2008, 2:45pm »

I have heard the term API for years and never quite understood the concept. That first tutorial about the basics of API was very instructive and put me in a position to try using an API. I am continuing with the lessons. Thanks
User IP Logged

Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5300
xx Re: API's for Beginners
« Reply #8 on: Oct 16th, 2011, 1:32pm »

Another useful resource for API beginners are the conversion tables by Brent D. Thorn at Converting C types to LB types.

If you like to start using the Windows API make sure to keep them at hand wink
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
datwill
Guest
xx Re: API's for Beginners
« Reply #9 on: Jan 21st, 2015, 08:50am »

MSDN is rubbish! Not only does it have code which is in C++ and not LB but it just tells me messages and not how to use them all properly (SendMessage is used often I know), all I need is a simple, dll library which tells me about how to send commands and create controls! MSDN is OK as a revision tool, but it's rubbish to find out how to do anything with it, I'VE SEARCHED NUMEROUS TIMES BUT CANNOT FIND ANYTHING! Seriously don't know how you guys find anything about LB, I cannot find anything except LBE and this, which are the only things of any use about LB not including the website! I'm actually getting frustrated with this.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5585
xx Re: API's for Beginners
« Reply #10 on: Jan 21st, 2015, 2:59pm »

Well msdn isn't rubbish you only think it is rubbish because it isn't meeting your needs. Given it is the font of all knowledge about API it is kinda foolish to diss it.

I would say that if you are a beginner you shouldn't be messing with APIs. Try seeing what you can do with native Liberty BASIC first.

So in the beginners board tell us what you are trying to achieve and folks may code sample code to show you the wY forwards.
User IP Logged

Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5300
xx Re: API's for Beginners
« Reply #11 on: Jan 21st, 2015, 5:12pm »

MSDN is the official resource for all development languages using the Windows API, there is none for each and every language that can use the Windows API.

MSDN uses C++, because Microsoft thinks this is the most common language, so all other languages use their own sites with explanations about how to translate from C++ to that language.

You are free to translate each and every page of MSDN to LB code and make sure to tell us about the translation in a million years wink
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2289
xx Re: API's for Beginners
« Reply #12 on: Jan 21st, 2015, 9:35pm »

I agree with Rod and Stefan.


MSDN has code samples in the "official" languages for Windows; that is, the languages and compilers Microsoft writes themselves.


The reason why things seem so complicated is because, well, they are. The windowing system used in Windows is an extremely complex beast, but that complexity is what gives it its versatility.

Many MSDN pages are written on the assumption that you understand how Windows(all things on the screen are windows; even controls are made using CreateWindow()), Classes, Messages(the message pump in particular), etc. all work. Microsoft does give fairly good lessons in how all those work in MSDN; but they're kept in their own section, not used in every page(that would balloon the entire size of MSDN immensely).


Liberty BASIC does an amazing job of abstracting away all that complexity, but that abstraction does come at a cost: the loss of some of the versatility. You get a simplified set of commands, that are far easier to use, and LB does all the background work of translating that to Win32.

Because of that abstraction, not everything possible in Win32 is possible in native LB; that's why Liberty BASIC gives you the chance to take control yourself by letting you interface with the Windows API directly.

However, doing that means you now have to play by the rules of Win32; you don't have LB to work as a go-between anymore. You get the versatility back, but you get the complexity to go with it.


Side note: That's not to say Win32 isn't overly complicated, at times; even Microsoft themselves agree with that; which is why stuff like the .NET Framework provide an abstraction made by Microsoft themselves to organize the features of Win32 better. It tends to be easier to use than raw Win32; but if you're an outside program, needing to interface with Windows itself, the API is all you have.

Part of the reason of the complexity of Win32 is the fact that it is built on the same structure that started with Windows 1, in the mid 1980's. (It's not the same code; the Windows NT line was a re-write that came along later; but the Win32 interface has largely remained the same.) Microsoft tries extremely hard to keep compatibility with old code and programs, which means that a lot of the older ways of thinking and structuring programs still exist in Win32 code.

This is stuff that can't be changed without breaking all current Windows applications, which Microsoft does not want to do.

They can't always get it right, but their commitment to compatibility is why you can take a (properly written) binary compiled 30+ years ago, and still have it run on a modern Windows system today.
« Last Edit: Jan 21st, 2015, 9:36pm by Chris Iverson » User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
datwill
Guest
xx Re: API's for Beginners
« Reply #13 on: Jan 22nd, 2015, 01:31am »

No, it is not meeting my needs for certain. I kinda wonna learn about Common Controls because I know the basics of DLLs now (thanks to the api abc series) and would like to LEARN (not REVISE) COMMON CONTROL DLL topics. In LBE, the only common control topic there seems to be is trapping a double-click in a listview. I know, it is kinda foolish to say that I didn't like it...
I agree with complexity meaning that you can control things more (in an odd way, I'm kinda thankful that this is complex), and I do know (from handling with listviews ext. from LBW) that you need some #comctl32 DLL, and some User32 ones too, one of them being a SendMessage to create a control, but I also kinda assumed that making other controls would be different... Now I'm guessing they are not different apart from different function names used, pretty much...
User IP Logged

Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2289
xx Re: API's for Beginners
« Reply #14 on: Jan 22nd, 2015, 10:03am »

If you're using the API, then the way of making it is actually pretty much always identical.

You need to know the specifics of the window you're making(the control class, etc), but the way of doing so is always hte same.


CreateWindow() is the function used to create controls(remember, all controls are windows).

Interaction with windows is handled using messages. EVERYTHING you do with a window(control, etc) boils down to message handling.

The messages can go both ways, too; the window sends YOU a message when it updates something(like it got a click), and you send the window a message when you want to change something(for example, Progress Bars, to set their limit or increment them, you use specific messages).

Actually, Progress Bars aren't a bad example. Take a look:

http://basic.wikispaces.com/ProgressBar


In particular, take a look at how all the calls boil down to CreateWindow() to make it(actually CreateWindowEx(), but still), or SendMessage().
« Last Edit: Jan 22nd, 2015, 10:17am by Chris Iverson » User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls