Keeping an HTA from resizing to extremely small sizes - vbscript

I have a HTA that I want to block resizing to extremely small sizes (less than 170x70). I found a way in VBScript to do this by detecting if the window is to small and if it is resizing it automatically like this:
<script type="text/vbscript">
Sub Window_onResize
Dim w
Dim h
Dim p
w = Document.Body.OffsetWidth
h = Document.Body.OffsetHeight
p = false
If Document.Body.OffsetWidth < 170 Then
w = 170
p = true
End If
If Document.Body.OffsetHeight < 70 Then
h = 70
p = true
End If
If p Then
window.ResizeTo w,h
End If
End Sub
</script>
My problem is that apparently ResizeTo counts the scroll bar and the title bar whereas OffsetWidth and OffsetHeight don't. I thought of solving this problem by detecting the title bar's height and the scroll bar's width. I've searched the web for how to do this and I haven't found anything. You can suggest a way of detecting the title bar's height and the scroll bar's width or another way of keeping the HTA from getting resized to extremesly small sizes.

Related

Creating a fixed background using tkinter

I am using tkinter when and trying to set up a window with a background image. In some of the processes I have a frame that fills up with checkboxes so I created a scrollbar so the user can see all the options. The problem is the scroll bar also moves the background image of the canvas. Is there a way I can fix the image to not move or somehow move the frame by itself.
code is
def canvasScroll():
canvas = gui.createCanvas()
fFrame = gui.createNewFrame()
scrollbar = Scrollbar(root, orient="vertical", command=canvas.yview)
canvas.configure(yscrollcommand = scrollbar.set)
scrollbar.pack(side="right", fill="y")
canvas.pack(side="left", fill="both", expand= True)
canvas.create_window((150,50),window = fFrame, anchor='nw', tags = "frame")
gOb.change_canvas(canvas)
fFrame.bind("<Configure>", gui.scroll)
gOb.change_scrollbar(scrollbar)
gOb.change_frame(fFrame)
def createCanvas():
canvas = Canvas(root,height = _h, width = _w,highlightthickness = 0)
canvas.pack(side='top',fill='both',expand='yes')
canvas.create_image(-200,-200,image=bground,anchor='nw')
return canvas
def createNewFrame():
frame = Frame(root,height = _h, width = _w,background='white')
frame.pack()
return frame
Just to clear things up, these guys are all part of a class name gui and gOb is an object that hold several gui objects.
Here's one idea - it's kind of kludgy, but it would work. Every time the scrollbar scrolls, shift the background image's position so it appears to stay in the same place:
Tag your image so you can access it later:
canvas.create_image(-200,-200,image=bground,anchor='nw',tags="background")
# ^^^^^^^^^^^^^^^^^
Make your scrollbar call a function that you define:
scrollbar = Scrollbar(root, orient="vertical", command=scrollCallback)
Define your scroll callback:
def scrollCallback(*args):
canvas.yview(*args)
# Arrange for your background image to move so it appears to stay in the same position as the canvas scrolls.

Get Window Position in HTA

Can i get the current window position in HTA (HTML Application)? which is similar with Me.Top and Me.Left in VB6, but i want it get the pixels number.!?
With JS you can get the position of the topmost window with top.screenLeft and top.screenTop.
Here's a cool way to do it. It's sorta animated
VBScript
Add this to global variables
Dim IntervalMovingWindow
then add this OnLoad routine
Sub Window_OnLoad
moveTo screen.availWidth/2-200 , screen.availHeight/2-100
IntervalMovingWindow= Setinterval ("MoveTheWindow",100)
End Sub
Then Add this Routine for moving windows (animated style)
Sub MoveTheWindow
Dim X,Y
X=top.screenleft
Y=top.screentop
If X<=60 Then
X=0
End If
If Y<=60 Then
Y=0
End If
If X<>0 Then
moveBy -20,0
End If
If Y<>0 Then
moveBy 0,-20
End If
If X=0 And Y=0 Then
moveto 0,0
clearInterval IntervalMovingWindow
End If
End Sub
This may not work if you have an excessively large border. in that case you may need to change -20 in the moveBy to a larger negative number like -30 and the If {X or Y}=60 into a larger positive number like If {X or Y}=80
NOTE don't include the Braces '{}' they just mean that i am talking about both X and the Y conditionals.

Programmatically created Label will not right-justify

Creating a label programatically (i.e. not in designer) won't right-align on my form.
Set lblStatus = StatusForm.Controls.Add("VB.Label", "lbl" & xml(Prop, "column"))
With lblStatus
.Visible = True
.Caption = Text
.Alignment = vbRightJustify
.WordWrap = False
.AutoSize = True
.top = Index * (lblStatus.height)
.left = MaxWidth - Screen.TwipsPerPixelX * 15
.Width = StatusForm.TextWidth(Text)
End With
I created three of these controls, but they continue to expand from the left, rather than from the right:
Ideally, I want those labels (surrounded by #) to have their semicolons line up.
Since you set AutoSize to true, the width is set to the precise width of the text, leaving no room for alignment.
To layout the text within a fixed width, turn off AutoSize.

Matlab, GUI, Scrolling content in Pane. How to hide overflow?

I am trying to make a Matlab GUI that has a panel with scrolling content inside of a larger figure. I am having a problem hiding the overflow content when it scrolls out of the subpanel.
I got the code for the scrollbar from this SO post: Adding scroll bar in subplots within GUI
Try the code below. I have a figure, an outer panel (smaller than the figure, child to the figure), a scrolling panel (with a height greater than the figure, child to outer panel), a scroll bar, and a text field to appear in the scrolling pane (child to the scrolling panel).
When you try the code you will see the text string, which is just the alphabet repeated, scrolls up and down the whole length of the figure, but the scrolling panel stops at the edge of the limits of the outer panel.
How can I correct this problem. Thanks.
function guitest
scrsz = get(0,'ScreenSize');
height = scrsz(4)*7/8;
width = scrsz(3)*2/3;
leftmargin = 10;
rightmargin = 10;
% figure
handles.hFig = figure('Visible','on',...
'Position', [scrsz(3)/8 scrsz(4)/10 width height],...
'Name', 'Tap Toolbar Report',...
'NumberTitle', 'off',...
'Color', [0.75 0.75 0.75],...
'ToolBar','none',...
'MenuBar','none',...
'Resize','off');
% subpanel in the figure for scrolling
handles.hOut = uipanel('Parent',handles.hFig,...
'BackgroundColor', [0.85 0.85 0.85],...
'BorderWidth', 0,...
'Units', 'pixels',...
'Position',[leftmargin 100 width-2*leftmargin height-200]);
hPanheight = 2000;
handles.hPan = uipanel('Parent',handles.hOut,...
'BackgroundColor', [0.85 0.85 0.85],...
'BorderWidth', 0,...
'Units', 'pixels',...
'Position',[0 0 width-2*leftmargin-19 hPanheight]);
str = sprintf('a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nx\ny\nz');
uicontrol('Parent', handles.hPan,'Style','text','String',str,'FontSize', 10,'FontWeight','bold', 'HorizontalAlignment', 'left',...
'Position',[10 20 20 1960],'BackgroundColor', [0.85 0.85 0.85]);
handles.hSld = uicontrol('Style', 'slider',...
'BackgroundColor', [0.8 0.8 0.8], ...
'Position', [width-leftmargin-20 101 19 height-202],...
'Callback', {#onSlide,handles.hPan,handles.hOut});
set(handles.hSld,'Value',1);
onSlide(handles.hSld,'',handles.hPan,handles.hOut)
end
function onSlide(hSld,~,hPan,hOut)
%# slider value
offset = get(hSld,'Value');
%# update panel position
p = get(hPan, 'Position'); %# panel current position
ph = get(hOut, 'Position');
set(hPan, 'Position',[p(1) -offset*(p(4)-ph(4)) p(3) p(4)])
end
I would use a container object that has scroll capability built-in. Take a look at:
help uitable
help uitree

Vertical Scrolling Marquee for foxpro

Could anyone could point me to some code/give me ideas on how to create a smooth scrolling vertical marquee for VFP 8 or 9?
Any help is appreciated.
Here's a quick program that will scroll messages. Put the following in a prg file and run it.
I'd make a containerScrollArea a class that encapsulates the timer, labels, and scrolling code. Give it GetNextMessage method that you can override to retrieve the messages.
* Put a container on the screen to hold our scroller
_screen.AddObject("containerScrollArea", "container")
WITH _Screen.containerScrollArea
* Size it
.Visible = .t.
.Width = 100
.Height = 100
* Add two labels, one to hold each scrolling message
.AddObject("labelScroll1", "Label")
.AddObject("labelScroll2", "Label")
* This timer will move the labels to scroll them
.AddObject("timerScroller", "ScrollTimer")
ENDWITH
WITH _Screen.containerScrollArea.labelScroll1
* The labels are positioned below the margin of the container, so they're not initially visible
.Top = 101
.Height = 100
.Visible = .t.
.WordWrap = .t.
.BackStyle= 0
.Caption = "This is the first scrolling text, which is scrolling."
ENDWITH
WITH _Screen.containerScrollArea.labelScroll2
* The labels are positioned below the margin of the container, so they're not initially visible
.Top = 200
.Height = 100
.Visible = .t.
.WordWrap = .t.
.BackStyle= 0
.Caption = "This is the second scrolling text, which is scrolling."
ENDWITH
* Start the timer, which scrolls the labels
_Screen.containerScrollArea.timerScroller.Interval = 100
DEFINE CLASS ScrollTimer AS Timer
PROCEDURE Timer
* If the first label is still in view, move it by one pixel
IF This.Parent.labelScroll1.Top > -100
This.Parent.labelScroll1.Top = This.Parent.labelScroll1.Top - 1
ELSE
* If the first label has scrolled out of view on the top of the container, move it back to the bottom.
This.Parent.labelScroll1.Top = 101
* Load some new text here
ENDIF
IF This.Parent.labelScroll2.Top > -100
* If the second label is still in view, move it by one pixel
This.Parent.labelScroll2.Top = This.Parent.labelScroll2.Top - 1
ELSE
* If the second label has scrolled out of view on the top of the container, move it back to the bottom.
This.Parent.labelScroll2.Top = 101
* Load some new text here
ENDIF
ENDPROC
ENDDEFINE
You can use Scrollable Container
Unfortunately the nature of my work leaves me no time for fooling around with graphics, however if I did I would look into using GDI+ with VFP. Here is an article to get you started

Resources