Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Fri Aug 09, 2002 6:19 pm Post subject: NOTITLE minimized to TASK BAR |
|
|
Here's an example based on Mac's NOTITLE Fake Title Bar example. But
in this example, we fake a minimize to the task bar instead of the system
tray. This code also uses additional code by FreezingFire.
| Code: | rem -- NOTITLE window with fake title bar, minimizes to systray.
rem -- Has fake icon, but you can load icons with a BITMAP element.
rem -- In this example we remove the systray icon feature and instead
rem -- add a task bar icon for the NOTITLE window. We do this by
rem -- adding a second window that does have a TITLE BAR to serve as
rem -- our task bar icon. When the main window is showing, we hide
rem -- the second window, and when the main window has been requested
rem -- to be minimized, we hide it and then ICONIZE our second
rem -- window. When the second window has been clicked on from the
rem -- task bar, we then hide it and bring back the main window.
rem - IMPORTANT NOTE\________________________________/IMPORTANT NOTE
rem
rem -- The task bar icon is only present when the main window has
rem -- been hidden. It is not in the task bar when the main window
rem -- is visible.
rem --
rem -- You must compile this example in order to see the example in
rem -- action properly. If you run it from the IDE, the second
rem -- window will not minimize to the task bar, but to an old style
rem -- minimized title icon above the task bar. So compile to see.
rem ________________________________
rem - IMPORTANT NOTE/ \IMPORTANT NOTE
rem -- This example uses the NOTITLE with the Fake TITLE BAR example
rem -- that was provided by MAC. This example was also modified by
rem -- FreezingFire to make use of the @mousedown() function in
rem -- VDS 4, so this example also is only intended for VDS 4. You
rem -- can of course use the VDS 3 example that Mac originally posted
rem -- and add the Task Bar Icon code that is in this example.
OPTION SCALE, 96
OPTION DECIMALSEP, "."
rem -- Add the sleeptime so we can have the TIMER loop. This was not --
rem -- part of the original example. --
Option Sleeptime,100
TITLE "Fake Title Bar "
DIALOG CREATE,"Fake Title Bar ",-1,0,400,300,NOTITLE
DIALOG ADD,STYLE,Border1,,,,WHITE
DIALOG ADD,STYLE,Border2,,,,$00665555
DIALOG ADD,STYLE,Style0,MS Sans Serif,8,B,DKBLUE,WHITE
DIALOG ADD,STYLE,Style1,Impact,12,B
DIALOG ADD,STYLE,Style2,Wingdings,10
DIALOG ADD,STYLE,Style3,MS Serif,14
DIALOG ADD,STYLE,Style4,MS Sans Serif,8,B,BACKGRND
DIALOG ADD,STYLE,Style5,,,,DKBLUE,WHITE
DIALOG ADD,STYLE,Style6,Wingdings,14,,,CYAN
rem -- Add bottom and right first --
DIALOG ADD,TEXT,Bottom,298,1,398,2,,,Border2
DIALOG ADD,TEXT,Right,1,398,2,298,,,Border2
DIALOG ADD,TEXT,Top,1,1,398,1,,,Border1
DIALOG ADD,TEXT,Left,1,1,1,298,,,Border1
rem -- Add SysBars first --
DIALOG ADD,TEXT,SysBar,4,4,340,18,,,,Style0,CLICK
DIALOG ADD,TEXT,SysBar2,4,340,56,18,,,,Style0
DIALOG ADD,TEXT,SysTitle,6,28,,,"Fake Title Bar - Minimizes to System Tray",,,Style0,CLICK,TRANSPARENT
DIALOG ADD,TEXT,SysIcon,3,6,,,@chr(5 ,,Style6,CLICK,TRANSPARENT
rem -- Titlebar buttons --
DIALOG ADD,BUTTON,SysMin,6,344,16,14,"-",,Style1
DIALOG ADD,BUTTON,SysMax,6,360,16,14,@chr(114),,Style2
DIALOG DISABLE,SysMax
DIALOG ADD,BUTTON,SysExit,6,378,16,14,@chr(215),,Style3
rem -- Smoke and mirrors "Menu" replacement (no hotkeys) --
DIALOG ADD,TEXT,FileBkGrnd,24,5,25,18," "&File" ",,Style5
DIALOG ADD,TEXT,File,24,5,25,18," "&File" ",,CLICK
DIALOG ADD,EDIT,E1,40,3,393,235,,,MULTI,SCROLL
rem -- Status bar replacement (STATUS element is at top of NOTITLE)--
DIALOG ADD,EDIT,Stat,277,3,393,20,,,READONLY,Style4
DIALOG SHOW
rem -- Create second window to serve as our taskbar icon and then hide it immediately --
rem -- Note that this dialog titled "Fake Title Bar" and the main is "Fake Title Bar " --
rem -- with a space at the end of the title. This is to insure that they are --
rem -- different titles and do not get confused in the code --
DIALOG CREATE,"Fake Title Bar",9000,9000,0,0
DIALOG SHOW
WINDOW HIDE,"Fake Title Bar"
rem -- Select the main dialog so that all buttons and such work since we added a dialog --
DIALOG SELECT,0
rem -- Dialog status --
%%visible = 1
rem -- A variable switch letting our program know what status it is in --
%%Status = Showing
DIALOG FOCUS, E1
:EVLOOP
WAIT EVENT,0
goto @event()
rem -- TIMER loop added so we can see when the second window is clicked --
rem -- from the task bar. --
:TIMER
rem -- Check the variable switch to see if we need to check the windows --
If @equal(%%Status,Hidden)
rem -- Now check the original dialog status --
If @null(%%visible)
rem -- If all switches are set right, the main window is hidden now --
rem -- and we must check to see if the second window has been clicked --
rem -- from the task bar. If it has, then we need to hide it and --
rem -- then go bring back the main window. --
If @equal(@winpos("Fake Title Bar",S),1)
WINDOW HIDE,"Fake Title Bar"
Goto TaskBarCLICK
End
End
End
Goto Evloop
:SysIconCLICK
DIALOG POPUP,"&Minimize"|-|"&Close Alt+F4"
%e = @event()
if %e
goto %e
end
goto EVLOOP
:SysBarCLICK
:SysTitleCLICK
if @equal(@click(B), "RIGHT")
goto SysIconCLICK
end
%%x1 = @diff(@mousepos(X), @winpos("Fake Title Bar ",L))
%%y1 = @diff(@mousepos(Y), @winpos("Fake Title Bar ",T))
DIALOG SET, Stat, "Click again to release window..."
REPEAT
%x = @diff(@mousepos(X),%%x1)
%y = @diff(@mousepos(Y),%%y1)
if @greater(0, %x)
%x = 0
end
if @greater(0, %y)
%y = 0
end
WINDOW POSITION,"Fake Title Bar ",%y,%x
WAIT ".01"
UNTIL @not(@mousedown())
goto EVLOOP
:MinimizeMENU
:SysMinBUTTON
%%visible = ""
%%Status = Hidden
rem -- The minimize button has been clicked, so we set our variable switch and --
rem -- iconize our second window and hide our main window --
WINDOW POSITION,"Fake Title Bar",@winpos("Fake Title Bar ",T),@winpos("Fake Title Bar ",L),@winpos("Fake Title Bar ",W),@winpos("Fake Title Bar ",H)
WINDOW ICONIZE,"Fake Title Bar"
WINDOW HIDE,"Fake Title Bar "
goto EVLOOP
:TaskBarCLICK
%%visible = 1
%%Status = Showing
rem -- The task bar button for our second window has been clicked, so we hide it --
rem -- and bring back our main window --
WINDOW HIDE,"Fake Title Bar"
WINDOW NORMAL,"Fake Title Bar "
DIALOG FOCUS, E1
DIALOG SET, Stat, "Click title bar to move window..."
goto EVLOOP
:FileCLICK
DIALOG HIDE, File
DIALOG POPUP,&New...|&Open...|&Save...|&Save As...|-|&Exit,40,5
%e = @event()
DIALOG SHOW, File
if %e
goto %e
end
goto EVLOOP
:New...MENU
DIALOG CLEAR, E1
goto EVLOOP
:Open...MENU
%f = @filedlg()
if %f
if @greater(@file(%f, Z), 32000)
INFO "File is too large for this program..."@tab()
goto EVLOOP
end
LIST CREATE, 1
LIST LOADFILE, 1, %f
DIALOG SET, E1, @text(1)
LIST CLOSE, 1
end
goto EVLOOP
:Save...MENU
:Save As...MENU
if @dlgtext(E1)
if %f
%f = @filedlg(,,%f,SAVE)
else
%f = @filedlg(,,,SAVE)
end
if %f
LIST CREATE, 1
LIST ASSIGN, 1, @dlgtext(E1)
LIST SAVEFILE, 1, %f
LIST CLOSE, 1
end
else
INFO Nothing to save...@tab()
end
goto EVLOOP
:Close Alt+F4MENU
:ExitMENU
:SysExitBUTTON
:CLOSE
EXIT
STOP |
|
|