Simple WinAPI GUI library

User projects written in or related to FreeBASIC.
Lothar Schirm
Posts: 333
Joined: Sep 28, 2013 15:08
Location: Bavaria, Germany

Re: Simple WinAPI GUI library

Postby Lothar Schirm » May 13, 2016 15:14

Thank you very much for your inerest, datwill310!

Ok, it is better to use "once", I do it in my own WinGUI.bi so that it will be included in the next update (I am still waiting for further comments).
Lothar Schirm
Posts: 333
Joined: Sep 28, 2013 15:08
Location: Bavaria, Germany

Re: Simple WinAPI GUI library

Postby Lothar Schirm » May 19, 2016 14:00

New update (download site on FreeBasic Portal see first post). Only small corrections, as discussed recently on different places in this forum.
RNBW
Posts: 175
Joined: Apr 11, 2015 11:06
Location: UK

Re: Simple WinAPI GUI library

Postby RNBW » May 22, 2016 15:34

Lothar

Thank you for the update to your Windows API library. I've not had chance to check it out yet, but I will. I don't anticipate any problems, but I'll advise if I find anything.
RNBW
Posts: 175
Joined: Apr 11, 2015 11:06
Location: UK

Re: Simple WinAPI GUI library

Postby RNBW » May 27, 2016 14:40

Lothar
Congratulations!

I see your Simple WinAPI GUI library has now exceed one thousand views!

I think there is quite a bit of interest in the subject.

Ray
Lothar Schirm
Posts: 333
Joined: Sep 28, 2013 15:08
Location: Bavaria, Germany

Re: Simple WinAPI GUI library

Postby Lothar Schirm » May 28, 2016 16:31

And it has exceeded 300 downloads. Thanks to all who are interested and to all who supported me in the past!
leopardpm
Posts: 1678
Joined: Feb 28, 2009 20:58

Re: Simple WinAPI GUI library

Postby leopardpm » May 28, 2016 16:48

Lothar,
you WinAPI GUI Library is a godsend! Thank you! My interfaces are usually just hacked together and crude, but I am writing a program now for my work and need it to look pnice and clean - you saved me countless hours of extra work in being able to use your library - very simple and easy to use, yet does enough for basic interfaces.... thank you!
Lothar Schirm
Posts: 333
Joined: Sep 28, 2013 15:08
Location: Bavaria, Germany

Re: Simple WinAPI GUI library

Postby Lothar Schirm » May 28, 2016 17:33

Well, everybody is standing on the shoulders of others who did a lot of work before. First, I got some good examples from dodicat similiar to the simple concept of bojan.dozen's "Easy Windows API Tutorial" (see first post), and then I studied the functions library in Paul Squires' fantastic FirefLy. Since I worked with PureBasic for two years, I also had a feeling how a simple GUI library should work, and this motivated me to this project. I wanted a simple GUi library for myself with a code that I understand and which I can maintain easily, using WinAPI (since the WinAPI header files are a fixed part of the FreeBasic package), but without writing a lot of code for just a window with a textbox and a button.
Last edited by Lothar Schirm on May 29, 2016 15:19, edited 1 time in total.
leopardpm
Posts: 1678
Joined: Feb 28, 2009 20:58

Re: Simple WinAPI GUI library

Postby leopardpm » May 28, 2016 17:46

couple of questions:
(1) I didn't see a pull-down menu/button example... is there one?

(2) I am making a listbox, but it would be ideal if in each line of the listbox I could have buttons (or better yet, pull down menus) ... is that possible?

UPDATE: more questions....

(3) How do I access (print to/draw to) the window that is maintained by your GUI?
Here is what I am trying to do:
Image
so the user can select a company fron the list box, and the correct info displays to the right... they will be able to edit/update this info, as well as add a new company, delete the currently selected company

The little 'envelope' icon to the left of 'Main Email' will open up a new email to this email address automatically (got this part figure out)

so if I want all this info in the same window (Listbox & the information), how do I access the window to draw/print in it?

Looking through the WinGUI.bi code, it looks like I could use Label_New function... hmmm not ideal, but workable I guess... BUT, I would like to 'jazz' up the GUI window a bit by adding some boxes, circles, and be able to PUT graphics in there as well, perhaps even set the background for the window (either a single color or an image)? Is there a way I can get to it?
Lothar Schirm
Posts: 333
Joined: Sep 28, 2013 15:08
Location: Bavaria, Germany

Re: Simple WinAPI GUI library

Postby Lothar Schirm » May 29, 2016 16:25

Hi leopardpm,

here are some answers which will probably not be fully satisfactory for you.

(1) There is a file "Menu.bas" with a pull-down menu, and also "Editor.bas" has a pull-down menu. What do you mean by "pull-down menu/button example"?

(2) I have no idea how to place buttons or pull down menus into a listbox, sorry.

(3) You can use the "Label_New" function, that would be ok. Use Chr(13, 10) after each text line if you want to place the whole text into one label. You can give the label a border using the WS_BORDER style. But I do not see a way how to place a button inside the label. Or you use a new label for each text line, so that you can place the button before the line "Main Email: ..." New text can be printed into the label using "Label_SetText". Or what do you mean by "so if I want all this info in the same window (Listbox & the information), how do I access the window to draw/print in it?"?

To "jazz up" the window: WinGUI.bi does not support images or graphics, but it is possible to draw something on a window with WinAPI drawing commands, see for example http://www.freebasic.net/forum/viewtopic.php?f=8&t=15796&hilit=FireFly&start=60. Drawing stuff is explained in the help file Win32_fb.chm. To draw on a window, you must use the WM_PAINT message. Bitmaps can be loaded using the "LoadBitmap" function (WinAPI).

In General, I think you expect too much from my simple tool. It is just thought for people who want to create simple input masks or who need simple controls or menus. If you need much more, you should have a look on Vanya's Window9 http://www.freebasic.net/forum/viewtopic.php?f=14&t=23210&p=204173&hilit=FBGUI#p204173 or on Paul Squires' FireFly http://www.freebasic.net/forum/viewtopic.php?f=8&t=15796&p=136772&hilit=FireFly#p136772.
leopardpm
Posts: 1678
Joined: Feb 28, 2009 20:58

Re: Simple WinAPI GUI library

Postby leopardpm » May 29, 2016 16:31

thank you very much for your reply, Lothar - I am currently trying to use sGUI, by Muttonhead (http://www.freebasic.net/forum/viewtopic.php?f=8&t=13903&p=220637#p220637) and it looks adequate... I don't need much and want as simple as possible, so I think that will work for my purposes.

Thank you again!
Lothar Schirm
Posts: 333
Joined: Sep 28, 2013 15:08
Location: Bavaria, Germany

Re: Simple WinAPI GUI library

Postby Lothar Schirm » Jul 11, 2016 15:00

I created a new update (see first post):

Some EditBox functions added (cut, copy, paste or delete text, get number of text lines from an editor (multiline textbox), get a line of text from an editor

Some examples revised

Some examples added:
- DataGrid.bas: editable data grid using a twodimensional array of editboxes
- ListBox_Table.bas: use a listbox to show data in a table and to retrieve them from the listbox
- Progressbar.bas: Test of progressbar, also a demonstration how to use a Windows timer
RNBW
Posts: 175
Joined: Apr 11, 2015 11:06
Location: UK

Re: Simple WinAPI GUI library

Postby RNBW » Jul 11, 2016 16:29

Hi Lothar

Thank for your update of WinGUI. All the changes are very useful as are the examples. Well done!

Ray
RNBW
Posts: 175
Joined: Apr 11, 2015 11:06
Location: UK

Re: Simple WinAPI GUI library

Postby RNBW » Jul 11, 2016 19:09

Lothar

The code below uses WinGUI and shows two identical grids. The columns are of varying widths, which can be changed by the user.

Data is entered into the top grid. Click on the <Click me!> button and the data is transferred into the second grid. You may wish to include it in your examples for WinGUI.

Code: Select all

'=============================================================================
'GridTransfer.bas
'Shows a grid of InputBoxes in 5 rows and 9 columns
'Includes Row and Column Headings
'Transfers values from one grid to another
'Code contributions gratefully received from Lothar Schirm,
'MrSwiss and fxm
'--------------------------------------------------------------------------------------------------------------
'Posted on 1April 2016
'Last Change on 11 July 2016 using Lothar Schirm's WinGui.bas Library
'=============================================================================
'
' INSTRUCTIONS:
' -------------------
' ENTER DATA INTO THE TOP GRID.
' WHEN COMPLETE CLICK <Click me!> Button.
' DATA WILL BE TRANSFERRED FROM TOP GRID TO BOTTOM GRID
'=============================================================================

#Include "WinGui.bi"

DIM AS Long NumOfRows=5, NumOfCols=9
Dim As String sRows, sCols

DIM SHARED AS HWND Window_Main, Static_Text
DIM SHARED AS MSG msg
'Changed
DIM AS STRING text, text2
DIM AS HWND Edit_Text(1 TO NumOfRows, 1 To NumOfCols)
DIM AS HWND Edit_Text2(1 TO NumOfRows, 1 To NumOfCols)
DIM AS HWND Button_Click
Dim AS Long vPos, hPos, bWidth, bHeight, row, col

'---------------------
' MAIN WINDOW
'---------------------
SUB OpenWindow_Main()
   Window_Main = Window_New(100, 100, 950, 400, "Test Inputbox - Multi-Column Grid")   
END SUB

OpenWindow_Main()

Button_Click = Button_New(10, 10, 100, 20, "Click me!", Window_Main)

'-------------------------------
'  SET UP THE FIRST GRID
'-------------------------------
vPos = 40: bHeight = 20
FOR row = 1 TO NumOfRows
   'hPos = 0 : bWidth = 0
   FOR col = 1 TO 9
      SELECT CASE col
      CASE 1
         hPos = 10: bWidth = 65
      CASE 2
         hPos = 75: bWidth = 380
      CASE 3 TO 8
         hPos = col*65+(455-65*3) : bWidth = 65
      CASE 9
         hPos = (10+65+380)+(col-3)*65 : bWidth = 75
      END SELECT
      Edit_Text(row, col) = EditBox_New(hPos, vPos+bHeight*(row-1), bWidth+1, bHeight+1, "",, Window_Main)
   NEXT
NEXT

'----------------------------------
'  SET UP THE SECOND GRID
'----------------------------------
bHeight = 20
vPos = 40+bHeight*(NumOfRows+3)
FOR row = 1 TO NumOfRows
   'hPos = 0 : bWidth = 0
   FOR col = 1 TO 9
      SELECT CASE col
      CASE 1
         hPos = 10: bWidth = 65
      CASE 2
         hPos = 75: bWidth = 380
      CASE 3 TO 8
         hPos = col*65+(455-65*3) : bWidth = 65
      CASE 9
         hPos = (10+65+380)+(col-3)*65 : bWidth = 75
      END SELECT
      Edit_Text2(row, col) = EditBox_New(hPos, vPos+bHeight*(row-1), bWidth+1, bHeight+1, "",, Window_Main)
   NEXT
NEXT

'-----------------------------------
' SET UP HEADINGS IN ROW 1
' IN BOTH GRIDS
'-----------------------------------
row = 1
FOR col = 2 TO NumOfCols
   EditBox_SetText(Edit_Text(row,col), "Col" + STR(col-1))
   EditBox_SetText(Edit_Text2(row,col), "Col" + STR(col-1))
Next

'----------------------------------
' SET UP HEADINGS IN COL 1
' IN BOTH GRIDS
'----------------------------------

col = 1
FOR row = 2 TO NumOfRows
   FOR col = 1 TO 1
      'text = text + " " + STR(row-1)
      'EditBox_SetText(Edit_Text(row,col), text)
      'text = "Row"
      EditBox_SetText(Edit_Text(row,col), "Row" + STR(row-1))
      EditBox_SetText(Edit_Text2(row,col), "Row" + STR(row-1))
   NEXT
NEXT

'-----------------------------------------
'Close out code and end program
'-----------------------------------------
DO
   WaitEvent(msg)
   SELECT CASE msg.hwnd
   CASE Button_Click
      IF msg.message = WM_LBUTTONDOWN THEN
         '-----------------------------------------
         ' GET VALUES FROM FIRST GRID
         ' AND TRANSFER TO SECOND GRID
         '-----------------------------------------
         FOR I As Integer = 1 To NumOfRows
            FOR J As Integer = 2 To 9
               EditBox_SetText(Edit_Text2(I,J), EditBox_GetText(Edit_Text(I,J)))
            NEXT J
         NEXT I
      END IF
   END SELECT
LOOP UNTIL Window_Event_Close(Window_Main, msg)

END


Hope it's of use

Ray
Lothar Schirm
Posts: 333
Joined: Sep 28, 2013 15:08
Location: Bavaria, Germany

Re: Simple WinAPI GUI library

Postby Lothar Schirm » Jul 12, 2016 9:09

Nice example, I will include it in the next update. You wrote that the column widths can be changed by the user. How? In the source code?

Regarding the combobox, we recently had a discussion. Meanwhile I think it might be useful to include also a combobox in the project, even if it has no scrollbar and is not editable. It might be useful in order to choose items from a shorter list, e.g. days of a month (1 to 31), if it is important to save space in the GUI. What do you or other people think about it?
RNBW
Posts: 175
Joined: Apr 11, 2015 11:06
Location: UK

Re: Simple WinAPI GUI library

Postby RNBW » Jul 12, 2016 10:45

Hi Lothar

Lothar Schirm wrote:Nice example, I will include it in the next update. You wrote that the column widths can be changed by the user. How? In the source code?

Regarding the combobox, we recently had a discussion. Meanwhile I think it might be useful to include also a combobox in the project, even if it has no scrollbar and is not editable. It might be useful in order to choose items from a shorter list, e.g. days of a month (1 to 31), if it is important to save space in the GUI. What do you or other people think about it?


The column widths can be set up in the code, using Case Select (or a dIfferent method if the user prefers). The example I submitted it's based on the configuration of a little project I've been working on (on and off) for some time. I'll look at making it more flexible when I have time.

Regarding the Combobox, I think it would be useful. You have always said that you wanted to keep the GUI simple, so you need only include the Combobox messages that you think meet with this. I think something along the lines off what you have done with the listbox should suffice.

I note that you have had over 1500 views of this topic. I'm sure someone out there must have some ideas on what they would like you to produce, taking into account that you have said that you want to keep it simple. It certainly meets my needs at the moment. It's also got me looking at the Windows API.

Ray

Return to “Projects”

Who is online

Users browsing this forum: rchockxm and 2 guests