Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I don't want TILE effect on my Picture
Message
 
 
À
05/05/2001 18:46:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Divers
Thread ID:
00503869
Message ID:
00504607
Vues:
22
Hi!

Late binding for VFP object events, right?

Very nice tip. Why not make a feature in VFP 7 to bind VFP code to the events of COM/ActiveX objects by the same way? I just tried to do this in VFP 7 and had no luck. For example, no way to add COM object to the VFP comntainer. When making it as aproperty of the container, I can define a method for the object assigned to thet property (!), however, cannot bind code to the COM object/ActiveX event (when can do this for VFP object).

Code example:
_Screen.AddProperty("oo")
_Screen.oo = createobject("ADODB.Connection")
_Screen.NewObject("oSH", "ScreenHook")
_Screen.oo.Open("DSNConnection","User","Password")
_Screen.oo.WillConnect("Something...")

DEFINE CLASS ScreenHook AS CUSTOM
o = _Screen.oo
PROCEDURE o.WillConnect()
lparameters pConnectionString, pUserID, pPassword, pOptions, padStatus, ppConnection
  *
  * Code to handle the main VFP screen being resized
  *
  WAIT WINDOW NOWAIT "Connecting... " + pConnectionString
ENDPROC
ENDDEFINE
Strange, but code runs without errors. WillConnect Event of the ADO Connection object is not fired by ADO. However, you can call that method directly from VFP.

I guess it is not a problem in VFP 7 to make such binding to events.

Defining a method in run-time for any object is interesting. This also gives an interesting idea to organize wrapper around 'Scatter ... Name' object in VFP. And, of course, to do some strange hooking of such objects like window defined by DEFIUNE WINDOW .. NAME, Browse ... Name etc. I guess this approach is also very valuable for grids, specially for such hooks like grid highliters ;) Note that events work even for objects assigned as a property. Example:
lcObjectPath = "_Screen.ot"
_Screen.AddProperty("ot")
_Screen.ot = CreateObject("TextBox")
_Screen.NewObject("or", "ScreenH")
_Screen.ot.Value = "Something"

DEFINE CLASS ScreenH AS CUSTOM
oRS = eval(lcObjectPath)
PROCEDURE oRS.ProgrammaticChange()
  *
  * Code to handle the main VFP screen being resized
  *
  WAIT WINDOW NOWAIT "!!!!!!!!!!"
ENDPROC
ENDDEFINE
In above code ProgrammaticChange event of the textbox fired correctly. As you see, you can make such hooks universal by passing an object to them as expression.




>>>Alexander,
>>>
>>>Thanks, that did the trick. Now all I have to do is get my JPG detail right so when it stretchs it doesn't lose quality.
>>>
>>>Thanks Again
>>>Elgin
>>>
>>
>>Elgin,
>>
>>That is good.
>>BTW, will be your screen resized? If so your background image will not be centered and you need to move it somethere in your code, maybe using timer for that.
>
>
>You don't need a timer. You can add method code for _SCREEN like this:
>
>*
>* ScreenMethods.PRG
>*
>* Fred Taylor - ElZorro 4/10/2001  www.elzorro.org
>*
>* Use the following to modify _SCREEN methods:
>*
>* For VFP6 & 7:
>*
>*     _SCREEN.NewObject("oSH","ScreenHook","screenmethods.prg")
>*
>* For VFP3 & 5:
>*
>*     SET PROCEDURE TO screenmethods ADDITIVE
>*     _SCREEN.AddObject("oSH","ScreenHook")
>*
>* Any of the main VFP screen methods can be hooked into in this manner.
>* A similar technique can also be used to hook methods of grid
>* headers, etc., at run-time.
>*
>DEFINE CLASS ScreenHook AS CUSTOM
>oScr = _SCREEN
>PROCEDURE oScr.Resize()
>  *
>  * Code to handle the main VFP screen being resized
>  *
>  WAIT WINDOW NOWAIT TRANSFORM(this.Width)+" "+TRANSFORM(this.Height)
>ENDPROC
>PROCEDURE oScr.RightClick
>  *
>  * Code to do a "shortcut" menu on main VFP screen RightClick
>  *
>  DO testmenu.mpr
>ENDPROC
>ENDDEFINE
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform