We are using PB 2017, however, this issue has existed in previous versions as well.
When a field in a datawindow has a ddlb edit style and is dropped down, when the MDI frame is moved the list of items in the ddlb does not move with the frame. It simply stays exactly where it was when it was dropped down.
To ensure this issue could be reproduced, I used PowerBuilder's Tempate Application with pretty much all default values (I changed the default name) to create a new MDI app. When it was finished, I created an external datawindow with one string field and assigned a ddlb edit style with two items to the field. I then added the datawindow to the base sheet object and ran the app from the IDE, A window was opened and the ddlb dropped down. When the MDI frame was moved, the ddlb was left behind.
I also added a ddlb control directly to the base sheet. When the MDI frame is moved, it collapses.
Has anyone else noticed the same behaviour? And more importantly, is there a way to have the ddlb collapse when the MDI frame moves, similar to the behaviour when the actual window is moved?
Thanks for your help
Aubrey
The value for WM_ENTERSIZEMOVE is 561, so the code will look like this:
// Window - other event
// This traps the event WM_ENTERSIZEMOVE as sent by Windows. It trips as soon as you click to move/resize the window
if message.number = 561 then // capture event - Begin Size/Move
// close the DDLB here (either direct, or call a function or trigger an event)
end if
Once again, thank you very much Brad,
Aubrey
That being said, below is the solution I have put together. I would be very happy to hear if there are any issues/improvements with implementing this code that I have not thought of. And as usual, it could be modified to include other messages where appropriate. All of the changes are made within the MDI Frame object. Here we go (The solution was edited September 26, 2017 at 08:40 Pacific to simplify it:
Global Function:
SUBROUTINE keybd_event( int bVk, int bScan, int dwFlags, int dwExtraInfo) LIBRARY "user32.dll"
Instance Variables:
Constant Integer VK_F4 = 115 // Constant used to send the F4 Up Key command
Other Event:
// Trigger the appropriate user defined events when WM_ENTERSIZEMOVE is received
CHOOSE CASE message.number
CASE 561
TriggerEvent('ue_wm_EnterSizeMove', wparam, lparam)
End Choose
ue_wm_EnterSizeMove New Event
// If focus is on a field in a datawindow that has an edit style of ddlb or dddw,
// and if the ddlb/dddw is dropped down when the MDI frame is moved/resized,
// the dropped down portion does not move with the MDI frame.
// The F4 Key Up command collapses the droped down ddlb/dddw resolving this issue.
GraphicObject Which_Control
Window ActiveSheet
DataWindow dw_Which
String ls_Column
String ls_Style
// Determine the Active Sheet. If a sheet is not active, the ddlb/dddw issue doesn't exist,
// so we do not need to do anything
ActiveSheet = This.GetActiveSheet()
If IsValid(ActiveSheet) Then
// Issue the F4 Key Up, if appropriate.
Which_Control = GetFocus()
CHOOSE CASE TypeOf(Which_Control)
CASE DataWindow!
dw_Which = Which_Control
ls_Column = dw_Which.GetColumnName()
ls_Style = dw_Which.Describe(ls_Column + ".Edit.Style")
// If the field with focus has an edit style of ddlb or dddw,
// issue the F4 Key Up to collapse the dropped down portin.
If ls_Style = 'dddw' or ls_Style = 'ddlb' Then
dw_Which.SetFocus()
dw_Which.SetColumn(ls_Column)
// keybd_event( VK_F4,0,0,0 ) // F4 key down
keybd_event( VK_F4,0,2,0 ) // F4 key up
End If
End Choose
End If