Alaska Software Inc. - 2 Ways 1 CRASH without Errorsys or XppFatal
Username: Password:
AuthorTopic: 2 Ways 1 CRASH without Errorsys or XppFatal
Jim Lee2 Ways 1 CRASH without Errorsys or XppFatal
on Tue, 13 Feb 2018 06:27:56 +0100
when ComboBox have focus you can open dropdown list with F4

i do have a XbpPushButton to activate

   oDlg:oPBtarget:activate  := {|| oDlg:OpenTargetDir(.F.)  }

i also have a Hotkey ALT_T

   CASE nEvent = xbeP_Keyboard .AND. mp1 == xbeK_ALT_T
        oDlg:OpenTargetDir(.T.)

METHOD SaveDlg:OpenTargetDir(lShow)
   SetAppFocus(::oCombo)
   PostAppEvent(xbeP_Keyboard,xbeK_F4,,::oCombo)



Problem : it work when press XbpPushbutton() but it CRASH with Hotkey 
without Errorsys or XppFatal ?!

now you can see i pass a Parameter as workaround

   IF lShow
      msgbox("workround")
   ENDIF

i have try

  PostAppEvent( xbeP_Activate,,,oDlg:oPBtarget)

  SendMessageA()
  keybd_event()
  SendInput()

but it always CRASH without workaround ... why ?

i include Demo Source.
compile  link it and start App without  with (any) Parameter to see CRASH





COMBO_F4.ZIP
Andreas Gehrs-Pahl
Re: 2 Ways 1 CRASH without Errorsys or XppFatal
on Tue, 13 Feb 2018 04:48:49 -0500
Jimmy,

Instead of using PostAppEvent(), you should simply drop down (or close) the 
ListBox directly.

Change your :OpenTargetDir() method to:

Method SaveDlg:OpenTargetDir()
LOCAL lDropDown := ::oCombo:ListBoxFocus()
   SetAppFocus(::oCombo)
   ::oCombo:ListBoxFocus(.not. lDropDown)
return

BTW, the program doesn't crash, it simply ends, because an xbeP_Close event 
is created, which sets lExit to .t. and ends your event loop.

The reason for the xbeP_Close event being created, is that you post an F4 
keyboard event, which is handled asynchronously (internally to and) by the 
ComboBox, before the ALT_T keyboard event had been (completely) processed. 

This causes the ALT Key State flag to be (still) set when the F4 keyboard 
event is created. That in turn causes the F4 to be interpreted as ALT_F4, 
which (again asynchronously/internally) is interpreted as a Close Event.

As a workaround, you could remove the ALT Flag, before posting the F4 key, 
using something like this in your :OpenTargetDir() method:

if AppKeyState(xbeK_ALT, APPKEY_GET_PRESSED) == APPKEY_DOWN
   AppKeyState(xbeK_ALT, APPKEY_SET_PRESSANDRELEASE)
endif
PostAppEvent(xbeP_Keyboard, xbeK_F4, , ::oCombo)

But using :ListBoxFocus() instead of posting events, seems much more 
efficient to me (and it produces much fewer side effects).

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC
Jim LeeRe: 2 Ways 1 CRASH without Errorsys or XppFatal
on Wed, 14 Feb 2018 04:32:25 +0100
>  you should simply drop down (or close) the ListBox directly.
>
> Method SaveDlg:OpenTargetDir()
> LOCAL lDropDown := ::oCombo:ListBoxFocus()
>   SetAppFocus(::oCombo)
>   ::oCombo:ListBoxFocus(.not. lDropDown)
> return

i used F4 while it is the Windows Way but o:ListBoxFocus(.T.)  to open is 
much better

> BTW, the program doesn't crash, it simply ends, because an xbeP_Close 
> event
> is created, which sets lExit to .t. and ends your event loop.

hehe ... i have not check this with debugger

THX for help