1. Scott Gorke
  2. PowerBuilder
  3. Friday, 22 January 2021 19:45 PM UTC

Using PB 2019 R2 build 2353

We built a C# .NET screen to be used by both our Powerbuilder and C# .NET WPF applications.

I wrote in C# .NET a function that takes 8 arguments (all strings) and returns 1 string. The function uses those arguments to open and populate the C# .NET screen. Then I used PB's ".NET DLL Importer" to create an NVO which uses that function.

CODE:

nvo_powerbuilderfunctioncall lnvo_pb
string ls_string
DotNetAssembly ldna
DotNetObject ldno
long li_rc

lnvo_pb = create nvo_powerbuilderfunctioncall

If IsValid(lnvo_pb) then
    ldna = create DotNetAssembly
    li_rc = ldna.LoadWithDotNetFramework(lnvo_pb.is_assemblypath)
    ldno = create DotNetObject
    li_rc = ldna.CreateInstance(lnvo_pb.is_classname, ldno)
    ls_string = ldno.CallCSharpDotNetFunction(as_str1, as_str2, as_str3, as_str4, &
        as_str5, as_str6, as_str7, as_str8)
else
    ls_string = "FAIL"
    return -1
end if

destroy lnvo_pb
destroy ldno
destroy ldna

PROBLEM: when I run my app in PB and call this function, the C# .NET window opens with the arguments populating its fields. But as it opens, PB resizes itself - the app is resized (but not all the objects within the app), and when I close the app and return to PB, PB itself is resized, and looks silly. The only way to get PB back to normal is to close and restart it.

I'm going to look at any losefocus events in my frame and sheets to see if I can find a cause. Any input you guys have is welcome. Thanks!


 

Attachments (2)
Accepted Answer
Scott Gorke Accepted Answer Pending Moderation
  1. Tuesday, 26 January 2021 21:06 PM UTC
  2. PowerBuilder
  3. # Permalink

We found a workaround. We found that if the Windows 10's Windows Settings are set so "Change the size of text, apps, and other items" is set to 100%, the issue is resolved. (Mine was at 125%.) According to my manager, this is a recurring problem with some of our C# .NET WPF XAML windows, and that someone in my company might be able to supply a programmatic resolution, so it's likely not a PowerBuilder issue.

 

Thanks for reading!

Comment
  1. Armeen Mazda @Appeon
  2. Tuesday, 26 January 2021 22:52 PM UTC
Thanks for the info, and glad you have a workaround.
  1. Helpful
  1. Scott Gorke
  2. Friday, 26 February 2021 21:18 PM UTC
Thanks Armeen.



Furthermore, we discovered that if we open the properties of the PB190.exe, and change its high DPI settings to override high scaling DPI, and set the scaling to "System", then Powerbuilder and the app I'm working on both retain their original size when opening the C# .NET window.
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Friday, 26 February 2021 23:18 PM UTC
Thanks for sharing this important finding. I have passed it on to our product management team.
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.