Hi Lutz,
This method search windows opennend from VFP and test if it's messagebox (class is #32770) or not.
MartinaJ
>Hi Martina,
>
>Nice. Do you do this by default, or do you need to know if the MB is open?
>
>Lutz
>
>>Hi,
>>
>>Messageboxes are not problem:
>>
>>
>> PROCEDURE DirectCloseMessagebox()
>> LOCAL ARRAY laWind(1)
>> LOCAL lnCount,lii,lcCaption,liOwner,lcClass,liLen
>>
>> lnCount = AWINDOWS("laWind",1,_VFP.hwnd)
>> FOR lii=1 TO lnCount
>> lcCaption=GetWindowTextEx(laWind(lii))
>>
>> liOwner=GetWindow(laWind(lii),GW_OWNER)
>> IF _VFP.hwnd=liOwner
>> lcClass=SPACE(254)
>> liLen=GetClassNameA(laWind(lii),@lcClass,LEN(lcClass))
>> IF liLen>0 AND LEFT(lcClass,liLen)=="#32770"
>>* debugout lcCaption+" "+TRANSFORM(laWind(lii),"@0")+" "+TRANSFORM(liOwner,"@0")+" "+lcClass
>> SendMessage(laWind(lii), WM_CLOSE, 0, 0)
>> ENDIF
>> ENDIF
>> NEXT
>> ENDPROC
>>
>>
>>
>>MartinaJ
>>
>>>>Thanks. Sounds like a similar situation. I'll see whether a similar solution will help.
>>>>
>>>>Tamar
>>>
>>>The most important is, that the
stucked code where the modal form is called must run to end before the form closes. It will not run while the form is closing or in queryunload. So, if one closes the form, the code is left in a undefined state. Cursors, for example, are gone.
>>>
>>>For that you need to go back to the event loop, and recall the closing after a while. If you see a different way to end the method out of queryunload let me know, now it's awkward and looks slow.
>>>OTOH I use this to close report preview as well. Form knows about active preview and how to kill it. Messageboxes remain a problem.