CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Thu Jul 03, 2003 6:34 am Post subject: Window Not ontop and Restore a window from any state |
|
|
Always ontop feature is very helpful if the window is small else it is equally irritating
as it obscures all other windows.Here is a piece of code(my 2 cents) to help U
1.Restore a ontop window back to normal
2.Restore any window to the top(NOT "Always ontop" he he)in VDS5 using a hotkey.
One would be wondering that window,normal would do this - Yes but only if the user has
minimized the window AND NOT if the window is just obscured by another window !.
The principle used here is use window normal in conjunction with SetForegroundWindow API
from user32.dll so that when user presses a hotkey(F6 in example) the window comes to
focus and is ready for keyboard input whatever be its inital state(even hidden) !
Enjoy.
| Code: |
#-----------------------------------------------------------------------------#
# #
# Calling a Non VDs dll and demo of some API Functions (VDS 5 ONLY) #
# #
# Author: CodeScript #
# #
# Copyright: You are free to remove this info if Using this code in your app.#
# #
#-----------------------------------------------------------------------------#
REM USE AT YOUR OWN RISK !!
REM MISTAKES MADE WHILE USING A NON VDS DLL MAY INVITE A VDS/SYSTEM CRASH.
REM SAVE YOUR WORK BEFORE RUNNING/DEBUGGING THIS SCRIPT.
TITLE NOT ON TOP Test by CodeScript
DIALOG CREATE,NOT ON TOP Test by CodeScript,-1,0,311,185,CLASS MYWIN
DIALOG ADD,BUTTON,ONTOP,24,64,189,24,Always on top,@CHR(32)Always on top
REM Note the tool tip preceded by a space character for a better look
DIALOG ADD,BUTTON,NOTONTOP,69,64,189,24,Not on Top,@CHR(32)Not on Top
DIALOG ADD,BUTTON,HIDE,112,64,189,24,Hide,@CHR(32)Hides this window
DIALOG ADD,TEXT,TEXT1,149,15,,,Use Hotkey F6 to bring this dialog to focus from any
state!!
DIALOG SHOW
Hotkey add,1,F6
:EVLOOP
wait event
goto @event()
:Hotkey
LOADLIB USER32
%H = @strdel(@WINEXISTS(#MYWin),1,1)
if %H
%H = @lib(user32,SetForegroundWindow,BOOL:,%H)
else
ERROR -1
end
FREELIB USER32
END
window normal,#MYWIN
goto EVLOOP
:ONTOPBUTTON
REM You can use Window ontop avilable in VDS which is easier
LOADLIB USER32
%H = @strdel(@WINEXISTS(#MYWin),1,1)
if %H
%H = @lib(user32,SetWindowPos,BOOL:,%H,-1,0,0,0,0,3)
else
ERROR -1
end
FREELIB USER32
END
goto EVLOOP
:NOTONTOPBUTTON
LOADLIB USER32
%H = @strdel(@WINEXISTS(#MYWin),1,1)
if %H
%H = @lib(user32,SetWindowPos,BOOL:,%H,-2,0,0,0,0,3)
else
ERROR -1
end
FREELIB USER32
END
goto EVLOOP
:HIDEBUTTON
REM You can use a tray icon to spice up yor app.
window hide,#MYWIN
goto EVLOOP
:close
exit
|
_________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|