Does somebody know HOW to create a window which appearance not the magnification same as
window at windows magnifier program use visual basic
regards
There are a cople of properties of form which you will need to set in order to get the similar appearance.
Try setting following properties 每
------------------------Code Start-----------------------------------------
Dim pt As Point
pt.X = 0
pt.Y = 0
Me.Location = pt
Me.StartPosition = FormStartPosition.Manual
Me.ControlBox = False
Me.TopMost = True
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
--------------Code End---------------------------------------------------------
I hope this helps.
-Ajay
--------------------------------------
-------------------------------------
Hi Ajay,
I think the OP may also want to know how to create a magnifier type of window.
Regards,
John
Ajay K. Singh wrote:
There are a cople of properties of form which you will need to set in order to get the similar appearance.
Try setting following properties 每
------------------------Code Start-----------------------------------------
Dim pt As Point
pt.X = 0
pt.Y = 0
Me.Location = pt
Me.StartPosition = FormStartPosition.Manual
Me.ControlBox = False
Me.TopMost = True
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
--------------Code End---------------------------------------------------------
I hope this helps.
-Ajay
--------------------------------------
-------------------------------------
Hi Nicosa,
I am not surely that I understand your question. Just based on your post, I think that you need to have magnifier functionality in your form.
You can create a customized control. It inherits from the Panel control. We override the CreateParams property so that we can set the control's style. For magnification, this control uses very simple logic as , whenever you draw an image of small size on bigger canvas, it looks like magnified although the quality is not very good. Here is the code snippet to create a control with magnifier functionality. You can drag and drop this control to the form, but you need to ensure that that form has a background image. This control comes from the Writing Movable Transparent control with Magnifier functionality. I convert it to vb.net code and make a little change. You need to use vbc.exe to compile this file as a dll. Hope this helps.
Imports System Private x As Integer Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams #Region "Component Designer generated code" Protected Overloads Overrides Sub OnPaint(ByVal e As PaintEventArgs) Protected Overloads Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs) End Sub Protected Sub this_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) 'Refresh the parent to ensure that whatever is behind the control gets painted Protected Sub this_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) topBorder.Location = New Point(0, 0) leftBorder.Location = New Point(0, 0) rightBorder.Location = New Point(Me.Width - 1, 0) bottomBorder.Location = New Point(0, Me.Height - 1)
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.Windows.Forms
Namespace TransControl
Public Class TransControl
Inherits System.Windows.Forms.Panel
Private components As System.ComponentModel.Container = Nothing
Private topBorder As New Label()
Private leftBorder As New Label()
Private bottomBorder As New Label()
Private rightBorder As New Label()
Public XOffset As Integer = 0
Public YOffset As Integer = 0
Private MagnificationFactor As Integer = 1
Public Property pMagnificationFactor() As Integer
Get
Return MagnificationFactor
End Get
Set(ByVal value As Integer)
If (value >= 1) Then
MagnificationFactor = value
End If
End Set
End Property
Private y As Integer
Private pleft As Integer
Private ptop As Integer
Private isMouseDown As Boolean = False
Public Sub New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If components IsNot Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or 32
'WS_EX_TRANSPARENT
Return cp
End Get
End Property
Private Sub InitializeComponent()
Me.Name = "TransControl"
Me.Controls.Add(topBorder)
Me.Controls.Add(rightBorder)
Me.Controls.Add(leftBorder)
Me.Controls.Add(bottomBorder)
AddHandler Me.MouseDown, AddressOf this_MouseDown
AddHandler Me.MouseMove, AddressOf this_MouseMove
AddHandler Me.MouseUp, AddressOf this_MouseUp
AddBorders()
End Sub
#End Region
AddBorders()
End Sub
pevent.Graphics.DrawImage(Me.Parent.BackgroundImage, New Rectangle(0, 0, Me.Width, Me.Height), New Rectangle(Me.left + XOffset, Me.top + YOffset, Me.Width / MagnificationFactor, Me.Height / MagnificationFactor), GraphicsUnit.Pixel)
If isMouseDown Then
Me.left = Me.left + (e.X - x)
Me.top = Me.top + (e.Y - y)
'before we need to do our own graphics output.
Me.Parent.Refresh()
End If
End Sub
x = e.X
y = e.Y
pleft = Me.Left
ptop = Me.Top
isMouseDown = True
Me.Cursor = Cursors.SizeAll
End Sub
Protected Sub this_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
isMouseDown = False
Me.Cursor = Cursors.Default
Me.Refresh()
End Sub
Private Sub AddBorders()
topBorder.Size = New Size(Me.Width, 10)
topBorder.BackColor = Color.Black
leftBorder.Size = New Size(1, Me.Height)
leftBorder.BackColor = Color.Black
rightBorder.Size = New Size(1, Me.Height)
rightBorder.BackColor = Color.Black
bottomBorder.Size = New Size(Me.Width, 1)
bottomBorder.BackColor = Color.Black
End Sub
End Class
End Namespace
Best regards,
Riquel
Riquel Dong 每 MSFT wrote:
Hi Nicosa,
I am not surely that I understand your question. Just based on your post, I think that you need to have magnifier functionality in your form.
You can create a customized control. It inherits from the Panel control. We override the CreateParams property so that we can set the control's style. For magnification, this control uses very simple logic as , whenever you draw an image of small size on bigger canvas, it looks like magnified although the quality is not very good. Here is the code snippet to create a control with magnifier functionality. You can drag and drop this control to the form, but you need to ensure that that form has a background image. This control comes from the Writing Movable Transparent control with Magnifier functionality. I convert it to vb.net code and make a little change. You need to use vbc.exe to compile this file as a dll. Hope this helps.
Code BlockImports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.Windows.Forms
Namespace TransControl
Public Class TransControl
Inherits System.Windows.Forms.Panel
Private components As System.ComponentModel.Container = Nothing
Private topBorder As New Label()
Private leftBorder As New Label()
Private bottomBorder As New Label()
Private rightBorder As New Label()
Public XOffset As Integer = 0
Public YOffset As Integer = 0
Private MagnificationFactor As Integer = 1
Public Property pMagnificationFactor() As Integer
Get
Return MagnificationFactor
End Get
Set(ByVal value As Integer)
If (value >= 1) Then
MagnificationFactor = value
End If
End Set
End PropertyPrivate x As Integer
Private y As Integer
Private pleft As Integer
Private ptop As Integer
Private isMouseDown As Boolean = False
Public Sub New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If components IsNot Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End SubProtected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or 32
'WS_EX_TRANSPARENT
Return cp
End Get
End Property#Region "Component Designer generated code"
Private Sub InitializeComponent()
Me.Name = "TransControl"
Me.Controls.Add(topBorder)
Me.Controls.Add(rightBorder)
Me.Controls.Add(leftBorder)
Me.Controls.Add(bottomBorder)
AddHandler Me.MouseDown, AddressOf this_MouseDown
AddHandler Me.MouseMove, AddressOf this_MouseMove
AddHandler Me.MouseUp, AddressOf this_MouseUp
AddBorders()
End Sub
#End RegionProtected Overloads Overrides Sub OnPaint(ByVal e As PaintEventArgs)
AddBorders()
End SubProtected Overloads Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
pevent.Graphics.DrawImage(Me.Parent.BackgroundImage, New Rectangle(0, 0, Me.Width, Me.Height), New Rectangle(Me.left + XOffset, Me.top + YOffset, Me.Width / MagnificationFactor, Me.Height / MagnificationFactor), GraphicsUnit.Pixel)End Sub
Protected Sub this_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
If isMouseDown Then
Me.left = Me.left + (e.X - x)
Me.top = Me.top + (e.Y - y)'Refresh the parent to ensure that whatever is behind the control gets painted
'before we need to do our own graphics output.
Me.Parent.Refresh()
End If
End SubProtected Sub this_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
x = e.X
y = e.Y
pleft = Me.Left
ptop = Me.Top
isMouseDown = True
Me.Cursor = Cursors.SizeAll
End Sub
Protected Sub this_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
isMouseDown = False
Me.Cursor = Cursors.Default
Me.Refresh()
End Sub
Private Sub AddBorders()topBorder.Location = New Point(0, 0)
topBorder.Size = New Size(Me.Width, 10)
topBorder.BackColor = Color.BlackleftBorder.Location = New Point(0, 0)
leftBorder.Size = New Size(1, Me.Height)
leftBorder.BackColor = Color.BlackrightBorder.Location = New Point(Me.Width - 1, 0)
rightBorder.Size = New Size(1, Me.Height)
rightBorder.BackColor = Color.BlackbottomBorder.Location = New Point(0, Me.Height - 1)
bottomBorder.Size = New Size(Me.Width, 1)
bottomBorder.BackColor = Color.Black
End Sub
End Class
End Namespace
Best regards,
Riquel
Hi Nicosa,
Do you mean you need to create a form and this form hasn't the control box If you need to create a form, the form's size can't be changed and the form hasn't the control box. You can set Form.ControlBox = False, Form.MaximumSize = Form.Size and Form.MinimumSize = Form.Size to implement this functionality. If you have any further questions, please tell me.
Best regards,
Riquel
Just set the FormBorderStyle = None
Then of course you will have to set the size, location, and background of the form to obtain your desiered result.