I remember reading awhile ago about a way to intercept the messagebox function? If i remember correctly you were able to define a new format and specify a title if one did not exist.
We have literally hundreds of messebox function calls throughout our programs. What im looking for is a way to modify the looks of the messagebox function without going into each form and modify each individual messagebox function call.
You can't intercept a window natively in VFP. Because it requires callback function and you need a wrapper for that. There are several customizable "MessageBox API" wrapper at UT, also a "VFP Callback" wrapper if you want to search.
The only way to do it from VFP is using TIMER. But you can still see the window flashing for a moment.
Here is the example to change MessageBox position. Modify the code to suit your needs :
Local lcTitle, loSetPos
Define Class SetPos as Timer
Interval = 10
Enabled = .F.
cTitle = ''
Procedure Init
Declare Long FindWindowEx in User32 ;
Long hwndParent, Long hwndChildAfter, ;
String lpszClass, String lpszWindow
Declare Short SetWindowPos in User32 ;
Long hwnd, Long hWndInsertAfter, ;
Integer nHorz, Integer nVert, ;
Integer nWidth, Integer nHeight, Long nFlags
EndProc
You may want to think about creating your own message box class at this point. You would still have to go through and change all the current messageboxes to your class, but next time you wouldn't.
MESSAGEBOX() is pretty much a wrapper for the OS's message box. There isn't any sort of 'intercept' for it, and you can't change the appearance of it other than through API calls or Control Panel which would change message boxes globally for the OS.
I actually found the article i was referencing in my first partially cryptic post. However the problem is i can't get it to work. It's from the FoxPro advisor's February 2003 edition.
The above is a quick rundown of how the code is laid out. However it does not work. Im assuming when it says standard header file i can add the define to any of our existing <filename>.h files???
Although the current messagebox function can accept different data types (date, etc.) I still prefer this method. However, mine are contained in a method of one of my main classes so it is referred to as:
IF goMyApp.YESNO("Is this Helpful?"
goMyApp.Info("Cool"
ELSE
goMYApp.Stop("Ouch"
ENDIF
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.