Results 1 to 4 of 4

Thread: [RESOLVED] Moving borderless form - ERROR

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458

    Resolved [RESOLVED] Moving borderless form - ERROR

    Hi,
    Found this code to move a borderless form, but gives me an error:


    VB Code:
    1. using Microsoft.Win32;
    2.  
    3. private const int WM_NCLBUTTONDOWN = 0xA1;
    4. private const int HTCAPTION = 0x2;
    5.  
    6. [DllImport("user32.dll")]
    7. public static extern bool ReleaseCapture();
    8.  
    9. [ DllImport( "user32.dll" ) ]
    10. public static extern int SendMessage( IntPtr hWnd, int Msg, int wParam, int lParam );
    11.  
    12. private System.Windows.Forms.Button cmdExit;
    13. private System.ComponentModel.Container components = null;
    14.  
    15.  
    16. private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    17. {
    18. if ( e.Button == MouseButtons.Left )
    19. {
    20. ReleaseCapture();
    21. SendMessage( Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0 );
    22. }
    23. }

    The error says:
    "The type or namespace DLLImport could not be found..."
    Thanks

    Tomexx.

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Moving borderless form - ERROR

    Add this statement at the top
    Code:
    using System.Runtime.InteropServices;
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458

    Re: Moving borderless form - ERROR

    Thanks!
    I haven't seen that with any samples that I found (maybe it's a common knowledge).
    Thanks

    Tomexx.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Moving borderless form - ERROR

    Don't forget to resolve your thread from the Thread Tools menu.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width