Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid & Memo and other problems...
Message
De
11/06/1999 11:54:01
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00227549
Message ID:
00228825
Vues:
23
>Hi Dragan,
>
>>I'm in charge of such decisions over here, so this grid of ours gets built at runtime, using AddObject(cColumnName, "ColumnClass") - and this column class is
>
> How you define cColumnName?

nColumnCount = this.columncount+1
cColumnName="Column"+allt(str(nColumnCount))

>defined in a .prg, so it has different defaults regarding the default control and its
>
> I am new here. I always created my classes visually, so could you give me a little more example here - how this prg should call, invoke, etc. I understand,
>that I still can create this class visually, then copy code from ClassBrowser.
>And am I right that I need to create class based on textbox, just in DblClick event and in KeyPress on Ctrl+Home have this code:

There's this prgclasses.prg which I "Set Classlib to prgclasses.prg addi" in the addobject of the grid class which defines a column class called FColumn, and it goes something like this (I've omitted some confusing details):
define class fcolumn as column
	ColumnNumber=0
Proc init
Lpara pnColumnNumber
	if empty(pnColumnNumber)
		pnColumnNumber=this.parent.columncount+1
	endif
	this.removeobject("header1")
	this.addobject("header1","fheader")
	this.columnNumber=pnColumnNumber
EndProc

EndDefine

Define class fheader as header

procedure click
* this grid is used in a form which always has a HeaderClick custom method:
thisform.headerclick(this.parent.columnnumber)
endproc

enddefine
You see, in this example the sole purpose of a custom column object is to equip it with a custom header instead of the standard header, so this header has some custom code defined on class level. Can't subclass columns and headers visually, so I did it this way.

>
> MODIFY MEMO
>
> How can I decide when I need to put NOEDIT here - it depends on READONLY property of the parent object...

So in the parent object's dblclick event you should have

lcNoEdit=iif(this.readonly, "noedit", "")
modify memo alias.memofield &lcNoEdit

> Could you also suggest something about SetFocus problem?

Can't remember the problem :). Like someone said, "my memory is one byte long". Aaaah... now I remember. Did you check what's thisform.activeobject.name? Put a breakpoint in the button's When event (or just a Wait Window thisform.activeobject.name) and see if it's the button itself, or the previously active object. If it's the previous object, you can have a custom property (on the form, or in the button - but then you must design this button as a class, and add the property at the class level) which will keep the referrence to this LastActiveObject. If (and only if) it is the old object and not the button itself, you can

* button.when
thisform.LastActive=thisform.activecontrol

* button.lostfocus

thisform.LastActive.Setfocus
nodefault

If this doesn't work, then your method of having each control report itself to the form when it receives focus (and do thisform.LastActive=this in its .gotfocus) should be the way to go. You should keep couple of things in mind:

- release the referrence else the form won't close:
* form.unload
this.LastActive=.null.

- the button itself should never report itself to the form as the LastActive, else you're back at square one

Alternative solution would be to put the button on a toolbar - that way it never actually receives focus, so the focus remains on the control where it was.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform