A very useful feature was added in 2.0 of .NET framework which was the
scaling of a form and all the controls within it. This is really useful but
I am finding very little information of how to use it.
I have managed to implement it as follows:
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim addSize As New SizeF(0.5F, 0.5F)
Me.Scale(addSiz e)
End Sub
And this quite rightly reduces everything down to half of what it was.
However I am wanting to put this in the Form Resize event, and I tried this
rather clumsy approach:
Private Sub Form2_Resize(By Val sender As Object, ByVal e As
System.EventArg s) Handles Me.Resize
Static OldWidth As Integer
Static OldHeight As Integer
If OldWidth = 0 Then OldWidth = Me.Width
If OldHeight = 0 Then OldHeight = Me.Height
Dim ScaleX As Decimal = Me.Width / OldWidth
Dim ScaleY As Decimal = Me.Height / OldHeightDim MyScale As New
SizeF(ScaleX, ScaleY)
Me.Scale(MyScal e)
OldWidth = Me.Width
OldHeight = Me.Height
End Sub
The problem is that it suffers from re-entry. As soon as the form and
everything else is scaled, the Resize event is triggered again and so on.
How are we supposed to use this scale facility?
-Jerry 3 2023
I think that you can add a static Boolean variable that will be used a flag
to ignore the event
Static b As Boolean
b = not b
if b then
Scaling code goes here
end if
That will mean that the event will be implemented once though fired twice
(second time ignore)
hth,
Samuel Shulman
"Jerry Spence1" <je**********@s omewhere.comwro te in message
news:44******** *************** @ptn-nntp-reader01.plus.n et...
>A very useful feature was added in 2.0 of .NET framework which was the scaling of a form and all the controls within it. This is really useful but I am finding very little information of how to use it.
I have managed to implement it as follows:
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim addSize As New SizeF(0.5F, 0.5F)
Me.Scale(addSiz e)
End Sub
And this quite rightly reduces everything down to half of what it was.
However I am wanting to put this in the Form Resize event, and I tried
this rather clumsy approach:
Private Sub Form2_Resize(By Val sender As Object, ByVal e As
System.EventArg s) Handles Me.Resize
Static OldWidth As Integer
Static OldHeight As Integer
If OldWidth = 0 Then OldWidth = Me.Width
If OldHeight = 0 Then OldHeight = Me.Height
Dim ScaleX As Decimal = Me.Width / OldWidth
Dim ScaleY As Decimal = Me.Height / OldHeightDim MyScale As New
SizeF(ScaleX, ScaleY)
Me.Scale(MyScal e)
OldWidth = Me.Width
OldHeight = Me.Height
End Sub
The problem is that it suffers from re-entry. As soon as the form and
everything else is scaled, the Resize event is triggered again and so on.
How are we supposed to use this scale facility?
-Jerry
Thanks for that tip Samuel. Yes, that part did work OK, although the rest of
the code doesn't perform too well. The result is very jerky and only some of
my controls are actuall scaling. I think it doesn't help that I am
physically scaling the form with the mouse, and then it is also being scaled
through my code - one is fighting the other. I am surprised that help
doesn't help and there are no examples on the net anywhere.
-Jerry
"Samuel Shulman" <sa************ @ntlworld.comwr ote in message
news:u9******** ******@TK2MSFTN GP05.phx.gbl...
>I think that you can add a static Boolean variable that will be used a flag to ignore the event
Static b As Boolean
b = not b
if b then
Scaling code goes here
end if
That will mean that the event will be implemented once though fired twice
(second time ignore)
hth,
Samuel Shulman
"Jerry Spence1" <je**********@s omewhere.comwro te in message
news:44******** *************** @ptn-nntp-reader01.plus.n et...
>>A very useful feature was added in 2.0 of .NET framework which was the scaling of a form and all the controls within it. This is really useful but I am finding very little information of how to use it.
I have managed to implement it as follows:
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventAr gs) Handles Button1.Click
Dim addSize As New SizeF(0.5F, 0.5F) Me.Scale(addSiz e)
End Sub
And this quite rightly reduces everything down to half of what it was. However I am wanting to put this in the Form Resize event, and I tried this rather clumsy approach:
Private Sub Form2_Resize(By Val sender As Object, ByVal e As System.EventAr gs) Handles Me.Resize
Static OldWidth As Integer Static OldHeight As Integer If OldWidth = 0 Then OldWidth = Me.Width If OldHeight = 0 Then OldHeight = Me.Height
Dim ScaleX As Decimal = Me.Width / OldWidth Dim ScaleY As Decimal = Me.Height / OldHeightDim MyScale As New SizeF(ScaleX , ScaleY)
Me.Scale(MyScal e)
OldWidth = Me.Width OldHeight = Me.Height
End Sub
The problem is that it suffers from re-entry. As soon as the form and everything else is scaled, the Resize event is triggered again and so on.
How are we supposed to use this scale facility?
-Jerry
On Sun, 16 Jul 2006 19:35:50 +0100, "Jerry Spence1"
<je**********@s omewhere.comwro te:
>A very useful feature was added in 2.0 of .NET framework which was the scaling of a form and all the controls within it. This is really useful but I am finding very little information of how to use it.
I have managed to implement it as follows:
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventAr gs) Handles Button1.Click
Dim addSize As New SizeF(0.5F, 0.5F)
Me.Scale(addSiz e)
End Sub
And this quite rightly reduces everything down to half of what it was. However I am wanting to put this in the Form Resize event, and I tried this rather clumsy approach:
Private Sub Form2_Resize(By Val sender As Object, ByVal e As System.EventAr gs) Handles Me.Resize
Static OldWidth As Integer
Static OldHeight As Integer
If OldWidth = 0 Then OldWidth = Me.Width
If OldHeight = 0 Then OldHeight = Me.Height
Dim ScaleX As Decimal = Me.Width / OldWidth
Dim ScaleY As Decimal = Me.Height / OldHeightDim MyScale As New SizeF(ScaleX , ScaleY)
Me.Scale(MyScal e)
OldWidth = Me.Width
OldHeight = Me.Height
End Sub
The problem is that it suffers from re-entry. As soon as the form and everything else is scaled, the Resize event is triggered again and so on.
How are we supposed to use this scale facility?
-Jerry
When resizing the form, you don't want to scale the form, itself -
just the form's controls. The Try/Catch is needed as during starup,
the static variables are not initialized until the first pass through
of the resize event:
Private Sub Form1_Resize(By Val sender As Object, ByVal _
e As System.EventArg s) Handles Me.Resize
Static OldWidth As Integer
Static OldHeight As Integer
Try
Dim ScaleX As Decimal = CDec(Me.Width / OldWidth)
Dim ScaleY As Decimal = CDec(Me.Height / OldHeight)
Dim MyScale As New SizeF(ScaleX, ScaleY)
For Each ctl As Control In Me.Controls
ctl.Scale(MySca le)
Next
Catch
Finally
OldWidth = Me.Width
OldHeight = Me.Height
End Try
You also can selectively scale only specfic controls in the For Each
loop.
Gene This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: chaos |
last post by:
Hello,
i have problems using sqlj in the following environment.
I use type 4 driver com.ibm.db2.jcc.DB2Driver and connect succesful to
8.1. db2-Database(DRDA)(Informational tokens are "DB2 v8.1.0.32",
"s031027", "MI00060", and FixPak "4".Product is installed at
"/opt/IBM/db2/V8.1"). It runs in an applicationcontainer (jdk1.4,
linux). I tried all other drivers without success.
|
by: Paul Duncan |
last post by:
diggityduncs (Programmer) Nov 13, 2003
Hello,
I'm tring to use a win32/api dll in c#
The vendor I received the dll from doesn't know anything
about .net
I received two files
ACGAPI.DLL +
|
by: Tod Birdsall |
last post by:
Hi All,
I am trying to secure non-ASP.NET files (i.e. .html, .pdf) in an
application running on IIS 6.0, Win2K3 using the .NET Framework 2.0.
What has worked in the past using .NET Framework 1.1 on IIS 6.0 is the
following :
1. Open IIS
2. Right click website, choose Properties.
3. Click "Home Directory" tab.
|
by: James |
last post by:
I have a VB windows forms application that accesses a Microsoft Access
database that has been secured using user-level security. The
application is being deployed using No-Touch deployment. The objective
in utilizing this new deployment method is to reduce the maintenance
overhead as well as making it easier for my users to setup and run the
application initially. I have VS 2002, Windows XP, Access XP(2000
format).
He is my problem....
|
by: James |
last post by:
I have a VB windows forms application that accesses a Microsoft Access
database that has been secured using user-level security. The
application is being deployed using No-Touch deployment. The objective
in utilizing this new deployment method is to reduce the maintenance
overhead as well as making it easier for my users to setup and run the
application initially. I have VS 2002, Windows XP, Access XP(2000
format).
He is my problem....
| |
by: CompuBoy |
last post by:
I have a problem on retrieving information from web browser component;
because I am using .Net framework 2.0 and it cannot use AxSHDocVw function.
Currently I am using Microsoft.mshtml, how can I get the web browser
information by using this function or any other solution?
P.S. I found the solution from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vsgrfwalkthroughaccessingdhtmldomfromc.asp
but it...
|
by: ampravin |
last post by:
Hi all,
I am using Atlas framework and while my session time out, am getting an unknown alert. Is it possible to avoid this? If possible can any one help me out of this?
Thanks in advance.
|
by: _spitFIRE |
last post by:
Is it possible to run a SMTP server that sends mail to recipients
using standard libraries, without using twisted framework, and also
without using any relay server?
|
by: Brett R. Wesoloski |
last post by:
I am having problems using HttpContext.Current.Request.Url.Host.
I have some code that does this...
if (HttpContext.Current != null)
{
subdomain = HttpContext.Current.Request.Url.Host;
}
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |