none
Windows Forms for Small Basic v2 (Old thread)

    General discussion

  • * EDIT: Version 2 is out!* Please download it here: http://www.mediafire.com/?db5gjpa22z2t82a. I added a Chart control and changed the class's name to "Forms" instead of "WindowsFormsForSmallBasic". There is an updated sample with ID: ZQX928.

     Hello guys! I have spent the past couple of days writing a new extension for Small Basic. Here is a screenshot of a program made with it:

    The extension adds the following Windows Forms controls to Small Basic (** means that no other extension supports the control):

    - Button

    - RadioButton

    - CheckBox

    - ** Chart **

    - Label

    - ** LinkLabel **

    - **NumericUpDown**

    - **DateTimePicker**

    - **MonthCalendar**

    - ProgressBar

    - TrackBar

    - **RichTextBox**

    - PictureBox

    - **MaskedTextBox***

    - **NotificationIcon***

    - **ComboBox**

    - **TreeView**

    - **ListView**

    Plus, it is 100% event driven! It is super easy to use! Just call WindowsFormsForSmallBasic.Setup() before you start and WindowsFormsForSmallBasic.InitializeForm() when all the controls are placed--- this shows the form and hands off control to it. You may not modify the controls after this or write any more code outside of the event handlers. However, your event handlers can preform these operations.

    Here is a sample (outdated, for v1): HMD046

    And download link for the extension (outdated, for v1): http://www.mediafire.com/download.php?b8w679cqs6mpusr

    Please ask any questions you make have and suggestions / bug reports are welcome too! I expect to add some more controls to the extension soon!


    Please mark any answers and "vote as helpful" any posts that help you!







    Monday, November 05, 2012 8:57 PM
    Answerer

All replies

  • Nice job - lots of work in this and loads for SB users to play with.
    Monday, November 05, 2012 9:29 PM
    Moderator
  • Thanl you, Litdev! I appreciate your acknowledgement. What controls do you think I should add next? I am thinking MenuStip, ContexMenu, ErrorProvider, ToolTip, and DomainUpDown. 

    By the way, I found a way to do Forms without Invoke calls or delegates (except the delegates for the events and SmallBasicCallBacks). What you do is make a Windows Forms project, use the .Controls collection of the form to add your controls, connect and delegate their event handlers,  then call Application.EnableVisualStyles() and Application.Run(), then the form starts with your programmatically added controls. It was not hard to write once I figured that out, but it was super tedious to add all the controls --- as it stands now, 2031 lines of code.


    Please mark any answers and "vote as helpful" any posts that help you!

    Monday, November 05, 2012 9:45 PM
    Answerer
  • How about a Chart control - more work but could be useful, or more options for the RichTextBox.

    EDIT looks like Chart are not .Net 3.5, perhaps it  can be added though, e.g. here, but  perhaps redistribution issues so may not be a good idea.


    Monday, November 05, 2012 9:58 PM
    Moderator
  • That is a VERY awesome extension. It includes many more graphical controls than maybe even the Data Extension and the Fremy Extension combined! Works well on this 32-bit laptop too! (which is impressive because Data Extension and many others won't even run on this computer)Only ONE request, though. Perhaps you could shorten the name so that instead of being "WindowsFormsForSmallBasic" it could be just "WindowsForms" or "Forms."

    I am a 10 year old that loves math, games, and computers. 'Binary is as easy as 1, 10, 11.'


    • Edited by Math Man Monday, November 05, 2012 11:00 PM
    Monday, November 05, 2012 10:58 PM
  • That is a VERY awesome extension. It includes many more graphical controls than maybe even the Data Extension and the Fremy Extension combined! Works well on this 32-bit laptop too! (which is impressive because Data Extension and many others won't even run on this computer)Only ONE request, though. Perhaps you could shorten the name so that instead of being "WindowsFormsForSmallBasic" it could be just "WindowsForms" or "Forms."

    I am a 10 year old that loves math, games, and computers. 'Binary is as easy as 1, 10, 11.'


    Thanks for your kind words! More controls are coming soon.

    I think I will rename it WindowsForms. It is just kind of confusing for me to write in C# and have Windows.Forms and a WindowsForms namespace (Windows.Forms is the .NET built library for Windows Forms). Don't worry though, I will rename it. 


    Please mark any answers and "vote as helpful" any posts that help you!


    Monday, November 05, 2012 11:06 PM
    Answerer
  • How about a Chart control - more work but could be useful, or more options for the RichTextBox.

    EDIT looks like Chart are not .Net 3.5, perhaps it  can be added though, e.g. here, but  perhaps redistribution issues so may not be a good idea.


    I have downloaded the Chart API and will see what I can come up with. Maybe I will do a setup bootstrapper that downloads and installs the lib... that would take care of the redist issues. 

    Please mark any answers and "vote as helpful" any posts that help you!

    Monday, November 05, 2012 11:08 PM
    Answerer
  • How about a Chart control - more work but could be useful, or more options for the RichTextBox.

    EDIT looks like Chart are not .Net 3.5, perhaps it  can be added though, e.g. here, but  perhaps redistribution issues so may not be a good idea.


    I have implemented the Chart with quite a few options! I will look into the RichTextBox as well--- what kind or options do you suggest?

    Please mark any answers and "vote as helpful" any posts that help you!

    Tuesday, November 06, 2012 2:24 AM
    Answerer
  • That is a VERY awesome extension. It includes many more graphical controls than maybe even the Data Extension and the Fremy Extension combined! Works well on this 32-bit laptop too! (which is impressive because Data Extension and many others won't even run on this computer)Only ONE request, though. Perhaps you could shorten the name so that instead of being "WindowsFormsForSmallBasic" it could be just "WindowsForms" or "Forms."

    I am a 10 year old that loves math, games, and computers. 'Binary is as easy as 1, 10, 11.'


    I have implemented your request! The class is now called "Forms". I was going to call it "Form" since there is only one instance of the window (as opposed to "Forms"), but that created a huge mess with the class "Form" which is the .NET Windows Forms class.


    Please mark any answers and "vote as helpful" any posts that help you!

    Tuesday, November 06, 2012 2:26 AM
    Answerer
  • Not working in XP SP3

    They say working hard is good but i say working smart is best...

    Tuesday, November 06, 2012 4:29 PM
  • Not working in XP SP3

    They say working hard is good but i say working smart is best...


    Are you using the latest sample and the latest version (v2)? Also, you need the Microsoft Chart Controls .NET 3.5... use the link Litdev posted.

    Please mark any answers and "vote as helpful" any posts that help you!

    Tuesday, November 06, 2012 6:06 PM
    Answerer
  • For the RichTextBox I was just thinking about some of the formatting options, like color and font and whatever else you find - there are loads of options.

    One other possibility is to embed the controls in the GraphicsWindow - quite a lot more work, but it does allow the controls to use the Shapes commands like move, hide, zoom, opacity etc and also interact with any other extensions that relate to the GraphicsWindow - one reason I like the Fremy extension.  If each extension uses its own forms window or gamewindow (e.g. Data extension),  then it does eventually become harder for users to pick and choose bits from various extensions.

    Either way yours is a big step forward for SmallBasic.

    Tuesday, November 06, 2012 7:07 PM
    Moderator
  • For the RichTextBox I was just thinking about some of the formatting options, like color and font and whatever else you find - there are loads of options.

    One other possibility is to embed the controls in the GraphicsWindow - quite a lot more work, but it does allow the controls to use the Shapes commands like move, hide, zoom, opacity etc and also interact with any other extensions that relate to the GraphicsWindow - one reason I like the Fremy extension.  If each extension uses its own forms window or gamewindow (e.g. Data extension),  then it does eventually become harder for users to pick and choose bits from various extensions.

    Either way yours is a big step forward for SmallBasic.


    I will implement the RichTextBox ideas when I can. Sorry, I cannot achieve GW compatability since the GW is WPF and my extension is Windows Forms.

    Please mark any answers and "vote as helpful" any posts that help you!

    Tuesday, November 06, 2012 7:40 PM
    Answerer
  • The following creates a RichTextBox that can be treated as any other shape in the GraphicsWindow, eg

    GraphicsWindow.Show()
    rtb = LDShapes.AddRichTextBox(100,100)
    Shapes.Move(rtb,100,100)
    Note that the RTB is System.Windows.Controls.RichTextBox (WPF).  There are WPF alternatives to Windows Forms for most everything I think.
            /// <summary>
            /// Add a RichTextBox
            /// </summary>
            /// <param name="width">width</param>
            /// <param name="height">height</param>
            /// <returns>The RTB name</returns>
            public static Primitive AddRichTextBox(Primitive width, Primitive height)
            {
                Type GraphicsWindowType = typeof(GraphicsWindow);
                Type ShapesType = typeof(Shapes);
                Dictionary<string, UIElement> _objectsMap;
                Canvas _mainCanvas;
                string shapeName;
    
                try
                {
                    MethodInfo method = ShapesType.GetMethod("GenerateNewName", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
                    shapeName = method.Invoke(null, new object[] { "Control" }).ToString();
    
                    _mainCanvas = (Canvas)GraphicsWindowType.GetField("_mainCanvas", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
                    _objectsMap = (Dictionary<string, UIElement>)GraphicsWindowType.GetField("_objectsMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
    
                    InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
                    {
                        try
                        {
                            RichTextBox richTextBox = new RichTextBox();
                            richTextBox.Width = width;
                            richTextBox.Height = height;
    
                            _objectsMap[shapeName] = richTextBox;
                            _mainCanvas.Children.Add(richTextBox);
                            return shapeName;
                        }
                        catch
                        {
                            return "";
                        }
                    });
                    method = GraphicsWindowType.GetMethod("InvokeWithReturn", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
                    return method.Invoke(null, new object[] { ret }).ToString();
                }
                catch
                {
                    return "";
                }
            }
    

    Tuesday, November 06, 2012 8:34 PM
    Moderator
  • Great code, Litdev! Thanks for the tips. I will certainly consider making a WPF alternative or converting the whole thing to WPF.

    However, I think one thing that is special about my extension is that it uses Windows Forms and has controls that WPF doesn't support like NumericUpDowns, MonthCalendars, and DateTimePickers... just to name a few. That is probably why Fremy's and Oskariok's extensions do not have those controls. Also, I have written 2,389 lines of code so far and it would be tricky to port everything. 

    Once I am done with writing it and implementing everyone's suggestions (I have gotten the class name shorter and implemented Charts so far and released that, but am still working on the RTB), I will open-source it and let everyone improve on it. I will help you guys make a WPF version if you would like, too. It would just be confusing now to fork into two versions (Forms and WPF) and have some features in one and some not in the other and vice-versa.

    But I promise, once I have everything implemented and documented in XML, I will open-source it and make my best effort to help you guys follow and understand my code and improve upon it!


    Please mark any answers and "vote as helpful" any posts that help you!

    Wednesday, November 07, 2012 10:45 PM
    Answerer
  • I think your extension using Forms is great and it would be a lot of work to convert to GraphicsWindow WPF (all the Invoking is a pain) and may not be possible to do everything that way.  Keep up the good work.
    Wednesday, November 07, 2012 10:56 PM
    Moderator
  • I think your extension using Forms is great and it would be a lot of work to convert to GraphicsWindow WPF (all the Invoking is a pain) and may not be possible to do everything that way.  Keep up the good work.
    Thanks Litdev! I think I will do as you suggest until I finish adding all the controls then see what is next.

    Please mark any answers and "vote as helpful" any posts that help you!

    Wednesday, November 07, 2012 11:25 PM
    Answerer
  • Hi Gungan,

    Extremely usefull extension, I will be using this alot, thanks. I think a menu strip would be a good addition to the extension, also a canvas would be nice, the ability to add graphics into a child canvas would be very useful.

    Good luck with your extension.

    Monday, November 19, 2012 11:04 AM
  • I am getting the following error when running your demo:

    at SB_Forms.Forms.Setup()
    at _SmallBasicProgram._Main()

    Monday, November 19, 2012 11:12 AM
  • Great! I was looking for this a long time ago. I will test it! :)

    Greetings Timo

    Monday, November 19, 2012 5:24 PM
  • Great! I was looking for this a long time ago. I will test it! :)

    Greetings Timo

    Thanks!

    -Noah J. Buscher "You just need a spark to start a fire."

    Tuesday, November 20, 2012 11:31 PM
  • I added this to the Extensions Gallery on the blog: http://blogs.msdn.com/b/smallbasic/archive/2012/10/12/small-basic-extensions-gallery.aspx
    Thanks!

    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Twitter, Wiki)

    Saturday, November 24, 2012 6:01 AM
    Owner
  • Gungan, I'm going to blog about this extension. If there's something specific you want it to say, email me at edprice at Microsoft. Otherwise, I'll use a lot of what you have here.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Twitter, Wiki)

    Saturday, November 24, 2012 6:02 AM
    Owner
  • Gungan, I'm going to blog about this extension. If there's something specific you want it to say, email me at edprice at Microsoft. Otherwise, I'll use a lot of what you have here.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Twitter, Wiki)


    GunGan is gone on a vacation... You may want to add the website (ioextension.codeplex.com). Thanks! :)

    -Noah J. Buscher "You just need a spark to start a fire."

    Saturday, November 24, 2012 3:47 PM
  • Meaning that this extension is now part of the I/O Extension? That might be a few blog posts. =^)

    But I'll start with this one. Please verify and let me know of any changes to make... http://blogs.msdn.com/b/smallbasic/archive/2012/11/25/windows-forms-i-o-extension-for-small-basic.aspx

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Twitter, Wiki)

    Monday, November 26, 2012 12:00 AM
    Owner
  • Meaning that this extension is now part of the I/O Extension? That might be a few blog posts. =^)

    But I'll start with this one. Please verify and let me know of any changes to make... http://blogs.msdn.com/b/smallbasic/archive/2012/11/25/windows-forms-i-o-extension-for-small-basic.aspx

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Twitter, Wiki)


    Yes... It is now part of I/O Extension. The blog post looks great (on behalf of GunGan37)! Thanks a ton! :)

    -Noah J. Buscher "You just need a spark to start a fire."

    Tuesday, November 27, 2012 3:33 AM
  • Hi guys! I am back from vacation and am ready to start developing again. I have a failing hard disk and need to take care of that so it might be a couple of days until check-ins become regular on CodePlex.

    MainChip, thanks for your suggestions. I have already implemented the MenuStrip in the latest CodePlex source code. I need to add drawing and will do that as soon as I can. Also, could you please give more details about your error and post the code that caused it (the SB code). Also, does the demo run fine? Thanks for your feedback!


    Please mark any answers and "vote as helpful" any posts that help you!

    Wednesday, November 28, 2012 1:16 AM
    Answerer
  • hello I just copy your extension files into lib and opened small basic and imported your sample ZQX928 when i try to run it says exception handle in 

    at SB_Forms.Forms.Setup() at _SmallBasicProgram._Main()

    same problem as Mainchip seems this problem is occurringto some of us but not others any suggestion ???

    Thursday, February 21, 2013 3:59 AM
  • hello I just copy your extension files into lib and opened small basic and imported your sample ZQX928 when i try to run it says exception handle in 

    at SB_Forms.Forms.Setup() at _SmallBasicProgram._Main()

    same problem as Mainchip seems this problem is occurringto some of us but not others any suggestion ???

    Hello! Thanks for using my extension.

    This extension, however is old and not updated. Please use the new IO Extension (which contains IOForms, the new version of this): http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/8a206925-8c0b-4d3c-939d-31cea582ff9e

    Thanks! Please post any questions you may have about the IO Extension or feature requests on the new thread.


    Please mark any answers and "vote as helpful" any posts that help you!

    Friday, February 22, 2013 2:13 AM
    Answerer
  •  

       Hola amigo

    Publiqué tu post en Small Basic Enthusiasts de Facebook

    Obviamente con tu nickname (gungan37), y el link de esta página

    Espero nos visites en ese grupo Small Basic en Faceboob

    Saludos


    carlosfmur - Buenos Aires

    Friday, May 17, 2013 1:27 AM
  • Perdon, pero yo no uso Facebook para algo que no es personal =( Espero que ud. lo entiende. Pero, si ud. quiere hacer un correo en el grupo de "Small Basic Enthusiasts" sobre el IO Extension, por favor hagalo. Solamente lo que pido por es que ud. use el version mas nuevo de mi extension: http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/8a206925-8c0b-4d3c-939d-31cea582ff9e En lo, yo he cambiado partes del PlusPlus Extension, el Windows Forms Extension, y partes nuevos como Google Maps y Windows 7/8 Sensors.

    Gracias!


    Please mark any answers and "vote as helpful" any posts that help you!


    • Edited by gungan37Editor Saturday, May 18, 2013 12:08 AM Grammar mistake
    Saturday, May 18, 2013 12:07 AM
    Answerer
  • Hello. First of all, congratulations because, apparently, wrote an excellent extension SmallBASIC.
    I write because I can not make it work your program.
    It is like calling the new commands you programmed.
    The example that you hung up on the internet, does not work. Is incomplete?
    As I did with other extensions, I created the "lib" folder inside of SmallBASIC, where I copied the files of your extension.
    What am I doing wrong?
    From already, thank you very much.

    JML2013

    P. D.: Sorry for my bad English. I wrote in Spanish and used the Google Translator.



    Wednesday, September 18, 2013 1:57 AM
  • Hola JML2013!

       Yo hablo espanol mas o menos (pero no puedo poner accentos en mis palabras porque mi teclado es de los EE UU.)

       ¿Que ejemplo estas usando? ¿Y copiaste los todos del archivos del carpeta de "lib"?

    P.D.  ¿has visto mi "I/O Extension"? (http://social.msdn.microsoft.com/Forums/en-US/8a206925-8c0b-4d3c-939d-31cea582ff9e/new-extension-io-extension) Es mas nuevo que esto y tiene mucho mas funcionalidad.


    Please mark any answers and "vote as helpful" any posts that help you!


    Wednesday, September 18, 2013 2:09 AM
    Answerer