I'd like to allow the user to zoom a window using a trackbar, say from 80%
to 120% the size of the original window. I'm trying to do this with the
following code, but it fails pretty miserably:
(from the form)
Dim per As Decimal
per = CDec(zoomit.Val ue)
setzoom(Me, Me.Font, per) ' per is the current value of the trackbar as a
decimal
----------------------
Public Sub setzoom(ByRef senderform As Form, ByRef senderfont As Font, ByVal
per As Decimal)
per = per * 0.01
Dim iwidth As Int32 = SystemInformati on.PrimaryMonit orSize.Width
Dim sizeold As SizeF =
System.Windows. Forms.Form.GetA utoScaleSize(se nderfont)
senderfont = New Font(senderfont .FontFamily, senderfont.Size * iwidth /
1280)
' 1280 is my current environment width
Dim sizenew As SizeF =
System.Windows. Forms.Form.GetA utoScaleSize(se nderfont)
sizenew.Width = sizenew.Width * per
sizenew.Height = sizenew.Height * per
senderform.Scal e(sizenew.Width / sizeold.Width, sizenew.Height /
sizeold.Height)
End Sub
Thanks for any help.
Bernie Yaeger 4 3821
Hi Bernie,
Have a look of this code, I did want to send it to you yesterday, but I did
not really test it.
The idea of this is that it changes recursevly the controls in a child
control.
I first made it with height and width, but when I saw your solution with
scale I changed it.
But I think that with height and width it is even nicer.
Cor
\\\To test
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
Dim mescale As Single = 1.1
doScale.scale(M e, mescale)
End Sub
Private Sub Button2_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button2.Click
Dim mescale As Single = 1 / 1.1
doScale.scale(M e, mescale)
End Sub
End Class
///
\\\
Public Class doScale
Public Shared Sub scale(ByVal ctr As Control, ByVal mescale As Single)
ctr.Width = CInt(ctr.Width * mescale)
ctr.Height = CInt(ctr.Height * mescale)
ctr.Scale(mesca le)
Dim Berny As New doCtr(ctr, mescale)
End Sub
Private Class doCtr
Public Sub New(ByVal parentCtr As Control, ByVal mescale As Single)
Dim ctr As Control
For Each ctr In parentCtr.Contr ols
ctr.Scale(mesca le)
Dim newdoCtr As _
New doCtr(ctr, mescale)
Next
End Sub
End Class
///
Bernie,
I see two problems, well one problem and one potential problem.
I believe you want to only scale the font: senderfont = New Font(senderfont .FontFamily, senderfont.Size * iwidth / 1280 * per)
Also while attempting to get it to work I would remove the "iwidth /1280"
logic, once your zooming works, I would then attempt at incorporating that
back in...
Now the "bigger" problem, which I currently don't have a solution.
After the first call to SetZoom, you are scaling the scaled form. Somehow
each time you call SetZoom, you need to "reset" the form to the original
size, then apply the new scale. Or maybe only zoom original values (not
current values)...
If you don't have it, you may want to review the section in Petzold's book
that explains how the code I gave you works...
Hope this helps
Jay
"Bernie Yaeger" <be*****@cherwe llinc.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. I'd like to allow the user to zoom a window using a trackbar, say from 80% to 120% the size of the original window. I'm trying to do this with the following code, but it fails pretty miserably: (from the form)
Dim per As Decimal
per = CDec(zoomit.Val ue)
setzoom(Me, Me.Font, per) ' per is the current value of the trackbar as a decimal
----------------------
Public Sub setzoom(ByRef senderform As Form, ByRef senderfont As Font,
ByVal per As Decimal)
per = per * 0.01
Dim iwidth As Int32 = SystemInformati on.PrimaryMonit orSize.Width
Dim sizeold As SizeF = System.Windows. Forms.Form.GetA utoScaleSize(se nderfont)
senderfont = New Font(senderfont .FontFamily, senderfont.Size * iwidth / 1280)
' 1280 is my current environment width
Dim sizenew As SizeF = System.Windows. Forms.Form.GetA utoScaleSize(se nderfont)
sizenew.Width = sizenew.Width * per
sizenew.Height = sizenew.Height * per
senderform.Scal e(sizenew.Width / sizeold.Width, sizenew.Height / sizeold.Height)
End Sub
Thanks for any help.
Bernie Yaeger
Hi Jay,
Actually, the code you gave me yesterday works splendidly when I scale based
purely on the current resolution of a given monitor. That's because it
scales only once.
I now want to extend that logic to a trackbar scale, but I now realize that
once I scale I don't have the original form to rescale - it's now another
size, not the resolution size. So, yes, either I maintain the original size
somewhere (could be done) or I scale the current scale value (eg, now it's
at .95 so multiply everything appropriately, etc).
As always, you've helped to put me on the right track. If you have any
further thoughts, please send them to me.
Thanks again,
Bernie
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:uv******** ******@tk2msftn gp13.phx.gbl... Bernie, I see two problems, well one problem and one potential problem.
I believe you want to only scale the font:
senderfont = New Font(senderfont .FontFamily, senderfont.Size * iwidth / 1280 * per)
Also while attempting to get it to work I would remove the "iwidth /1280" logic, once your zooming works, I would then attempt at incorporating that back in...
Now the "bigger" problem, which I currently don't have a solution.
After the first call to SetZoom, you are scaling the scaled form. Somehow each time you call SetZoom, you need to "reset" the form to the original size, then apply the new scale. Or maybe only zoom original values (not current values)...
If you don't have it, you may want to review the section in Petzold's book that explains how the code I gave you works...
Hope this helps Jay
"Bernie Yaeger" <be*****@cherwe llinc.com> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. I'd like to allow the user to zoom a window using a trackbar, say from
80% to 120% the size of the original window. I'm trying to do this with the following code, but it fails pretty miserably: (from the form)
Dim per As Decimal
per = CDec(zoomit.Val ue)
setzoom(Me, Me.Font, per) ' per is the current value of the trackbar as
a decimal
----------------------
Public Sub setzoom(ByRef senderform As Form, ByRef senderfont As Font, ByVal per As Decimal)
per = per * 0.01
Dim iwidth As Int32 = SystemInformati on.PrimaryMonit orSize.Width
Dim sizeold As SizeF = System.Windows. Forms.Form.GetA utoScaleSize(se nderfont)
senderfont = New Font(senderfont .FontFamily, senderfont.Size * iwidth / 1280)
' 1280 is my current environment width
Dim sizenew As SizeF = System.Windows. Forms.Form.GetA utoScaleSize(se nderfont)
sizenew.Width = sizenew.Width * per
sizenew.Height = sizenew.Height * per
senderform.Scal e(sizenew.Width / sizeold.Width, sizenew.Height / sizeold.Height)
End Sub
Thanks for any help.
Bernie Yaeger
Hi Cor,
Thanks for your help. Yes, my problem is that I have to scale recursively
and my current code does not do that, so that is where I think I'm failing.
I will review your code, which has already given me some ideas.
Tx again for all your help,
Bernie
"Cor" <no*@non.com> wrote in message
news:uX******** ******@TK2MSFTN GP10.phx.gbl... Hi Bernie,
Have a look of this code, I did want to send it to you yesterday, but I
did not really test it. The idea of this is that it changes recursevly the controls in a child control.
I first made it with height and width, but when I saw your solution with scale I changed it. But I think that with height and width it is even nicer.
Cor \\\To test Private Sub Button1_Click(B yVal sender As System.Object, _ ByVal e As System.EventArg s) Handles Button1.Click Dim mescale As Single = 1.1 doScale.scale(M e, mescale) End Sub
Private Sub Button2_Click(B yVal sender As System.Object, _ ByVal e As System.EventArg s) Handles Button2.Click Dim mescale As Single = 1 / 1.1 doScale.scale(M e, mescale) End Sub End Class /// \\\ Public Class doScale Public Shared Sub scale(ByVal ctr As Control, ByVal mescale As Single) ctr.Width = CInt(ctr.Width * mescale) ctr.Height = CInt(ctr.Height * mescale) ctr.Scale(mesca le) Dim Berny As New doCtr(ctr, mescale) End Sub Private Class doCtr Public Sub New(ByVal parentCtr As Control, ByVal mescale As
Single) Dim ctr As Control For Each ctr In parentCtr.Contr ols ctr.Scale(mesca le) Dim newdoCtr As _ New doCtr(ctr, mescale) Next End Sub End Class /// This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ron Crump |
last post by:
Hi,
I have a small javascript (scalegr.js) that re-scales a sequence of
images on a page to be less than the frame width, thus:
function scalegr(a) {
var imgs = document.images;
var fw = window.innerWidth;
for (var i=0; i<imgs.length; i++) {
var w=imgs.width;
|
by: Pls Help |
last post by:
Hi,
I've encountered a weird TrackBar issue, it seems to hang completely when
the TrackBar.Maximum is set to certain large values.. what's going on? Have
tried this on a few different 2000/XP environments and it seems the
behaviour is universal.
Btw, before attempting the test below it's a good idea to make sure you
haven't any unsaved...
|
by: juergen |
last post by:
how to design a trackbar/slider with diff. look???
For my win-application I need a trackbar/slider,
that doesnt look like the control-trackbar offered
by vb.net. ; e.g. something like the slider in win-mediaplayer...,
but with my own design.
tried to change the look, and create something that
works like a slider,
but didnt find a solution...
|
by: ACaunter |
last post by:
Hi all,
I really am in desperate need of some code that can zoom in on an image. I
don't want to just make the whole image bigger, i want to have a box ( <p>
tag ) that is the zooming window... so the image is always the same size, the
box is always the same size, and only when the box is moved over the image,
the part of the image that is...
|
by: RuffAroundTheEdges |
last post by:
I'm trying to get an aspx page to display a TrackBar. There is no TrackBar in
the System.Web.UI.WebControls. Is there a TrackBar like control in
System.Web.UI.WebControls? If not, is there a way to use
System.Windows.Forms.TrackBar in an aspx page?
| |
by: Sakharam Phapale |
last post by:
Hi All,
How to set the background image for TrackBar control.
Since BackgroundImage property doesn't visible in design mode, I tried doing
it in run time as follows,
myTrackBar.BackgroundImage = Image.FromFile("C:\myImage.bmp")
But by doing so don't set BackgroundImage of TrackBar.
Any help regarding such will be appreciated.
|
by: Kris |
last post by:
Hi.
We are developing an application in VS2005 in C#, .NET, that has lots of
tabs. On one of these tabs, there is a horizontal trackbar.
However, we are unable to set the background color of the trackbar to
trasparent.
The best would by transparent . Becouse the tabs are gradiently colored. It
should work on standard windows XP theme.
In...
|
by: John |
last post by:
I have an app where I want to show an icon in a large PictureBox.
I've set the SizeMode to Zoom but the icon image is extremely fuzzy because
the scaling up also anti-aliases. Is there a way to turn the anti-aliasing
off so I get a nice blocky icon image?
--
"I have nothing but the greatest respect for other peoples' crackpot
beliefs"....
|
by: therefor |
last post by:
I have the following in Flash 8
BriefLook_mc.btnStudentLife_mc.onRelease = function():Void
{
this.createEmptyMovieClip("craveLoader_mc", this.getNextHighestDepth());
this.craveLoader_mc.getURL("BWC_Crave.swf", "_blank");
}
This opens a new window for BWC_Crave.swf ...like I want. But the window scales depending on my current...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |