Hi Edy,
No, I am not getting you wrong at all! How can I get you wrong?
You were my first mentor. You remember? I was a newbie, and you taught me my very first steps in SDK, and helped me enormously along numerous projects. I always remind my assistant how precious you are for us.
Thanks to you, and other mentors, I, who knew nothing about VB.NET and SDK less than 2 years ago, now can write sophisticated applications (I have 2 assistants, Karishma & Jessica who are doing wonderful work).
BTW, I don't write sophisticated add-ons just for the sake of challenge, but because I work in a company where the requirements are really complex. I am an accountant by profession, not a programmer!
It was Maik Delly, another superb mentor who urged me to try SAP B1 Studio for VS. And so, I tried, hoping it would solve my problem.
But it did not!
-----------------
Well, let's recap my problem, and how I solved it!
This can be helpful to any other person who encounters the same problem.
I have searched the entire SDK forum, and have not found a single thread using my idea.
Many experts have proposed different solutions, but I did not find they worked in my case.
-----------------
The Problem:
I develop an add-on using VB.NET and SDK. There are many screens where users can enter data.
The application is available to all users (who are located in different places and have different types of monitors).
The problem is that the screens are perfect when viewed from the computer on which the application was developed (computer A). But when viewed on another computer B (with a screen of different resolution), the image is distorted.
When I modify my code to make the screen look perfect on computer B, it is now distorted on screen A. You see the problem... Come on ... I can't ask my boss to change all monitors to a single model!
When any user opens SAP on any computer, the SAP screen always look the same! (even with monitors of different resolutions), isn't it?
Why can't we have the same thing for add-ons?
This is the problem I wish to solve!
How I solved the problem:
The TRICK is to use a formula to read the screen resolution of the user's monitor.
Then make the dimensions and positions of all items on the screen (edit boxes, combo, static texts, etc) depend on the screen resolution.
In this way, "resizing" of the form is automatic. All my forms are maximised.
All users will see a screen (nearly) the same as any other user, even if his monitor is square or rectangular, or his resolution is 1680 x 1050 or 1440 x 900 or even if he manually changes his monitor resolution.
I found that the resize method in DI API resizes only the form (I mean the frame), but leaves the items on the form unchanged. This is not true resizing! If I resize a form to double its dimensions, I want the form to look exactly the same as if I had used a magnifying glass to magnify the whole form! This would be TRUE WYSIWIG!
It will speed up your development time as it is WYSIWYG.
> Speed up development time: yes, surely
> WYSIWYG? : If it cannot resize like a real glass magnifier does, I don't think it merits being called WYSIWIG?
Some sample code:
Public Shared VirtualScreenWidth As Double = System.Windows.Forms.SystemInformation.VirtualScreen.Width
Public Shared VirtualScreenHeight As Double = System.Windows.Forms.SystemInformation.VirtualScreen.Height
(This code was graciously provided by Maik Delly. )
-----
oItem = FormSelx.Items.Add("C_ToShip", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 0.58 * VirtualScreenWidth
oItem.Top = 0.39 * VirtualScreenHeight
oItem.Width = 0.11 * VirtualScreenWidth
oItem.Height = 0.02 * VirtualScreenHeight
C_ToShip = oItem.Specific
All my items are similarly parametrized. I don't use fixed dimensions.
I use VirtualScreenHeight for vertical dimensions, and VirtualScreenWidth for horizontal ones.
Outstanding Problem:
My method gets very near to true WYSIWIG, but there is one problem it cannot solve, nor can any other method, because of SAP design.
It seems that SAP divides your form into 4 equal parts, let's call them Quadrants.
There is a vertical and a horizontal quadrant line.
If you have the misfortune of placing any item (say an edit box) on a quadrant line, SAP pushes the item away from the line. There is no way to avoid this.
Worse, the quadrant lines are NOT thin lines. They appear to be so thick I would rather call them Quadrant Bands. Suffice you inadvertently place an item just on top of the horizontal quadrant band, SAP pushes it well down to below the band. Imagine the distortion this creates.
There is NO SOLUTION except design your form TO AVOID PLACING ITEMS ON THE QUADRANT BANDS.
------
You will notice that I don't use RESIZE METHOD anywhere in my code.And I don't use RESIZE EVENT. My code is very simple.
My SDK code AUTOMATICALLY adjusts the form AND ITS COMPONENTS right at the moment the form is created depending on the monitor resolution.
I can even parametrize the font size to make it vary with resolution... but this is not worth the trouble.
----
So, dear Edy, I'll stick to pure SDK even if it takes more time!
And thanks again for all your generous help!
Best Regards,
Leon