Results 1 to 13 of 13

Thread: [RESOLVED] Form Drag Problem

  1. #1

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Resolved [RESOLVED] Form Drag Problem

    Hello. I got this source from here or planet source code, and it makes a picture into a clock. I used it to create a custom clock and it drags around just fine on my computer. I am running 98se. But when I send it to my friends, it won't drag around their desktop. Can someone help me sort this out? Thanks.

    You need one form with form color set to &H00FF00FF&: picture on the form, a picturebox: blank, a label, and a timer with interval of 10. I posted the code for the form and the module is an attachment. Make sure you put the blank picturebox on top of the graphics that will show, it is what closes the window, that is if you want to see it in action.


    Form Code
    Vb Code Code:
    1. Private Sub Form_Load()
    2.  
    3. AutoFormShape clock, RGB(255, 0, 255)
    4. clock.Show 1
    5. End Sub
    6.  
    7.  
    8. Private Sub Image1_Click()
    9. End
    10. End Sub
    11.  
    12. Private Sub Timer1_Timer()
    13. Label1.Caption = Time
    14. End Sub
    15.  
    16. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    17. Const WM_NCLBUTTONDOWN = &HA1
    18. Const HTCAPTION = 2
    19.    Call ReleaseCapture
    20.    SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    21. End Sub
    Attached Files Attached Files
    Last edited by Brian M.; Jul 23rd, 2007 at 03:55 PM. Reason: update code

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Form Drag Problem

    Did you friends do a formal installation from a setup package you created or did you just copy an exe file over to them?

  3. #3

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Re: Form Drag Problem

    I just sent them an exe. It didn't work because it wasn't a registered window? I would hate for it to be a complicated procedure just to share a cool looking clock with my friends. Any help will be appreciated.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Form Drag Problem

    I just sent them an exe.
    That would be your problem then... see the article Why doesn't my program work on another computer? from our Classic VB FAQs for the explanation and solution.

    It does not need to be a complicated procedure.. unless you intentionally make it complicated, they will simply install the program just like any other.

  5. #5

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Re: Form Drag Problem

    Ok, it makes sense. But how do I know what files to include? The only external files I used was a bmp, and that was compiled into the exe and worked on the other computers. What files will I need to include to make it drag around, some vb runtime dlls or something? Also, will it work if I don't add a registry entry or use a self extracting exe? I read the post but it was a little vague on which files to include. Thanks.

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Form Drag Problem

    If you load a picture file at design time, it is complied into your program, and does not need to be distributed separately.

    The files you need to distribute are the ones that are external to your executable (eg: if you load pictures with code), as well as vb runtime DLL's etc.

    You probably don't need to worry about what the DLLs etc are, as the program you use to create the installation package should work it all out for you (as long as it is set up for VB6). The Package & Deployment Wizard that comes with VB will do it, even tho it isn't the best (see the Deployment FAQ for links to 'issues') it is probably the easiest to use.

    You don't need to add registry entries etc, as the installation package will do that for you.

  7. #7

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Re: Form Drag Problem

    I tried to use the package and deployment wizard, but it still won't let the window drag after its installed. Any ideas?

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Form Drag Problem

    As you included values in your code (rather than constants as would be advised) I compared them to a working example, and found that you are using unusual values.

    Here is code that works for me:
    Code:
    Const WM_NCLBUTTONDOWN = &HA1
    Const HTCAPTION = 2
       Call ReleaseCapture
       SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&

  9. #9

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Re: Form Drag Problem

    Thanks. I did not write that code, but that snippet you gave me above will be saved for future reference. When I get home from work this afternoon, I will try it on my xp computer.

  10. #10

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Re: Form Drag Problem

    Well I tried to use the code you gave me. I updated the form code above with it, I put it where I thought it would go, and I even made an installer from it, but it still doesn't drag on xp. Maybe I put it in the wrong place?

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Form Drag Problem

    Instead of using the MouseDown event, you should be using MouseMove.

    Here is a full example:
    Code:
    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 Declare Sub ReleaseCapture Lib "User32" ()
    Const WM_NCLBUTTONDOWN = &HA1
    Const HTCAPTION = 2
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
        Dim lngReturnValue As Long
        If Button = 1 Then
            'Release capture
            Call ReleaseCapture
            'Send a 'left mouse button down on caption'-message to our form
            lngReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
        End If
    End Sub
    Private Sub Form_Paint()
        Me.Print "Click on the form, hold the mouse button and drag it"
    End Sub

  12. #12

    Thread Starter
    Lively Member Brian M.'s Avatar
    Join Date
    Nov 2006
    Location
    Moberly MO
    Posts
    94

    Re: Form Drag Problem

    Hey thanks si! It works like a charm now, and I don't even need to make an install for it. I just copied the exe to my zip drive and it ran on my xp computer from it just fine. Now I can start with the custom windows I had in mind. I'd give you more rep but it won't let me, seems you are one of the few that actually answer my questions. I will pass you some rep when I can.

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Form Drag Problem

    Quote Originally Posted by Brian M.
    I don't even need to make an install for it. I just copied the exe to my zip drive and it ran on my xp computer from it just fine.
    You do need to make an install for it.. but as you have already installed the required files on that computer, you are currently in a situation where you can get away with this.

    Whenever you add new components/references, you will almost certainly need to install it on that computer.

    When you want to use the program on other computers, you should install it.

    I will pass you some rep when I can.
    Thanks, but there's no need - knowing I helped solve the problem (along with your thanks) is enough for me.

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