New member here, and I've some doubts *

New to FreeBASIC? Post your questions here.
AMSA
Posts: 9
Joined: Jan 27, 2011 20:35

Postby AMSA » Jan 31, 2011 13:40

Hello there again guys.

Well, now I'm more confused.

What do I need to make an Windows application? When I mean Windows Application is something similiar to what can be done with Visual Basic.

Some of you mentioned the GTK+, but for what is that for? Is a IDE? Allows me to do that GUI internface? Or the FreeBASIC editor that you guys suggested me backward is better?

Now I'm really confused.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Postby MichaelW » Jan 31, 2011 13:56

Could you give us a rough description of the user interface you had in mind?
AMSA
Posts: 9
Joined: Jan 27, 2011 20:35

Postby AMSA » Jan 31, 2011 15:20

Hi there Michael,

First of all, like I said in my first post, I'm looking foward to learn this language first, before starting to do some stuffs in Visual Basic, because I don't know anything about Visual Basic, and for what I'm thinking I cannot start doing some applications in Visual Basic without knowing the Basic language.

So I thought that this could be a good oportunity to do some applications, first with DOS prompt and then some simply GUI with FreeBASIC and then start with Visual Basic.

My real goal is to use programming to do some interesting apps that can communicate to the real world, like reading multimeter through RS232 or GPIB, programming PICs and use them to control stuffs and make some interesting projects, and so on.

My goal is to make a kind datalogger for Fluke 45. I've a piece of code that can read the multimeter readings and display them in to the prompt. I'd like to explore a little bit more this code and extend the applications to other functions of the multimeter. After that I wnat to make an application for windows that can display the reading in a window, and save that value in to an excel sheet and at same time display those results in to the window (with all that crap, file, about, help, some options, and so on)

Now, with that question about the GKT, can someone explain to me? I see lot's of options and some tricks that is needed to make for programming with this languagem all the IDE :S

Best Regards,
Charles
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Jan 31, 2011 15:29

Have you opened any of the examples that come with FreeBASIC?

Take a look at the examples here...

C:\FreeBASIC\examples\Windows\gui

They will show the basics of creating GUIs using the Windows API.

Here is the source of the hello.bas example...

Code: Select all



#include once "windows.bi"

declare function        WinMain     ( byval hInstance as HINSTANCE, _
                                      byval hPrevInstance as HINSTANCE, _
                                      byval szCmdLine as string, _
                                      byval iCmdShow as integer ) as integer
                                 
                                 
   end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )

'':::::
function WndProc ( byval hWnd as HWND, _
                   byval wMsg as UINT, _
                   byval wParam as WPARAM, _
                   byval lParam as LPARAM ) as LRESULT
   
    function = 0
   
    select case( wMsg )
        case WM_CREATE           
            exit function

        case WM_PAINT
          dim rct as RECT
          dim pnt as PAINTSTRUCT
          dim hDC as HDC
         
            hDC = BeginPaint( hWnd, @pnt )
            GetClientRect( hWnd, @rct )
           
            DrawText( hDC, _
                    "Hello, World!", _
                    -1, _
                      @rct, _
                      DT_SINGLELINE or DT_CENTER or DT_VCENTER )
           
            EndPaint( hWnd, @pnt )
           
            exit function           
       
      case WM_KEYDOWN
         if( lobyte( wParam ) = 27 ) then
            PostMessage( hWnd, WM_CLOSE, 0, 0 )
         end if

       case WM_DESTROY
            PostQuitMessage( 0 )
            exit function
    end select
   
    function = DefWindowProc( hWnd, wMsg, wParam, lParam )   
   
end function

'':::::
function WinMain ( byval hInstance as HINSTANCE, _
                   byval hPrevInstance as HINSTANCE, _
                   byval szCmdLine as string, _
                   byval iCmdShow as integer ) as integer   
     
    dim wMsg as MSG
    dim wcls as WNDCLASS     
    dim hWnd as HWND
     
    function = 0
     
    with wcls
       .style         = CS_HREDRAW or CS_VREDRAW
       .lpfnWndProc   = @WndProc
       .cbClsExtra    = 0
       .cbWndExtra    = 0
       .hInstance     = hInstance
       .hIcon         = LoadIcon( NULL, IDI_APPLICATION )
       .hCursor       = LoadCursor( NULL, IDC_ARROW )
       .hbrBackground = GetStockObject( WHITE_BRUSH )
       .lpszMenuName  = NULL
       .lpszClassName = @"HelloWin"
    end with
         
    if( RegisterClass( @wcls ) = FALSE ) then
       MessageBox( null, "Failed to register wcls", "Error", MB_ICONERROR )
       exit function
    end if
   
    hWnd = CreateWindowEx( 0, _
                       @"HelloWin", _
                           "The Hello Program", _
                           WS_OVERLAPPEDWINDOW, _
                           CW_USEDEFAULT, _
                           CW_USEDEFAULT, _
                           CW_USEDEFAULT, _
                           CW_USEDEFAULT, _
                           NULL, _
                           NULL, _
                           hInstance, _
                           NULL )
                         

    ShowWindow( hWnd, iCmdShow )
    UpdateWindow( hWnd )
     
    while( GetMessage( @wMsg, NULL, 0, 0 ) <> FALSE )   
        TranslateMessage( @wMsg )
        DispatchMessage( @wMsg )
    wend
   
    function = wMsg.wParam

end function


-Vince
TJF
Posts: 3609
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Postby TJF » Jan 31, 2011 17:09

Do you realy want to learn FB and than fall back to VB?

AMSA wrote:Some of you mentioned the GTK+, but for what is that for? Is a IDE? Allows me to do that GUI internface?

AMSA wrote:Now, with that question about the GKT, can someone explain to me?

When you see underlined words in posts at this forum like this (quoted from my last post)

GTK+

it's in most cases a link. Did you open and read the link? It may explain your questions.

You can find old-fashioned GTK examples at .../FreeBASIC/examples/libraries/Gtk. I prefer using RAD technologies by designing my GUIs with the Glade3-GUI-designer.
BasicCoder2
Posts: 3678
Joined: Jan 01, 2009 7:03
Location: Australia

Postby BasicCoder2 » Jan 31, 2011 18:13

AMSA wrote:First of all, like I said in my first post, I'm looking foward to learn this language first, before starting to do some stuffs in Visual Basic, because I don't know anything about Visual Basic, and for what I'm thinking I cannot start doing some applications in Visual Basic without knowing the Basic language.


If you want to program in Visual Basic I suggest you start there as you will only have to unlearn the way FreeBasic does things. You can then do what you want using an ActiveX control.

JohnC
AMSA
Posts: 9
Joined: Jan 27, 2011 20:35

Postby AMSA » Jan 31, 2011 21:58

Hi guys.

I know that the underlined means that is a link, and I've clicked all the links that you guys have posted here, but at some time I get lost.

TJF, that GUI that you have posted here seens to be very user friendly. Can we program in Basic and then use the FreeBASIC compiler? Is that what you do?

About the Visual Basic. Visual Basic isn't more recent that FreeBASIC? Doesn't use the same language? Basic? Which diferences exists between them? I said that I rather prefer to study this language first, doing some stuffs in the DOS prompt and than move toward the Visual part, and that Visual part would be in Visual Basic. But now that I see that exists too a "visual" part in FreeBASIC, i thought I could do some things in Visual FreeBASIC. Do you guys understand me?

The RAD stuff that TJF posted isn't the same as Visual Basic? In Visual Basic there is too the possibility to make Win32 API right? And now I see that in FreeBASIC we can do that too. (Like in Visual C++, C#, etc) But, like that RAD technology using Glade3 is the same like Visual Basic, or not? Because what I like in this is the Drag and Drop thing, and them program the buttons, scrolls, etc.

I don't want to learn Win32 API, that is too much for me and confusing. I prefer that RAD thing.

I'd like to join the fact that FreeBASIC is a popular and a easy popular language to learn with doing some Windows applications, or widgets or whatever is called (and when I say that, I mean that windows applications like drag and drop thing).

Sorry all that questions =( I've been always languages in console "mode".

Best regards,
Charles
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Jan 31, 2011 22:06

The problem forum members are having answering your questions are in part the fact that Visual BASIC and FreeBASIC are very (VERY) different programming paradigms. Visual BASIC hides the real code of what is actually going on whereas FreeBASIC shows all the code behind the magic.

That being said, FreeBASIC programmers prefer to have that low-level of control versus the hand-holding that Visual BASIC offers because of the level of control and faster execution speeds, plus other benefits. Unfortunately this does mean GUI programs are more complicated in FreeBASIC, but many FB programmers think the pros outweigh the cons.

If you are more interested in RAD, I would suggest either VB.NET Express or RealBASIC.

-Vince
AMSA
Posts: 9
Joined: Jan 27, 2011 20:35

Postby AMSA » Jan 31, 2011 22:43

And what about Glade3-GUI-designer that TJF mentioned?

In which language is programmed?

Okay, I understood what you mean the paradigms that exists between Visual Basic and FreeBASIC. What you mean is, for example, making a simply applications, in FreeBASIC you can do more optimization or something like that.

Ok. I see that I'm in the wrong forum. I just thought that, because I saw a piece of code that I've, written in BASIC A, I though it would be a good start to make this applications of getting the readings from the multimeter Fluke 45.

But I just don't understand. There are thousands of things and we get lost so easly. Whatever.
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Jan 31, 2011 23:47

AMSA wrote:And what about Glade3-GUI-designer that TJF mentioned?
In which language is programmed?


That is not the point. Designing the GUI is not what I am talking about. It is the actual code that creates the buttons and the code that processes the events when the user clicks something.

Okay, I understood what you mean the paradigms that exists between Visual Basic and FreeBASIC. What you mean is, for example, making a simply applications, in FreeBASIC you can do more optimization or something like that.


It is more than that. VB supports many technologies like ActiveX/COM that allow you to easily plug in functionality, like DirectX, SQL, or RS-232 functionality. FB does not support those but you can duplicate the functionality by writing the actual code that does the same thing.


Ok. I see that I'm in the wrong forum. I just thought that, because I saw a piece of code that I've, written in BASIC A, I though it would be a good start to make this applications of getting the readings from the multimeter Fluke 45.


BASICA is closer to FB as far as GUI capability is concerned.

But I just don't understand. There are thousands of things and we get lost so easly. Whatever.


You don't need to understand an entire language to start a project. You learn by doing, and learning each thing as your project requires it. Get your program working in text mode, then adding a GUI is just icing on the cake.

-Vince
TJF
Posts: 3609
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Postby TJF » Feb 01, 2011 8:18

vdecampo wrote:
AMSA wrote:And what about Glade3-GUI-designer that TJF mentioned?
In which language is programmed?


That is not the point. Designing the GUI is not what I am talking about. It is the actual code that creates the buttons and the code that processes the events when the user clicks something.

Vince did code his personal GUI (KwikGUI). I use existing toolkits. GTK and Glade3 are written in C, but they are used in other languages too. Ie they are used in Gimp, Incscape, Gnome or Firefox.

AMSA wrote:TJF, that GUI that you have posted here seens to be very user friendly. Can we program in Basic and then use the FreeBASIC compiler? Is that what you do?

AMSA wrote:Because what I like in this is the Drag and Drop thing, and them program the buttons, scrolls, etc.

Yes, I use these tools for coding FB apps with GUI for win and LINUX. (BTW: DND isn't easy to code.)

vdecampo wrote:
AMSA wrote:Okay, I understood what you mean the paradigms that exists between Visual Basic and FreeBASIC. What you mean is, for example, making a simply applications, in FreeBASIC you can do more optimization or something like that.


It is more than that. VB supports many technologies like ActiveX/COM that allow you to easily plug in functionality, like DirectX, SQL, or RS-232 functionality. FB does not support those but you can duplicate the functionality by writing the actual code that does the same thing.


There are replacements for FB: instead of DirectX use OpenGL or cairo for hardware accelleration, SQL bindings are avialabe for FB, ...

You need not write all the actual code by yourself. But you have to choose matching tools and you have to care about the interfaces to make them run together. At the beginning, it's a little more work. But when you start to finetune your code, you have more control and you can realise advanced features.

vdecampo wrote:
AMSA wrote:But I just don't understand. There are thousands of things and we get lost so easly. Whatever.


You don't need to understand an entire language to start a project. You learn by doing, and learning each thing as your project requires it.

My first project in FB was GTK+tobac, a code sketcher that generates FB source code from Glade GUI-XML files. I did not understand GTK nor FB. I had just some experience in other Basic dialects.

I think you can realise your Fluke app in all the mentioned languages (VB, BasicA or FB). FB will offer the most advanced features. But you have to learn to make them run together.

Vince wrote:Get your program working in text mode, then adding a GUI is just icing on the cake.

-Vince

I think your Fluke app needs some graphic, so I recomment:
    Get the RS-232 working,
    start with a simple GUI and simple graphic,
    then add one feature after the other.
marcov
Posts: 3081
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Postby marcov » Feb 01, 2011 8:19

TJF wrote:
You can find old-fashioned GTK examples at .../FreeBASIC/examples/libraries/Gtk. I prefer using RAD technologies by designing my GUIs with the Glade3-GUI-designer.


IMHO it is not RAD if you can't simply click the button and enter the code.

Otherwise it is just a GUI designer.
TJF
Posts: 3609
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Postby TJF » Feb 01, 2011 8:27

marcov wrote:IMHO it is not RAD if you can't simply click the button and enter the code.

Otherwise it is just a GUI designer.

Sorry, I don't understand.

RAD = software development methodology that uses minimal planning in favor of rapid prototyping.

Glade3 = GUI designer application (software)
AMSA
Posts: 9
Joined: Jan 27, 2011 20:35

Postby AMSA » Feb 01, 2011 9:53

Hello there guys.

Okay, I see that first the most important thing is to get the RS-232 working. Porgramming is FB.

Then, do a simple GUI. Okay. With which software/RAD software? Those that TJF mentioned? Like GTK+tobac or Glade?

So with that software I can do the "code that creates the buttons and the code that processes the events when the user clicks something", thats it?

Best regards and thank you so much for all those answers.
Charles
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Postby MichaelW » Feb 01, 2011 11:21

If you use a dialog you can avoid most of the code that you would otherwise need to create the window and the controls in the window.

MSDN: About Dialog Boxes

You can construct a dialog box template in memory, as is done here:

http://www.freebasic.net/forum/viewtopic.php?t=5667

Or you can use a Dialog Editor, for example the one included with FbEdit.

If you keep the user interface simple, then the code to handle the user interface events is likewise simple.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 8 guests