?
Solved

drag window using image

Posted on 2003-03-31
4
Medium Priority
?
275 Views
Last Modified: 2010-08-05
how do I drag a window (form) by clicking and dragging on an image?
I have set the borderstyle to none and mimic'd topbar with an image, but now I can't drag (obviously).  How do i make the image (looks just like a normal titlebar with the X on it) drag the entire window?
thx in advance!
Bear
0
Comment
Question by:LosBear
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:DeAn
ID: 8240729
assumes a picturebox name Picture1

Option Explicit

Private Declare Function ReleaseCapture Lib "user32" () As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1

Private Const WM_SYSCOMMAND = &H112
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ReleaseCapture
    SendMessage hwnd, WM_NCLBUTTONDOWN, _
        HTCAPTION, 0&

    ' Or use:
'    SendMessage hwnd, WM_SYSCOMMAND, _
'        &HF012&, 0&
End Sub

0
 
LVL 3

Accepted Solution

by:
DeAn earned 300 total points
ID: 8240741
you should use a PictureBox instead of Image for that code to work.
0
 
LVL 1

Author Comment

by:LosBear
ID: 8240751
so image wont' work?
0
 
LVL 1

Author Comment

by:LosBear
ID: 8240770
Well done; it worked like a charm.  I set the picture box properties to flat, no border, etc. and it works!
Thanks dude
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question