1. Ian Wells
  2. PowerBuilder
  3. Tuesday, 29 December 2020 18:12 PM UTC

Hi All,

I am using PFC. I have many response windows in my app (inherited from w_response), but only 1 of them I need to allow the user to resize the window. 

I have googled and found answers to this problem (e.g. Bruce A's of_setresizeable function) and other answers, but they all seem to use variables I don't know the definition of or value of (e.g. in Bruce's response from Nov 2012, it mentions GWL_STYLE).

The window has a number of resizable objects on it and does not have a control menu (picture attached). 

I just want to give the ability for this single response window to be resized. Hopefully then, as I have read, the PFC resize service will adjust the size of my controls if I register them correctly.

With your help I'd like some self-contained code I can paste into my window's Open event (and possibly some external functions)

I don't mind adding the ControlMenu if need, as PFC handles it the same as pressing the Cancel button.

Would be great to have Min/Max controls, but that (as they say) "would be the gravy!"

Thanks in advance for your help.

 

Attachments (1)
Accepted Answer
Ian Wells Accepted Answer Pending Moderation
  1. Tuesday, 29 December 2020 21:39 PM UTC
  2. PowerBuilder
  3. # Permalink

Thanks for all your help. It works great!

I just did the quick version. If the customer comes back with needing it on some other response windows, or min/max buttons, I'll look to implement the of_setresizeable function.

For now I just added these lines to Local External Functions:

function long GetWindowLongW (long hWindow, integer nIndex) Library "user32.dll"
function long SetWindowLongW (long hWindow, integer nIndex, long dwNewLong) library "user32.dll"

and these lines to my window's Open event:

//Register the objects with the resize service.
of_setResize(TRUE)

this.inv_resize.of_Register (dw_primary, "ScaleToRight&Bottom")
this.inv_resize.of_Register (cb_ok, "FixedToRight&Bottom")
this.inv_resize.of_Register (cb_cancel, "FixedToRight&Bottom")
this.inv_resize.of_Register (cb_selectall, "FixedToBottom")
//this.inv_resize.of_Register (dw_filter,"FixedToTop")


//Set this response window to resize
long ll_Styles

n_cst_numerical lnv_num

constant long WS_THICKFRAME = 262144
constant long WS_CAPTION = 12582912

ll_styles = GetWindowLongW(handle(THIS), -16)

IF ll_styles <> 0 THEN
ll_styles = lnv_num.of_BitWiseOr(ll_styles, WS_THICKFRAME + WS_CAPTION)
SetWindowLongW(handle(THIS), -16, ll_styles)
END IF

 

 

Comment
  1. Armeen Mazda @Appeon
  2. Tuesday, 29 December 2020 21:58 PM UTC
Thanks for sharing the solution!
  1. Helpful
There are no comments made yet.
Bruce Armstrong Accepted Answer Pending Moderation
  1. Tuesday, 29 December 2020 19:07 PM UTC
  2. PowerBuilder
  3. # 1

I assume you're referring to this post:

https://answers.sap.com/questions/9661757/resizable-response-window-with-control-menu.html

T
he values are:

GWL_STYLE = -16

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlonga

WS_THICKFRAME = 262,144  (40000 Hex)
WS_MINIMIZEBOX = 131,072 (20000 Hex)

https://docs.microsoft.com/en-us/windows/win32/winmsg/window-styles

MF_BYPOSITION = 1,024 (400 Hex)
MF_STRING = 0

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-modifymenua

SC_MAXIMIZE = 61,488 (F030 Hex)
SC_RESTORE = 61,728 (F120 Hex)
SC_SIZE = 61,440 (F000 Hex)

https://docs.microsoft.com/en-us/windows/win32/menurc/wm-syscommand

SWP_NOSIZE = 1
SWP_NOMOVE = 2
SWP_NOZORDER = 4
SWP_FRAMECHANGED = 32 ( 20 Hex )

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos

Comment
  1. Ian Wells
  2. Tuesday, 29 December 2020 19:15 PM UTC
Yes, that's the one I am referring to.



So Bruce, if I create the of_setresizeable function, using your code and set the constant as mentioned above, I should be able to call of_setresizeable(TRUE) from the response windows open event?



Cheers

Ian
  1. Helpful
  1. Bruce Armstrong
  2. Tuesday, 29 December 2020 19:19 PM UTC
Correct
  1. Helpful
  1. Bruce Armstrong
  2. Tuesday, 29 December 2020 19:21 PM UTC
Just a note, unlike the PFC services the boolean you are passing in doesn't turn the feature on/off. It determines if a size grip is shown in the lower right corner of the window. That is, of_setresizeable(FALSE) would still make the window resizeable, you just wouldn't see the resize grip.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 29 December 2020 18:52 PM UTC
  2. PowerBuilder
  3. # 2

Hi Ian;

  You would basically have to call some MS-Windows SDK API's to make the native PB and/or PFC response window resizable. The main API would be the "SetWindowlong" SDK command and the style would need to change to a type "262144" (thick frame).

Regards ... Chris

Comment
  1. Ian Wells
  2. Tuesday, 29 December 2020 19:15 PM UTC
Thanks Chris.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 29 December 2020 18:43 PM UTC
  2. PowerBuilder
  3. # 3

Greetings, Ian - 

The ancestor for w_response, pfc_w_response, already contains all of the PFC Resize Service-related code (from pfc_w_master), so if your response window is inherited from w_response and you "tweak" the window by using SetWindowLong, and registering the controls in the response window with the resize service, you should be all set to go.

Have you tried it?

Regards, John

Comment
  1. Ian Wells
  2. Tuesday, 29 December 2020 19:16 PM UTC
Thanks for your response John. I'll have a go soon and let you know.
  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.