[Gambas-user] Sample component with a form

Gian bagoneo at ...69...
Fri Mar 27 10:50:48 CET 2015


Il 26/03/2015 23:15, Tobias Boege ha scritto:
> On Thu, 26 Mar 2015, Roel Touwen wrote:
>> Hi everyone,
>>
>> Has anybody a sample source of a component which holds a form? I'm
>> trying for two weeks now and I simply don't succeed.
>>
>> What I want to do is have form that I can embed in another form (within
>> a tab). I could use a workspace but people can delete the tab then.
>>
>
> It's not clear to me what you want to do. You must know that the term
> "component" around Gambas usually means a shared library which adds
> functionality to the interpreter. gb.qt4, for example, is the QT4
> component.
>
> I'll assume that you want to create just a "widget" class which is usually
> called a "control", instead of component. [ A component is a whole
> collection of classes, and sometimes also controls, for a specific task. ]
>
> But you don't need to create a new control class either. Embedding forms
> is super easy. Again, assuming that I understood you, I attach a project
> which shows how to embed some instance of a Form class into a TabPanel
> where you can control, contrary to Workspace, if the user is able to close
> a tab.
>
> Note: On my system, the first form which is embedded into a tab of the
> TabPanel is not resized, while all subsequent forms are expanded to fill
> their tab. I don't know why...
>
> Regards,
> Tobi
>
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
>
>
>
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>

Hello Tobias
and change the code so?

Private $bFirst As Boolean = True

Public Sub btnAdd_Click()
   Dim hForm As FTest

   If Not $bFirst Then Inc panTabs.Count ' Get a new tab


   With panTabs
     .[.Count - 1].Text = Subst$("Tab #&1", .Count)
     ' Create the form with the new tab as its parent container, which
     ' effectively embeds the form into that container.
     hForm = New FTest(.[.Count - 1], "Hi!", Rnd(&H808080, &Hffffff))
     If $bFirst Then
       hForm.H = panTabs.H
       hForm.W = panTabs.W
       $bFirst = False
     Endif
   End With
End

Regards
Gianluigi





More information about the User mailing list