Link to home
Start Free TrialLog in
Avatar of boycy
boycyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

form on top

very easy question its just I didnt have time to search for an answer
How do you, w/out API, keep a form always on top?
Avatar of woottond
woottond

use the forms lost focus property - easy way to it is open up the code, select the form, pull down the procedure list select lostfocus. When the form calls this procedure this procedure could set it back on top.
I don't really know of a way to keep your form on top of all other applications without using the SetWindowPos API call.  But you just want it to be on top of your application then you can use this:

  FormName.Show , ParentForm

This will keep it on top of your application
ASKER CERTIFIED SOLUTION
Avatar of Vbmaster
Vbmaster

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Above.
Vvmaster: Boycy does not want the API.

I gave this following comment to the other same question.

try something like this.

Form1.Zorder

Oops
The correct way of doing this (put form on top) is using the API call, a cheesy (slow and dumb) way of doing it would be to add a timer control and use AppActivate formcaption_here. ;) This will make the end user really annoyed but hell.. if the programmer is so scared about API's the programs can't be any good anyway.
I agree with Vbmaster fully.

Boycy: What's wrong with using API? Most programs the programmers make uses the API a lot. Learn how to use API.. I'd suggest that you can buy "Visual Basic Programmer's Guide to Win32 API" book by Dan Appleman, or you can check the site for beginner -- http://www.vbapi.com.
boycy,

ummmm,  Why would you not want API if that will do what you want done?

Isn't the constraint of no API like asking, "How can I, w/out a saw, saw a piece of wood in half"?

JMHO

Brian
Have a timer control in your form with the default name. Following code should help

Option Explicit

Private Sub Form_Load()
Timer1.Interval = 200
End Sub

Private Sub Timer1_Timer()
On Error GoTo Err_handler
Screen.ActiveControl.SetFocus
Exit Sub
Err_handler:
SetFocus                'There are no controls on the form.
End Sub
"w/out API"

You don't. Period.
Avatar of boycy

ASKER

I remebered seeing a way somewhere to do it w/out API.
I can use the API, its just that it would be easier to not use it
I will cerainly not use a timer to do it, that would slow everything down too much
TNX vbmaster
This is a very easy Question, so you don´t have to be on a experts Web Side
Avatar of boycy

ASKER

McFauli: if its such an easy question, can you answer it. The format of what I once saw went something along the lines of
<formname>.show vbmodal
I have tried this but it doesnt work, only makes the form not show in the taskbar
With message boxes, you can do the following:

    msgbox "prompt", vbSystemModal . . .

Which leads me to believe that through APIs you can change the modality of windows, since a message box is, after all, a window.

vbModal makes a form modal for the app to which it belongs only.

Brian
Avatar of boycy

ASKER

I dont want to do it with a msgbox, but a single form on top of ALL other windows outside the app as well
"msgbox "prompt", vbSystemModal "

Well known Micro$oft lie. The message box actually is not system modal.

"System modal" does not exist in 32-bit Windows.
caraf_g:

So what does system modal actually do?

And if there is no system modal, how is it that when you tell the machine to shutdown, you must address that dialog before you can do anythnig else?

(I'm not disagreeing, I'm curious.  What you just said doesn't seem to fit the evidence.)
"you must address that dialog before you can do anything else"

That's not true.

I think what they do is to bring up a borderless window with a half-greyed out capture of the screen on it. Then they show a little dialog on top of that.

The dialog is not system modal. Yes, you cannot use the mouse, because the borderless form in the background covers the whole desktop, but you can still use the keyboard.

Try hitting standard windows key combinations such as "windows key"+E and you'll see it still brings up Explorer.
"So what does system modal actually do?"
The same as modal. I think it's there to provide code-level backward compatibility with Win 3.x code, but that's all. It doesn't actually work as specified anymore.