Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7900279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:55:50+00:00 2026-06-03T08:55:50+00:00

As you can see from the code provided below as well as the title,

  • 0

As you can see from the code provided below as well as the title, that I’m having trouble trying to figure out how to move this dynamically embeded borderless form in VB.NET.

Private Sub AddWidget_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddWidget.Click
        Dim WidgetForm As Form
        WidgetForm = New Form()
        WidgetForm.ShowInTaskbar = False
        WidgetForm.TopMost = True
        WidgetForm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        WidgetForm.BackgroundImage = Image.FromFile(Me.OpenFileDialog1.FileName)
        WidgetForm.BackgroundImageLayout = ImageLayout.Stretch
        WidgetForm.Show()

        opac = Me.OpacInt.Text
        WidgetForm.Opacity = opac

        sizew = Me.WidgetW.Text
        sizey = Me.WidgetY.Text
        WidgetForm.Size = New System.Drawing.Size(sizew, sizey)
    End Sub

I’ve done this method (code below) a couple times in the past, and it always seems to work for moving a form, but I’m unsure on how to apply this for the dynamically embeded form.

Any help would be greatly appreciated.

Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
    If e.Button = Windows.Forms.MouseButtons.Left Then
        drag = True
        mousex = Windows.Forms.Cursor.Position.X - Me.Left
        mousey = Windows.Forms.Cursor.Position.Y - Me.Top
    End If

    Timer1.Enabled = True
    Timer1.Interval = 2500
End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
    If drag Then
        Me.Top = Windows.Forms.Cursor.Position.Y - mousey
        Me.Left = Windows.Forms.Cursor.Position.X - mousex
    End If
End Sub

Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
    Timer1.Enabled = False
    drag = False
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:55:51+00:00Added an answer on June 3, 2026 at 8:55 am

    The dynamic form would perform as same as the normal form. First of all you need to add some events for the dynamic form when you create it

    Public WidgetForm As Form
    
    Private Sub AddWidget_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddWidget.Click
    
        WidgetForm = New Form()
        WidgetForm.ShowInTaskbar = False
        WidgetForm.TopMost = True
        WidgetForm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        WidgetForm.BackgroundImage = Image.FromFile(Me.OpenFileDialog1.FileName)
        WidgetForm.BackgroundImageLayout = ImageLayout.Stretch
        WidgetForm.Show()
    
        opac = Me.OpacInt.Text
        WidgetForm.Opacity = opac
    
        sizew = Me.WidgetW.Text
        sizey = Me.WidgetY.Text
        WidgetForm.Size = New System.Drawing.Size(sizew, sizey)
    
        'Add the event here
        AddHandler WidgetForm.MouseDown, AddressOf WidgetForm_MouseDown
        AddHandler WidgetForm.MouseMove, AddressOf WidgetForm_MouseMove
        AddHandler WidgetForm.MouseUp, AddressOf WidgetForm_MouseUp
    End Sub
    

    Then you can move the form by the events handler

    Private Sub WidgetForm_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) 
        If e.Button = Windows.Forms.MouseButtons.Left Then
            drag = True
            mousex = Windows.Forms.Cursor.Position.X - CType(sender, Form).Left
            mousey = Windows.Forms.Cursor.Position.Y - CType(sender, Form).Top
        End If
    
        Timer1.Enabled = True
        Timer1.Interval = 2500
    End Sub
    
    Private Sub WidgetForm_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If drag Then
            CType(sender, Form).Top = Windows.Forms.Cursor.Position.Y - mousey
            CType(sender, Form).Left = Windows.Forms.Cursor.Position.X - mousex
        End If
    End Sub
    
    Private Sub WidgetForm_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) 
        Timer1.Enabled = False
        drag = False
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some really funky code. As you can see from the code below
I have a setup a SQL Server instance that I can see from all
Hi below link from Vaadin you can see how to set checkboxes on tabletree,
While HTML Scraping is pretty well-documented from what I can see, and I understand
As you can see in the code below, I have an Abstract Base Class
Given my code below, is there a way that the first WebTestingApp constructor can
As you can see from the Client class, if the while breaks then the
From what I can see ui:dialog isnt a standard psuedo css element, so I
As you can see this is a question from a non web developer. I
How can I create a Popup balloon like you would see from Windows Messenger

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.