[C#/VB]Auto-Resize/Reposition

Leave a Comment
VB.NET: http://pastebin.com/raw/BtzQcPzN
Dim ProportionsArray() As CtrlProportions
 Private Sub Form1_HandleCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.HandleCreated
  On Error Resume Next
  Application.DoEvents()
  ReDim ProportionsArray(0 To Controls.Count - 1)

  For I As Integer = 0 To Controls.Count - 1
   With ProportionsArray(I)
    .HeightProportions = Controls(I).Height / Height
    .WidthProportions = Controls(I).Width / Width
    .TopProportions = Controls(I).Top / Height
    .LeftProportions = Controls(I).Left / Width
   End With
  Next
 End Sub
 
 Private Structure CtrlProportions
  Dim HeightProportions As Single
  Dim WidthProportions As Single
  Dim TopProportions As Single
  Dim LeftProportions As Single
 End Structure
 
 Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
  On Error Resume Next
  For I As Integer = 0 To Controls.Count - 1

   Controls(I).Left = ProportionsArray(I).LeftProportions * Me.Width
   Controls(I).Top = ProportionsArray(I).TopProportions * Me.Height
   Controls(I).Width = ProportionsArray(I).WidthProportions * Me.Width
   Controls(I).Height = ProportionsArray(I).HeightProportions * Me.Height
  Next
 End Sub





C#: http://pastebin.com/raw/krGQM5eu
public struct CtrlProportions
  {
   public float HeightProportions;
   public float WidthProportions;
   public float TopProportions;
   public float LeftProportions;
  }


  CtrlProportions[] ProportionsArray;

  private void Form1_Load(object sender, EventArgs e)
  {
   Application.DoEvents();
   ProportionsArray = new CtrlProportions[Controls.Count];
   for (int I = 0; I <= Controls.Count - 1; I++)
   {
    ProportionsArray[I].HeightProportions = (float) Controls[I].Height / this.Height;
    ProportionsArray[I].WidthProportions = (float) Controls[I].Width / this.Width;
    ProportionsArray[I].TopProportions = (float)Controls[I].Top / this.Height;
    ProportionsArray[I].LeftProportions = (float) Controls[I].Left / this.Width;
   }
  }

  private void Form1_Resize(object sender, System.EventArgs e)
  {
   for (int I = 0; I <= Controls.Count - 1; I++)
   {
    Controls[I].Left = (int)(ProportionsArray[I].LeftProportions * this.Width);
    Controls[I].Top = (int) (ProportionsArray[I].TopProportions * this.Height);
    Controls[I].Width = (int) (ProportionsArray[I].WidthProportions * this.Width);
    Controls[I].Height = (int) (ProportionsArray[I].HeightProportions * this.Height);
   }
  }

0 comments:

Post a Comment

Powered by Blogger.
Warning: include(4.php) [function.include]: failed to open stream: No such file or directory in PATH on line 3

Microsoft SQL Native Client error '80040e14
Unclosed quotation mark after the character string
Query failed: ERROR: syntax error at or near \"'\" at character 56 in home/www/regs/home.php on line 121.
SQLSTATE: 42000 (ER_SYNTAX_ERROR) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
ORACLE-00933: SQL command not properly ended
function antiscanner($antiscanner)
{
return \$antiscanner;
}
\"/usr/local/bin\"
\"c:/www/regs/home\"
define( 'DB_NAME', 'database' );
define( 'DB_USER', 'www.localhost.com' );
define( 'DB_PASSWORD', 'antiscanner' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8' );
root:!:0:0::/:/usr/bin/ksh daemon:!:1:1::/etc:bin:!:2:2::/bin:sys:!:3:3::/usr/sys: adm:!:4:4::/var/adm:uucp:!:5:5::/usr/lib/uucp: guest:!:100:100::/home/guest:
SomeCustomInjectedHeader:injected_by_wvs
PROJECTS
Raven
DevAssistant
Pascal Trainer
Meow encoder 0.2
PROJECT LIST
TOOLS
Hacking
Forensic
Developer tools
Reverse engineering
APP LIST
DOCUMENTS
Hacking
Metasploit
Coding
Web development
SOURCE CODE
C#, VB.NET C++ Delphi VB6
Python PHP Perl Bash Batch
HTML, CSS, Javascript
Autoit AHK