FF_Functions for controls

Started by Ivan Iraola, November 06, 2009, 10:53:39 AM

Previous topic - Next topic

Haakon Birkeland

I think I might still have have two of the books laying around if I look for the first one in the basement. Actually I recall the first API I used from it being a function to search the content of a listbox as I found the limited VB-way of doing it in a longer list to yield undesirable visual artifacts.

The helpfile from the book have been a companion to POFFs for years, but I see myself only following the "next great master" â€" Jose in the future. He is like Paul (and some few others) by no doubt one of the "faces" of PB that unselfishly serves the community with his wast knowledge.
Haakon 8o)

John Montenigro

Quote from: TechSupport on November 07, 2009, 05:29:59 PM
What exactly do you need help with? I can't explain how to use every wrapper available. That would be impossible. There are hundreds and hundreds of functions and wrappers.
I understand and agree...but how about something at a more general, or conceptual level?

Over the years (after having finally made the transition away from DOS), I have been learning the Win API.

So maybe a couple of comparisions would be helpful -
- whereas an API call is like this, Jose's calls are like that...
- here's how you've been using the Windows API, and here's how you use Jose's functions...
- if you did stuff like X with the API, you need to do things like Y with Jose's...

I promise to go back to Jose's site and re-read. It's been a long time since I tried, but I'll give it another go. However, I know it would be helpful if I had a better context by which to understand what makes them different from API functions.

In that regard, I hope someone can offer some easy-to-understand help.

Thanks,
-John

José Roca

Quote
So maybe a couple of comparisions would be helpful -
- whereas an API call is like this, Jose's calls are like that...
- here's how you've been using the Windows API, and here's how you use Jose's functions...
- if you did stuff like X with the API, you need to do things like Y with Jose's...

I'm afraid we will need some examples to understand what you mean. Otherwise, how on Earth can we know how have you been using the API?

Haakon Birkeland

It's not like the wrappers in basic are a reinvention of the wheel and totally different to the original code, but rather translated and made ready for use with PowerBASIC's syntax and variable types. It is still the same library that is called and "does the math".

Use Jose's wrappers in conjunction with the reference section on his pages and you'll find using basic API-calls/functions easier than if you have to read and understand the C code that you normally find on the net.

Compare the somewhat cryptic syntax below ...


int ListBox_FindString(
HWND hwndCtl,
int indexStart,
LPCTSTR lpszFind
);


... with this ...


FUNCTION Listbox_FindString ( _
BYVAL hListBox AS DWORD, _
BYVAL indexStart AS DWORD, _
BYVAL searchString AS STRING _
) AS LONG


Its not only easier to understand for those lacking C skills, but it is ready for use when the include is â€" included. Constants one would need for arguments are defined and the declaration of the function exported by the supporting library is pre-declared for you.

Copy the code, fill in the blanks (substitute the arguments with real life values or reference the variables holding them) and run the show ...
Haakon 8o)

John Heathcote

Paul,

QuoteWith that many functions it always amazes me why some people have such a resistance to wanting to learn aspects of the Windows API. There is so much power available at our fingertips but yet many people cringe whenever the "API" term is used. For just about anything you need to do there exists a set of functions to accomplish the task. Calling a WinAPI function is just as easy as calling a native PB function... actually, most of the time it can be even easier!  :)

To personally put this into context, it isn't so much resisting the API learning curve, it is more a matter of where to start.  As Jose stated:

QuoteAround 18,000. And you have to add the interface declarations, with thousands of methods and properties (more than 80,000).

...is more than enough to give me the API heebie jeebies.  :D

I can't tell you how many times I've been frustrated using the API, wanting to do something apparently simple and specific with the API, so I gather my equates, function calls etc., insert them in my code only to discover they don't work.  No GPF, but no real reason why things didn't work, GetLastError is of no help either.  So I ask a question in the forums about why XYZ didn't work and the response is, "Oh, you have to do ABC first."  Huh?  Where is that mentioned in the API?

POFFS is a great help as an aid to solve problems, but there are pitfalls too, particularly when POFFS code fails to compile.  So now what do you do?  Spend time getting POFFS examples to work or do something else?  This is the real world for me, and if I didn't love pain so much I would probably give up programming.   ;D

Again, I can't tell you how many days, even weeks I've wasted trying to get something to work, so for me productivity (or the lack of it) is a big factor in my decision to use API stuff.  The Win32 Programmers Reference is a help too, but it appears to be somewhat outdated.  The Platform Development Kit would be a wonderful thing to use, but it doesn't work on my system (I think I may be missing an upgrade, or two).  So essentially I have the WIN32API.inc file, or Jose's include files to look at.

QuotePB programmers need to expand their boundaries away from just DDT or some EZ this or EZ that. Everything is available to us and it is free for the taking. Luckily, FireFly users seem more willing to explore the WinAPI.

I don't disagree, but again, where do you start?  It would be nice if all PB users could gain the experience that you, Jose, and all of the other great PB gurus have gathered over the years so we would know where to start, but that isn't likely to happen as we all have differing programming goals.  Although I do benefit from your programming experiences (as well as Jose's and the host of other power users) I can honestly say I will probably never come close to achieving power user status.  I accept that, but I also think you have to consider that some of us don't want to get into that much detail with the API, we simply want our efforts to work as we have planned. 

An explanation of why things work is always nice and I try to include this info in my code, but I'm not disappointed if such an explanation is not forthcoming.  It works!

QuoteHopefully I can help by creating some tutorials that at least highlight some of the most common API functions (e.g. GetClientRect, GetWindowRect, SetWindowPos, SetFocus, ShowWindow, EnableWindow, etc...).

Not just examples, but practical examples that do some real world work.  A sort of "How do I" facility would be most welcome.

Just one old geezer's opinion.

JR