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

need idea on shortcut menus

Status
Not open for further replies.

sqlpro

Programmer
Dec 30, 2003
297
NZ
Hi friends
i created a shortcut menu and i added following command in one of menu items
Code:
 _screen.activeform.menu4systray(3)

i want to execute a method in activeform but i am getting
following error
property menu4systray is not found

how do i achieve what i want.
Thanks for ur ideas.

cheers
 
Sqlpro,

The most likely explanation is either that there is no form active at the time the command is executed, or the active form does not have the method you mentioned.

You can check the first possibility by testing _SCREEN.Formcount. You can use PEMSTATUS() to check the other.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Thanks for the post Mike.
Actually there is an activeform and it has method i wanted.
only thing i did not add to my post is i am calling that
shortcut menu in systray class.I mean user clicks icon in systray then the menu popsup.
It comes up as expected but does not do what it supposed to do when user selects a menu item.
Thanks :)

cheers
 
Hi Mike
i finally i got it working.i must say ur suggestion worked :)
here is the code
Code:
#define task_scr "EXPLORETASKS"
*!*loop thr all active screen and locate our task screen
FOR lncnt = 1 TO _screen.formCount
	lcname=_screen.Forms(lncnt).name
	*!* yes we found our form
	IF lcname==task_scr THEN 
		_screen.Forms(lncnt).menu4systray(tcIndex)
		exit	&& we r done exit
	ENDIF 
       
ENDFOR
but what i could not understand was when i make build and run exe nothing happens i mean no menu popsup but it works
greatly in develop mode
can u guess why?
thanks for ideas

cheers
 
SqlPro,

Does your code have a READ EVENTS statement in it?

Without this statement, your app will not work (like you expect) at runtime.

Malcolm
 
Hi Malcolm
No it does not.
You mean i need to have it in my abv program(before exit in FOR loop)?
Thanks for ur post by the way :)

cheers
 
Hi Malcolm
I tried ur idea (Read Events) but did not work...

cheers
 
SqlPro,

Try these mods to your code.

Code:
llFound = .F.
FOR lncnt = 1 TO _screen.formCount
    lcname=_screen.Forms(lncnt).name
    *!* yes we found our form
    IF lcname==task_scr THEN 
         llFound = .T.
         exit    && we r done exit
    ENDIF 
ENDFOR

* moved after for loop exit
if llFound
      _screen.Forms(lncnt).menu4systray(tcIndex)
     read events
endif

Note: You will need to have a way to clear events in order to exit your EXE. In your form's destroy event, include a "clear events" statement so that your application can exit.

In summary:

Without the "read events" statement, your application will immediately exit. In other words, it will display your form, then continue immediately to the next statement. If the next statement is a "read events" then your VFP application will enter an event loop and stay there until a "clear events" is issued.

Without the "clear events" statement your application will never exit - it will be stuck in its own event loop forever.

The reason your original code works in the DEVELOPMENT environment is that the development environment provides a wait state ("read events") by default.

Hope this makes sense!

Malcolm
 
Thanks Malcolm
i'll try again with ur suggestion.
by the way just to let u know i included read events before
exit in my porgram but to no avail.


cheers
 
sorry for the late post.
here is my changed code.
Code:
#define task_scr "EXPLORETASKS"
LOCAL lncnt,lcname
*CLEAR EVENTS && by  Rajani on 08/04/04
*!*loop thr all active screen and locate our task screen
FOR lncnt = 1 TO _screen.formCount
	lcname=_screen.Forms(lncnt).name
	MESSAGEBOX(lcname)
	*!* yes we found our form
	IF lcname==task_scr THEN 
		_screen.Forms(lncnt).menu4systray(tcIndex)
		READ EVENTS 	&& by  Rajani on 08/04/04
		exit	&& we r done exit
	ENDIF 
       
ENDFOR
i've abv code in a prg and i call this prg in menu click event.what is funny thing is in develop mode it is going into prg and in runtime it is not even going in the abv prg at all !!
anyway just to let u know the menu is actived by a Timer event.
Thanks for Ideas

cheers
 
SqlPro,

In your main code - where your app starts, try something like this:

<your startup code>
do <yourmenu.mpr>
read events

The "read events" will place your application in a wait state and allow your menu code to respond to events.

In the code called by your menu use the following to manipulate the PEM's associated with your EXPLORETASKS form. Note that the following code block is a modified (but untested) version of your original.

#define task_scr "EXPLORETASKS"
LOCAL lncnt,lcname

*!*loop thr all active screen and locate our task screen
FOR lncnt = 1 TO _screen.formCount
lcname=_screen.Forms(lncnt).name
MESSAGEBOX(lcname)
*!* yes we found our form
IF lcname==task_scr THEN
_screen.Forms(lncnt).menu4systray(tcIndex)
exit
ENDIF
ENDFOR

Remember - you will need some code to issue a "clear events" command or your application will never be able to exit.

Typically you might place a "clear events" command in the function called by your apps (menu's) "File/Exit" snippet.

Does this help?

Malcolm
 
Thanks Malcolm
I'll give it a try and let u know :)

cheers
 
Hi Malcolm
I already have read events in main() like following
Code:
*!* adding special events to _screen to use systray class, 
PUBLIC goScreen
goScreen=ScrEvents()	&& create _screen object
BINDEVENT(_screen, "resize", goScreen, "Scrresize")
***** end
		
*!* display search screen as default screen,	
	DOFORM('exploretasks')
		IF !glDevelop
			READ EVENTS
		ENDIF
but in runtime the menu does not work.
i even added do mymenu.mpr in main() yes,it opens up the menu before loading my main screen.but it soes not open when i click systray icon.

cheers
 
SqlPro,

I'm stumped myself. Are you using a 3rd party framework or sample code from the "solutions" that ship with VFP?

I've heard that there are problems with the way MS implemented the systray menu behavior. Others on this forum are using the systray activex from bbcontrols.com. You might want to search this forum for "bbcontrols.com" and/or systray and see what comes up.

Good luck!

Malcolm
 
Thanks Malcolm
Thats what i finally decided :)

cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top