cancel
Showing results for 
Search instead for 
Did you mean: 

A function to set the size and position of an object.

leon_laikan
Participant
0 Kudos

Hi, everybody

We write our add-ons using VB.NET in Visual Studio.

Everything is coded in VB.NET / SDK, and we don't use B1DE (yet). We must find time to learn that tool someday!.

The sizes and positions of all objects are coded like:

        oItem = oForm.Items.Add("EditTxt", SAPbouiCOM.BoFormItemTypes.it_EDIT)

       oItem.Left = 820

        oItem.Width = 125

        oItem.Top = 750

        oItem.Height = 10

        oEdit1 = oItem.Specific

     

As we use a large number of these codes, I am wondering if we can use a function (or should we use a sub?) to code the dimensions.

For ex. we could have a function called LeftWidthTopHeight(), so that the lines in bold above could be replaced by a single line:

LeftWidthTopHeight(820,125,750,10)

Sometimes we develop very lengthy add-ons; so this could reduce coding.

Any ideas on how to achieve this are most welcome.

Thanks

Leon

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

Hi Leon,


Everything is coded in VB.NET / SDK, and we don't use B1DE (yet). We must find time to learn that tool someday!.

I don't recommend you to start with B1DE since i think with the new B1Studio for VS, the B1DE (B1Wizardbase to be more precise) will be obsolete. More over there is no official B1DE for 64 bit addon.

You should go direct to B1Studio for VS. Almost the same, but a bit different from the sample I gave you your multiple classes post.

As for this question, you should really draw your form in srf/xml and load them using the LoadBatchActions method of SBO_Application.

If you still want to stick with your current way, of course you can always create a sub/function for this

Public Sub ResizeItem(ByRef oItem as SAPbouiCOM.Item, Left as Integer, Top as Integer, Height as Integer, Width as Integer)

     oItem.Left = Left

     oItem.Top = Top

     oItem.Height = Height

     oItem.Width = Width

End Sub

Place the above code in a Module so that it is accessible anywhere in your project.

You call in your code

        oItem = oForm.Items.Add("EditTxt", SAPbouiCOM.BoFormItemTypes.it_EDIT)

        'oItem.Left = 820

        'oItem.Width = 125

        'oItem.Top = 750

        'oItem.Height = 10

        ResizeItem(oItem, 820,750,10,125)

        oEdit1 = oItem.Specific

Regards
Edy

leon_laikan
Participant
0 Kudos

Hi Edy,

Thanks for your reply.

Glad you advised me to use B1 Studio rather than B1DE.

Although I never worked with either, I did play a little with both, and I found that B1 Studio is something I could more easily understand, and faster.

Just a couple of questions about B1Studio.

  • I found that we could specify positions but only as integers. I have the bad(?) habit of always specifying positions and sizes as parameters (a % of Screen Resolution) like this:

        As a % of the foll:

        System.Windows.Forms.SystemInformation.VirtualScreen.Width

        and

        System.Windows.Forms.SystemInformation.VirtualScreen.Height

         and the reason is to make the screen look similar to all users on the network, even if they use different sizes and brands of monitors. I found this   method works perfectly for me.

         With B1 Studio, can we still use parametrized sizes and positions?

  • Can B1 Studio generate SDK code which can be modified to suit my requirements?

        Ex. Once I specify positions in B1DE ,  B1 Studio, can I obtain the SDK code and modify it to change it  into a parameter?

Sorry for asking these questions, but one reason why I delayed in learning B1DE or B1 Studio, is that I believe (perhaps incorrectly) that with raw SDK, I can create more sophisticated add-ons.

I'll try your suggestion today and let you know how it goes.

Best Regards

Leon

edy_simon
Active Contributor
0 Kudos

Hi Leon,

First of all, you need to differentiate B1Studio and B1Studio for Visual Studio.

B1Studio alone is more of a screen composer. While the B1Studio for Visual Studio allows you to also generate code. Here I will take it as B1Studio for Visual Studio.

With B1 Studio, can we still use parametrized sizes and positions?

The drawing of the form is by XML. here you need to specify the absolute positioning.

You can however, change it after form is drawn on screen.

Can B1 Studio generate SDK code which can be modified to suit my requirements?

B1 Studio does not generate code. It is just merely give you the same feeling as you code in pure VS windows form project. ie An object event is handled by each procedure instead of one big item event procedure that you need to make branches like in the old SAPbouiCOM.

Regards
Edy

.

leon_laikan
Participant
0 Kudos

Thanks Edy,for the enlightening explanation.

I hope I am not bothering you too much.

Stand-alone B1 Studio appears to be is quite easy to learn.

I will learn both the Stand-alone version and the VS version (which I think I'll need to buy)

Just another couple of questions please, to help me decide whether to buy the VS version:

  • Can B1 Studio for VS do 'all' the things I am doing now with SDK? I mean, is it as powerful as SDK?

  • You see, I am not aiming to develop sophisticated applications for its own sake!

        Unfortunately, real life situations are really complex. And I am forced, by circumstances to use sophisticated techniques to develop add-ons that

        are extremely easy and user-friendly to use. I could not have done much without generous help from the forum.

       I think you will agree with me that the easier and more intuitive it is to use an add-on, the more complex the  programming becomes..

  • Will the use of  B1 Studio for Visual Studio cut development time drastically?

If B1 Studio for VS is appropriate for me, I'll make it a must to start documenting about it, and start using it.

Best Regards,

Leon

edy_simon
Active Contributor
0 Kudos

Hi Leon,


Can B1 Studio for VS do 'all' the things I am doing now with SDK? I mean, is it as powerful as SDK?

The term 'SDK' you are referring to is the 2 dlls, SAPbobsCOM and SAPbouiCOM.

B1Studio for VS is just a UI tool to help you write the code. The backbone of the code is still the 2 DLLs.

As such, B1Studio for VS is not a replacement for the DLLs.

ie. You can actually write a VB.Net code in a Notepad. But it would be easier if you have the IDE (Visual Studio).


Will the use of  B1 Studio for Visual Studio cut development time drastically?

It is just a matter of what you are used to.

All the thing that B1Studio offer can be handwritten in standard VS it self if you are familiar with how the new UI Framework work.

The thing is, when you use B1S for VS, some code are generated for you.

You can regard this as your cheat sheet and look at how they are doing things. This is helpful especially if you are not familiar yet with the Framework.

For me, I still prefer to handwritten it myself.

Note that since SBO9, SAP improves the SAPbouiCOM with a new Framework.

This  makes it possible to handle one specific item event in its own procedure. In the old UI API, this will need a large amount of work.

Regards

Edy

leon_laikan
Participant
0 Kudos

Edy,

Thanks a lot for your very clear explanation on B1 Studio for Visual Studio.

You remind me that when I started programming in VBA (For Excel) to develop complex VBA applications, I broke the application into simple steps, then used the Macro Recorder to generate codes for each simple step.

Then I put all those simple macros into one big VBA project, and filled in the missing codes that could not be generated by the Macro Recorder.

Yes, this makes learning and development faster.

> For me, I still prefer to handwritten it myself.

For me too

Best Regards,

Leon

Answers (1)

Answers (1)

Former Member
0 Kudos

hello,

first of all i think this question should be posted in a generic programming forum, as it's not related to sap b1 sdk.

this is basic programming.

you have to develop a function / sub in order to save time and development effort.


Public Shared Function Edit(ByRef oForm As Form, ItemUID As String, DataSourceID As String, Top As Integer, Left As Integer, Height As Integer, Width As Integer, AffectsFormMode As Boolean, Enabled As Boolean, FromPane As Integer, ToPane As Integer, TabOrder As Integer, ExtEdit As Boolean, RightJustified As Boolean, CFL_UID As String, CFL_Alias As String) As EditText

  Dim item As Item

  If Not ExtEdit Then

  item = oForm.Items.Add(ItemUID, BoFormItemTypes.it_EDIT)

  Else

  item = oForm.Items.Add(ItemUID, BoFormItemTypes.it_EXTEDIT)

  End If

  item.Top = Top

  item.Left = Left

  If Height <> 0 Then

  item.Height = Height

  End If

  item.Width = Width

  item.Enabled = Enabled

  item.FromPane = FromPane

  item.ToPane = ToPane

  item.AffectsFormMode = AffectsFormMode

  item.RightJustified = RightJustified

  Dim editText As EditText = CType(item.Specific, EditText)

  If Operators.CompareString(DataSourceID, "", False) <> 0 Then

  editText.DataBind.SetBound(True, "", DataSourceID)

  End If

  If TabOrder <> 0 Then

  editText.TabOrder = TabOrder

  End If

  If Operators.CompareString(CFL_UID, "", False) <> 0 Then

  editText.ChooseFromListUID = CFL_UID

  editText.ChooseFromListAlias = CFL_Alias

  End If

  Return editText

  End Function

something like that, i translated from an old c# version

but please, take your time learning vb programming ( ora another language ) before delving into sap b1 sdk.

it's a friend's advice.

happy coding

leon_laikan
Participant
0 Kudos

Hi, Christian

Thanks a lot for your reply.

I will try your suggestion this afternoon and let you know how it goes.

Although I am developing add-ons on a routine basis for some six months now, I agree with you that the basics are a bit shaky.

But

With a little help from my friends...

Best Regards,

Leon