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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

control in the forms by procedure

Status
Not open for further replies.

ameedoo3000

IS-IT--Management
Joined
Sep 20, 2016
Messages
241
Location
EG
hi all
i designed shortcut and need to write procedure or command to control in my form . how that?
 
Sorry, but my response is the same as when you asked this question earlier: It doesn't make sense.

I hope someone else here understands what you are asking and will be able to give you a solution.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
ok
my question is ( how can i call my "form1" from the procedure or command )
Untitled_n1c0mi.png
 
i want to do that
1_ef6g67.png

2_mwsbbh.png

what is the code to do that ( command / procedure )
 
OK, it looks like the root of your problem is that you are trying to execute a command from a menu, and that command contains THISFORM. Is that right?

If so, as you have discovered, you can't reference THISFORM from a menu. The solution is to store an object reference to the form in a variable, and then use that variable to address the form.

So in the code that creates the menu:

[tt]loForm = THISFORM[/tt]

Then, in the menu command:

[tt]
loFor.HideGrid() && or whateve method or property you want to address[/tt]

Does that answer the question?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
To be more specific,when I say "So in the code that creates the menu:" .....

Somewhere you have a [tt]DO ....MPR[/tt] (probably in a right-click event somewhere). It is in that code that you place [tt]loForm = THISFORM[/tt]. However, you need to make sure loForm stays in scope, so you will probably need to declare it as PRIVATE:

Code:
PRIVATE loForm
loForm = THISFORM
DO MyMenu.MPR

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Yes, that's what I want
but there is a problem !
4_i0m6zm.png

5_d31fo5.png
 
You named the variable loForm but your menu code references loFor. See the typo?

It may be more generic if you use _Screen.Activeform instead.
 
Excuse me
There was an error in the code and it was modified
modified (loFor.HideGrid) to (loForm.grd_23.Visible = .F.)
Thank you very very very much my dear Mike.
 
Well, I'm glad it's working now, but I do wish you had been clearer in explaining the problem in the first place. It would have saved as all some time, and a lot of guesswork.

By the way, the resolution does not depend on your setting the grid's Visible to .F. rather than calling a method called HideGrid. The issue was as Dan pointed out: a simple typing error in the name of the variable. (And Dan is also correct about using _Screen.ActiveForm.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
yes . many thanks for you my dear Mike .Now it is ok.
I learned a lot and a lot from this wonderful forum.
Thank you very much and to all your dear friends.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top