forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Window Not ontop and Restore a window from any state

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code
View previous topic :: View next topic  
Author Message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Thu Jul 03, 2003 6:34 am    Post subject: Window Not ontop and Restore a window from any state Reply with quote

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
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group