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

Ms Agent it is supported in Windows 8, what else to simulate the same effect

Status
Not open for further replies.

titoneon

MIS
Dec 11, 2009
335
US
Hi Guys,
I am working on VFP 9.0 spk2 app. and i know WIn 8 won't support Ms agent, the reason i wanted it, it is just to inform the user in when an event it is successfully done or not, i know we can use something else but i am wondering if anyone knows of any other thing similar to Ms agent that can work on win 8 ?
Thanks a lot in advance
 
Balloon tips are for that since Vista. There are samples in the VFP9 samples, eg in task pane. See "System Tray Icon Example", it has a Baloon Tips tab.

Bye, Olaf.
 
Ok Guys, i will try to see how to use that
Thanks a lot
 
I just use a simple form for this sort of thing.

The form is a small top-level form without title bar or borders. It slides up from the bottom right corner of the screen, stays in place for a short time, than slides down again. The whole thing is controlled by a couple of timers. Very simple to create, and it looks effective.

I'm not sure what Desktop Alerts is, but it sounds like it could be a similar sort of thing.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,
What you did it is probably cool, can you share it with me ? so i can get a better idea ?
Thanks
Ernesto
 
Ernesto,

I published an article about it - plus code - in FoxPro Advisor. Do you have access to it? I can't off-hand tell you which edition it was in.

If you can't find it there, I'll see if I still have some code I can post here. But it shouldn't be too difficult to figure out. Essentally, you set a timer to control the sliding up and down of the form. Every few milliseconds, you move the form a few pixels higher or lower. And there is another timer that controls how long the form stays visible.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Sorry, I can't find the code for my sliding form. But an alternative would be a "fading" form. This is a form that displays a short message of some kind in the corner of the screen, that gradually fades into view, stays visible for a short while, then fades out again. It's a good way of doing an alert that is noticeable but unobtrusive.

If that's of interest, here are the steps:

1. Create a small form. Make it top-level; no borders or title bar; ShowInTaskBar = .F. Add one or more labels to display your message. Position the form in, say, the bottom-right corner of the screen.

2. Do the following API declarations (for example, in the Load event of the above form):

Code:
DECLARE INTEGER SetWindowLong In Win32Api ; 
  INTEGER HWnd, INTEGER Index, INTEGER NewVal 
DECLARE INTEGER SetLayeredWindowAttributes In Win32Api ; 
   INTEGER HWnd, STRING ColorKey, ; INTEGER Opacity, INTEGER Flags
DECLARE Sleep IN WIN32API INTEGER Duration

3. Do this in the Init:

Code:
LOCAL lnTrans

* Make the form fully transparent
SetWindowLong(THISFORM.hWnd, -20, 0x00080000)
SetLayeredWindowAttributes(THISFORM.hWnd, 0, 0, 2)

* Show the form (at this stage, nothing will appear on
* the screen, because the form is still fully transparent)
thisform.Visible = .T.

* Now gradually fade in, taking about one second to do so
lnTrans = 10
DO WHILE .T.
  SetLayeredWindowAttributes(THISFORM.hWnd, 0, lnTrans, 2)
  lnTrans = lnTrans + 10
  IF lnTrans > 255
    EXIT
  ENDIF 
  Sleep(35)    && increase for slower fading, decrease for faster
ENDDO 
	
* The form is now fully opaque

4. Add this in the Destroy:

Code:
LOCAL lnTrans

SetWindowLong(THISFORM.hWnd, -20, 0x00080000)

* Gradually fade out, taking about one second to do so
lnTrans = 255
DO WHILE .T.
  SetLayeredWindowAttributes(THISFORM.hWnd, 0, lnTrans, 2)
  lnTrans = lnTrans - 10
  IF lnTrans < 50
    EXIT
  ENDIF 
  Sleep(35)    && increase for slower fading, decrease for faster
ENDDO


5. Add a timer to the form. Set its Interval to the number of milliseconds that you want the form to remain on the screen. In its Timer event, write code to release the form. Enable the timer at the end of the code that fades in the form (point 3, above).

6. Optionally add code to release the API declares (using CLEAR DLLS). You can do this in the form's Unload.

That's all there is to it. If you want some more information, see this article:

Mike






__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,
I was searching in "Foxpro Advisor website" and could not find it, OK i will try this code
Thanks a lot for your time and advise
Ernesto
 
Hi Mike,
Why do you think, that could be happening when i running the form with the above code, and i am getting an error
on "SetLayeredWindowAttributes(THISFORM.hWnd, 0, 0, 2)"
as "too many arguments " has been passed on the line above.

I did as indicated but i can not get the fade out effect, i was testing this form w/o the above line and of course it works but does not fade out at all, i am running this in VFP 9.0 SPK 2 under windows XP 32BIT.
Thanks in advance
Ernesto
 
Ernesto,

I just noticed a small error in my code:

Code:
DECLARE INTEGER SetLayeredWindowAttributes In Win32Api ; 
   INTEGER HWnd, STRING ColorKey, [b][COLOR=#CC0000];[/color][/b] INTEGER Opacity, INTEGER Flags

You see that spurious semi-colon in the second line? That shouldn't be there. I think that will explain your error. Can you try it and report back?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,
You are correct the ";" was the problem, now let me ask you something when you said

"Enable the timer at the end of the code that fades in the form (point 3, above)."
i added "thisformTimer1.enabled = .T." just after the Enddo command
But when the little form shows, i never shows transparent, it just show and then disappear later but do not fade out as it is supposed to do it is just running and then disappears as if it gets closed after the timer, i don't want to make a big deal of this, but it is interesting for me to learn these little trick, i don't want to take your precious time getting wasted on this
Thanks a lot
Ernesto
 
i don't want to take your precious time getting wasted on this

Ernesto, please don't worry about that. I gave you some code, so it is up to me to make sure the code is correct.

The first possibility is that the form is fading in and out much too fast, so that you don't actually see the fading. To verify that, could you change the value of the parameter to the Sleep() function, in both the Init and the Destroy. At present that parameter is 35. Could you change it to 135 in both places.

The effect of this will be to make the form fade in and fade out much more slowly. If that doesn't work - that is, if the form still appears instantly and disappears as soon as the timer expires - we will try something else.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
Yes even when increase the sleep to 200 and the timer interval to 1000 still no fade in and out, it it just display longer on the screeen, like i said don't worry about that, i am happy for being answered by you.
Thanks again
Ernesto
 
Mike I got intrigued (and had some time while an excruciating SQL query ran on another PC) so I tested this. Neat trick!

But on Windows 7, I don't see a fade in either. I get a fade out. But it's different every time I run it, it seems. And then the query was done and I had other things to do.

I suspect a routine like this is going to be highly susceptible to the mysteries of video drivers and video hardware, which I enjoy dealing with ever so slightly less than printers and printer drivers. :)
 
Dan and Ernesto,

Sorry you can't get this to work. I suspect the problem might be connected with themes, or possibly with Aero (I've seen posts elsewhere from users who say it doesn't work with Aero enabled).

Ernesto, since you say you are happy with it the way it is, I won't spend any more time on it just now. But I will look into it further when I have more time. If I get any more information, I'll post it here.

Mike





__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top