Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Override _SCREEN Methods

Status
Not open for further replies.

Irwin1985

Programmer
Feb 2, 2017
44
ES
Hi everybody,

I'd like to Override _SCREEN Events for example: Init(), Load(), Unload(), Custom Methods, etc.

I can do it in a Form like this:

Code:
oForm = CreateObject("MyForm")
oForm.Show(1)
Release oForm

DEFINE CLASS MyForm AS Form

   PROCEDURE Init
      ? "Método Init Sobreescrito"
   ENDPROC
ENDDEFINE

but, how can I do it on _SCREEN?, I suppose the answer is BINDEVENTS() but I cant make it work.

I found this sample on VFP file help:

Code:
PUBLIC oHandler
oHandler=NEWOBJECT("myhandler")
DO (_browser)
BINDEVENT(_SCREEN,"Resize",oHandler,"myresize")

DEFINE CLASS myhandler AS Session
   PROCEDURE myresize
      IF ISNULL(_obrowser) THEN
         UNBINDEVENTS(THIS)
      ELSE
         _obrowser.left = _SCREEN.Width - _obrowser.width
      ENDIF
   RETURN
ENDDEFINE

Thanks for your help...!



 
May I ask WHY you want to do this? In an exe most programmers simply hide _screen, and never show it. That's why we have Screen=Off in our config.fpw which are included in our projects. A visible _screen is only used for development.
 
I'm creating a new Ribbon builder for developers but some friends of mine uses _SCREEN instead of Top Level Form, so I must to switch between Top Level Form and _SCREEN for flexibilities.

Thanks...!
 
I found this code in my box of goodies, maybe it will give you some help.

[pre]Public ox
m.ox = Newobject([myformx])
Bindevent(_Screen, [resize], m.ox, [resize])
m.ox.Show
Define Class myformx As Form
Add Object txtURL As TextBox With Width = 400, Value = [www.msn.com], Autocomplete = 3
Add Object cmdRefresh As CommandButton With Caption = [\<Refresh], Left = 400, Height = 20
Add Object cmdBack As CommandButton With Caption = [\<Back], Left = 475, Height = 20
Add Object cmdForward As CommandButton With Caption = [\<Forward], Left = 550, Height = 20
Add Object oweb As cweb With Top = 30
Width = 800
Height = 800
AlwaysOnBottom = .T.
AllowOutput = .F.
TitleBar = 0
Procedure Init
This.oweb.Width = Thisform.Width
Thisform.Resize
This.oweb.Height = Thisform.Height - Thisform.txtURL.Height - 2
Thisform.txtURL.Valid
Procedure Resize
Thisform.Width = _Screen.Width
Thisform.Height = _Screen.Height
This.oweb.Top = 30
This.oweb.Height = Thisform.Height - 100
This.oweb.Width = Thisform.Width - Thisform.Left
Procedure txtURL.Valid
Thisform.oweb.Navigate(This.Value)
Procedure cmdRefresh.Click
Thisform.oweb.Refresh
Procedure cmdBack.Click
Try
Thisform.oweb.GoBack()
Catch
Endtry
Procedure cmdForward.Click
Try
Thisform.oweb.GoForward()
Catch
Endtry
Enddefine

Define Class cweb As OleControl
OleClass = [shell.explorer.2]
Procedure Refresh
Nodefault
[/pre]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top