Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API's with FB
#1
This is my first time to use this Forum and I was wondering how you would add API's in FB. I got a copy of the Apiwh.hlp doc and the Api32.hlp for online. I'm still ciphering through the files, although, any help to this subject will be sublime.

Also, I know that the mingwp site has these files yet the Api32.hlp was broken and showed 0 bites in a hex editor. So if anyone wants these files let me know; I'll send them via email. I would give the link, however, I lost it durning my search.

Again thanks for any provided help.
ut yield who will to their separation, my object in living is to unite my avocation and my vocation as my two eyes make one in sight.

-Robert Frost, 1936
Reply
#2
welcome,

ww not sure what you mean? WinAPI ? just add for example:
'$include once:'win\kernel32.bi'
'$include once:'win\user32.bi'
'$include once:'win\commctrl32.bi'
'$include once:'win\gdi32.bi'
url]http://fbide.sourceforge.net/[/url]
Reply
#3
Thanks for the welcome. I guess I'll just have to look at the help docs more. Also will look more into the Include as well. Yes, it's for WIN API's. The winapi help docs show me all the spects for sockets, audio, etc for the Windows OS. And, when I was reading about FB it said:

"FB can compile source-code files up to 2GB long

the number of symbols (variables, constants, etc) is only limited by the memory available (you can include/use for example opengl + sdl + bass + win api with your application)"


again, thanks.
ut yield who will to their separation, my object in living is to unite my avocation and my vocation as my two eyes make one in sight.

-Robert Frost, 1936
Reply
#4
Well, I've been looking around and I've seem to have no problem finding examples in c for win api's why no one seems to know what I mean is strange...again any help for using winapi in fb will be helpful.

Thankyou.


some code I found...

Code:
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
    return 0;
}
ut yield who will to their separation, my object in living is to unite my avocation and my vocation as my two eyes make one in sight.

-Robert Frost, 1936
Reply
#5
windows.h is a header that really just a grouping for more headers like

kernel32
user32
commctrl32
gdi32

since fb doesn't have a grouping .bi because everything still so new and no one's gotten around to doing that you have to include the .bi your self.
Reply
#6
Ok I get the idea on the including part. Now what about the coding part. The code example I show uses c/c++, so will this be the same way done with FB or is there a certain way to do it after you include each .bi file into your code?

after each .bi
code like this in FB?

Code:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
    return 0;
}

Again thanks for the help. The more I learn and understand, the more I will want to work with this compiler.
ut yield who will to their separation, my object in living is to unite my avocation and my vocation as my two eyes make one in sight.

-Robert Frost, 1936
Reply
#7
If you look up messagebox (google/msdn) then you will see that it is from the user32.dll in windows.

In freebasic you would just:

'$include: "user32.bi"

to get the apropriate header file instead of just a blanket include like windows.

The messagebox call is as follows:

MessageBox 0, "Hello!", "Note", MB_OK

There is no need for a winmain function in freebasic as the program entry is the main body of your code, so a valid equivalent of your example would be:

Code:
'$Include: "win/user32.bi"
messagebox 0, "Hello", "Note", MB_OK

This will compile and give the same results as the C example.
ature has its way of warning a person away from danger: The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Reply
#8
This is helpful information. I do have one last question a bit off the subject.

Why when I create an exe file then click on it from windows a dos like box opens up with it. I tried the message box and got this and wonder if this is something in plans to be fix or if there is something you have to add in a line of code to provent this.

I have also tested this on win98 and winXP getting the same result.

One last glitchy thing which is some what irking. When I run an exe from the dos prompt I would get a white block on the screen; it is controled with the mouse. Look just like the one you would see in qbasic. This seem to happen when I use the inkey$ to access keys on my keyboard. I haven't seen this happen when I use other statements such as PRINT, INPUT, CASE, READ DATA etc.

Again Thanks to everyone for the help.
ut yield who will to their separation, my object in living is to unite my avocation and my vocation as my two eyes make one in sight.

-Robert Frost, 1936
Reply
#9
Quote:Why when I create an exe file then click on it from windows a dos like box opens up with it.

Code:
fbc -s gui yourfile.bas

The fbc.exe has command line switches to control the subsystem linked into the final exe. The default is "-s console" which will open a windows console screen before the program runs.

If you are using only api/gui and no print statements then add "-s gui" to your command when compiling your source.
ature has its way of warning a person away from danger: The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Reply
#10
just compile it with a '-s gui' switch

http://fbtk.qbtk.com/phpBB2/qa.php
url]http://fbide.sourceforge.net/[/url]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)