1. Edinson Nongrados
  2. PowerBuilder
  3. Wednesday, 21 April 2021 09:25 AM UTC

Good morning,

How can i do this ? When i open my Powerbuilder app it's shows on the first monitor after that i move the app on the second monitor, and closed it.

 

I want that the next time i open the app it appears on the second monitor.

 

i'll waiting for your answers!

Have a nice day.

Accepted Answer
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 21 April 2021 12:26 PM UTC
  2. PowerBuilder
  3. # Permalink

This app is a good example of recording and restoring window position and size. It also has code that will move the window to the main screen if the second screen becomes disabled.

https://www.topwizprogramming.com/freecode_pbeditor.html

 

Comment
  1. John Fauss
  2. Thursday, 22 April 2021 04:46 AM UTC
I'm afraid I have to disagree, Roland. According to Microsoft's WinAPI documentation (URL follows), the type definition HANDLE (a generic handle) is a PVOID, and PVOID is defined as *void (pointer to any data type). Thus, all handles are the same size as memory pointers, so in a 64-bit process all handles are 64-bit. Type definitions for specific handle types (HCURSOR, HICON, HBITMAP, HMONITOR, etc.) are all defined as HANDLE, aka PVOID, aka *void, so Longptr is the ideal PB datatype to use for both Windows handles and memory pointers in both 32-bit and 64-bit.



https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types

  1. Helpful
  1. Roland Smith
  2. Thursday, 22 April 2021 17:22 PM UTC
Interesting. All my examples work in 64bit using long. I just created a simple app with a window that has a button and listbox. The button has this:



Longptr pWindow

pWindow = Handle(Parent)

lb_1.AddItem(String(pWindow))



I generated 32bit and 64bit exes. The 32bit handle is 6 digits and the 64bit handle is 7 digits.



I checked the IDE Browser window and the Handle function is defined as returning longptr despite what the help file says. I guess technically they should be longptr but in practice long will work in most cases.



Thanks for pointing this out.
  1. Helpful
  1. John Fauss
  2. Thursday, 22 April 2021 18:01 PM UTC
No problem. I think using Long works in many (but not all) cases because the handle values rarely, if ever, exceed the capacity of a 32-bit integer... at least in what I've seen to date when examining handle values in 64-bit processes. I wish Appeon would correct the Handle PowerScript tunction to return Longptr instead of Long.



I'm a little surprised you don't run into runtime errors due to inconsistencies in the amount of data passed on the execution call stack between PB and Windows, however.



The size of a WinAPI structure that contains a handle increases when moving from 32-bit to 64-bit because the size of the structure element that contains the handle increases. Padding within the structure to align members may also be affected. This was really brought home when attempting to use a FLASHWINFO structure with the FlashWindowEx API function in a PB 64-bit application, so I used it as an example in my tutorial series about using the Windows API from PowerBuilder.
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 21 April 2021 09:59 AM UTC
  2. PowerBuilder
  3. # 1

I haven't tested but you could record the x, y position of your main window. Then when reopening your application use this info to reposition it to you second monitor.

Andreas.

Comment
  1. Matt Balent
  2. Wednesday, 21 April 2021 12:00 PM UTC
Depending upon the version of PB you are using and the resolution and size of the monitor, you may exceed the maximum value of an integer in PB. (Latest PB version uses a long so there isn't an issue). Just something to keep in mind...
  1. Helpful
  1. Andreas Mykonios
  2. Friday, 23 April 2021 07:44 AM UTC
You are right.

Andreas.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.