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

i want my application to be on top always 2

Status
Not open for further replies.

mejiaks

IS-IT--Management
Jun 9, 2003
131
HN
i have been facing some issue with a time attendance applciation i developed recently.

the last problems were not related to the application it self but with some errors outside the aplication.

since this is a finger print recognition application, the application must have to be on top of evrything else, and in theory this is the only application that runs on the computer.

but from time to time, an error (diferent everytime) is showing on the desktop and infromt onf my aplication. it is OS related not VFP related.

what i want to do is from time to time, check if my application is on top of everything else on the windows desktop, if not, bring it on top thus the people wont see the OS error and keep registering on the tme attendance app, otehr wise if the see the OS error, they just dont register their fingerprint

i do not want to take care of the OS errors, i am looking for a snippet to bring my app on top of everything

any thoughts?
 
System (OS) errors should be remedied. Period. If your underlying OS is having errors, how can you (or your users) have any confidence whatsoever that your application will succeed in whatever it is doing or trying to do?

That said, system (OS) error messages are typically "System Modal". That means "always on top of everything else at all times no matter what". I believe there's a way to make your application "System Modal" as well, but what happens when you have two things that are "System Modal"? Which one is on top? Since they're both supposed to always be on top, who wins? Do they duke it out in a fistfight in the alley behind the billiards parlor?

Your real answer is fix the OS error.
 
i undesrtand what you are saying.
and we will fix the OS issues.

in the mid time i am pretty sure there is some APIs to access windows on the desktop and bring my app on top
any one?
 
I'm not completely sure what you want to achieve, or why (I agree with Dan that it's not usually desirable for an application to reserve "always on top" for itself).

That said, the way to bring your application to the front of all other windows is like this:

Code:
DECLARE INTEGER SetForegroundWindow IN WIN32API INTEGER
SetForegroundWindow(thisform.HWnd)
CLEAR DLLS "SetForegroundWindow"

If you do that in the main form's Init, that will do the trick. Alternatively, run it at startup time from your main program, but in that case use _screen.Hwnd rathr than thisform.Hwnd.

But that won't prevent the user or system bringing other application to the front later on. The only way I know to deal with that is to put the above code in a timer, and fire it every so-many seconds. But I stress that this is not a well-behaved thing to do, and I wouldn't encourage it unless you are sure you have a good reason.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Yeah and the other problem with SetForegroundWindow(thisform.HWnd), of course, is it may call the form to the front but it STILL won't be on top of a System Modal system error message.
 
For the benefit of the knowledge let us understand what I'm trying to achive


This is a Time Clock Attendance App.
This is a normal computer running Windows XP SP3
The applications Runs 24 hours a day 7 days a week
Of course it has a timer, cause running 24/7 needs to do some "refresh" on certain controls

Now, here's the deal:
Sometimes an err ocurrs outisde of the app. And a window with an error displays in front of my application. This has only happened twice.

Due to this, when employees see anything else other than the aplication they say: ERROR and do not register their punch.

But if you click back on the window of my app, it gets focus and keep working normally.

I know we have to address the OS errors and we will.

Now, meanwhile , if this happen on night shift, no IT personnel is present to click back on the app to get the focus again.

What I want is check on the Timer if my app is on top of everything and if not, bring it on top of everything.

I also know that if anything else , any of the other windows , is modal, this won't work. But like I said, the last two times it happen, they were not modal cause I click on my app and it got the focus and came on top

I hope this clarifys
 
Write an app that continuously uses the Win32 EnumWindows() function with a callback (you'll have to do this in a 32-bit DLL) to see if there are any windows which appear with coordinates somewhere overlaying your window, find the DC and paint onto your DC buffer which you then write to disk (to capture the print screen of that window's contents). Then send a VK_RETURN keystroke to dismiss the modal window and let it keep going.

You can Google how to do this as there are similar issues others have had. You can look on Monday at my fbxsim repository on GitHub for how to write a VFP 32-bit DLL if you like. I can also post the code for EnumWindows if you like.

Best regards,
Rick C. Hodgin
 
mejiaks said:
What I want is check on the Timer if my app is on top of everything and if not, bring it on top of everything.

I've already given you the answer to that.

In more details:

1. Create a new timer.

2. Set its Interval to a small amount, say, 5000 ms.

3. Take the code I showed you, and put it into the Timer event. Change the reference to thisform to _Screen.

The code doesn't check that the application is always in front, but it nevertheless always brings it to the front. Most of the time, this will have no visible effect. But if the error message happens to be in front when the timer triggers, your app will come to the front, which is what you want. At worst, the user will only have to wait 5 seconds for that to happen.

As Dan says, that won't help you if you there is a system modal message active. But the vast majority of error messages from Windows and from applicalations are not system modal.

I think this should solve your problem.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Mike

yes, your APPI is what i was looking for. i m sorry i didnt said so. my last post it was just to have all the context perfectly clear.

thanks a lot for all the comments and help
 
Glad we finally nailed it down, Mejiaks.

This thread has shown that Microsoft Windows really isn't the best environment for this kind of application. What you really want is for your time clock module to be to have total control of the device that it's running on. That was relatively easy to do in DOS, but it's not really the Windows way of doing things. Maybe the ideal solution would be a dedicated time clock that somehow interfaces to your system. But that probably goes much further than you want to.

At least you have a working solution now.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Actually, Mike, there's a way to replace the standard Windows shell with one of your making. It's a feature designed for making "kiosk" applications.

That's what runs airport departure/arrival monitors in many places, for instance. But even then, system error messages may still pop up. I've seen the Windows GPF dialog on malfunctioning airport monitors before. <g>
 
Dan,

You're right. "Kiosk" was the word I was looking for.

Talking of airport monitors, I've got a photo taken at London Gatwick airport of a monitor showing the blue screen of death. Doesn't exactly inspire confidence for those about to board a flight.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Well, software developers wouldn't naturally have much confidence anyway eh?

A while back I was having dinner with some mutual friends when the topic of automobiles that park themselves came up. Everyone at the table, having spent a career in software, agreed there's no way they'd let a car park itself. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top