Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Paul Culbertson
  Where is Paul Culbertson?
 Katy
 Texas - United States
 Paul Culbertson
 To: Terrence Ho
  Where is Terrence Ho?
 Hong Kong
 Hong Kong
 Terrence Ho
 Tags
Subject: RE: Shortcut Menu RightClick on a TreeView Problem
Thread ID: 310 Message ID: 347 # Views: 2 # Ratings: 0
Version: Unknown Category: General VFP Topics
Date: Wednesday, May 23, 2001 3:56:23 PM         
   


> > > > > Waoooo.... Cool Site indeed !!
> > > > >
> > > > > Hi,
> > > > >
> > > > > I have defined a TreeView (SP5) on a Form, also defined a Shortcut Menu, due to the TreeView has no RightClick Method, therefore, I added the code to the MouseDown as follow : -
> > > > >
> > > > > IF BUTTON = 2
> > > > > DO myShortcut.mpr
> > > > > ENDIF
> > > > >
> > > > > It works, but when I RightClick one of the Nodes, then RightClick the other node, the Shortcut can not automatically deactivate, I must (Left) Click one node or some place, the Shortcut then got normal.
> > > > >
> > > > > How can I solve this or any other way to define RightClick on a TreeView?
> > > > >
> > > > > Thanks in advance.
> > > > >
> > > > > Terrence
> > > >
> > > > Hey Terrance,
> > > >
> > > > I don't know about the mpr. I created my shortcut programmatically and it works fine.
> > > >
> > > > try the following basic steps:
> > > >
> > > > 1. place this code in the mousedown event of the treelist
> > > >
> > > > if button=2
> > > > thisform.dopopup()
> > > > endif
> > > >
> > > > 2. create a method in the form called dopopup.
> > > > 3. place this code in the forms new method called dopopup
> > > >
> > > > SET SHADOW ON
> > > >
> > > > DEFINE POPUP treepopup ;
> > > > FROM MROW(), MCOL() ;
> > > > MARGIN ;
> > > > shortcut
> > > >
> > > > DEFINE BAR 1 OF treePopup PROMPT 'Test Right Click Popup'
> > > > *** you can define other bars interactively or simply add here
> > > > ** i have been adding them from a table
> > > >
> > > > ON SELECTION POPUP treepopup _SCREEN.ACTIVEFORM.treepop(BAR())
> > > > ACTIVATE POPUP treepopup
> > > > RELEASE POPUP treepopup
> > > >
> > > > 4. next add another method to the form called treepop
> > > >
> > > > 5. last add the following code to the treepop method
> > > > LPARAMETERS tnbar
> > > >
> > > > ** this case statement can be expanded to do the different functionality of each menu item
> > > > do case
> > > > case tnbar=1
> > > > endcase
> > > >
> > > > DEACTIVATE POPUP gridpopup
> > > >
> > > > Please note that credit is given to the TasTrader Sample in the Visual Foxpro Samples for the basis of this functionality. Code was modified to be used a little more generically.
> > > >
> > > > Paul Culbertson
> > > >
> > > > Houston, TX
> > > >
> > >
> > >
> > > Thanks Paul,
> > >
> > > It works fine if the Form run on the VFP Command Window, but the problem happened when the Form run inside a Top-Level-Form. And my Shortcut is defined by VFP Menu Wizard.
> > >
> > > Terrence
> >
> > Hi Terrance...again,
> >
> > I use the code in a top level form and it works fine. I am suggesting not to use the menu wizard.
> >
> > I can't help you with information with the menu builder because i don't use it. What functionality does your sc menu have that my method won't work for you.
> >
> >
> > Paul Culbertson
> >
> > Houston, TX
> >
>
>
> Paul,
>
> I have tried your suggestion, ran the TreeView Form in a Main Top-Level-Form with a coded Shortcut Menu, it's still have problem, the Shortcut can not self deactivate, I have put a WAIT command before the shortcut in order to test it, I found the first Click was function (it WAIT, then shortcut prompted), but thereafter, every click on the nodes seems has no response (because no WAIT command responded), until I clicked some other place outside the nodes then back to normal.
>
> Finally, I don't know why, I defined the TreeView Form as Top-Level-Form, and running in the Main Top-Level-Form, it become normal, works fine.
>
> Normally, I should define that TreeView as 1. In-Top-Level, and running on a 2. Top-Level-Form, Will there be any unpredictable problem if run two Top-Level-Form at the same time?
>
> Thanks a lot.
>
> Terrence

Terrence,

I think the problem that your seeing is not really a problem with your code but just the way a menu works in VFP. As everybody knows that menus are not object oriented and don't behave so. From what your describing it is hard to know exactly what is wrong but I was just testing again and I did notiece that once i right clicked then the menu was activated. It did although release when 1 i selected an item in the menu or 2 selected anywhere else on the form or treelist with either a right click or left click. Then right click again and menu appeared.

Menus are somewhat like a minature modal form waiting for a response once activated. if you want the node in the treelist to become selected with the right click then do the menu you must issue a dodefault in the mousedown event of the tree control:

*** ActiveX Control Event ***
LPARAMETERS button, shift, x, y

dodefault(button, shift, x, y)

if button=2
thisform.dopopup()
endif

hope this helps.


Paul Culbertson

Home of the Visual FoxPro Experts

Houston, TX


ENTIRE THREAD

Shortcut Menu RightClick on a TreeView Problem Posted by Terrence Ho @ 5/22/2001 1:49:32 PM
RE: Shortcut Menu RightClick on a TreeView Problem Posted by Paul Culbertson @ 5/22/2001 2:10:08 PM
RE: Shortcut Menu RightClick on a TreeView Problem Posted by Terrence Ho @ 5/22/2001 2:47:29 PM
RE: Shortcut Menu RightClick on a TreeView Problem Posted by Paul Culbertson @ 5/22/2001 4:47:32 PM
RE: Shortcut Menu RightClick on a TreeView Problem Posted by Terrence Ho @ 5/23/2001 2:29:53 PM
RE: Shortcut Menu RightClick on a TreeView Problem Posted by Paul Culbertson @ 5/23/2001 3:56:23 PM
RE: Shortcut Menu RightClick on a TreeView Problem Posted by Terrence Ho @ 5/24/2001 11:16:49 AM