Results 1 to 8 of 8

Thread: using Sendmessage on user control ....

  1. #1

    Thread Starter
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225

    using Sendmessage on user control ....

    i have one active-x control made by me it just have a frame and command button .. i wanted to move my control like window to any where on form ... i did it my Send message passing using control's hwnd with WM_NCLBUTTONDOWN window message in control coding .. its working fine but now if i want to move it from code in outer form i.e. i move it by proeprties like top,left etc. through my code it doesnt move.It changes it pos once only but not after that ... i m not able to changes its position in run time through coding ... API usage on frame's mouse move is liek this ....

    Private Sub frmCaption_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    Dim lngReturnValue As Long
    '// Detect the left mouse button
    If Button = 1 Then
    '// Release the capture of the mouse
    Call ReleaseCapture
    '// Move the form with the mouse
    lngReturnValue = SendMessage(UserControl.hwnd, WM_NCLBUTTONDOWN, _
    HTCAPTION, 0&)

    End If

    End Sub

    frame is some thing on which putting mouse i move/drag the control ...

    i think use of this API stuck the movement of control when i use it in some form when i say usercontrol1.top = somehting etc. any one can help ??
    Chander
    Email:[email protected]

  2. #2
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    lngReturnValue = SendMessage(
    UserControl.hwnd
    , WM_NCLBUTTONDOWN, _
    HTCAPTION, 0&)
    Try changing it to..
    lngReturnValue = SendMessage(
    UserControl.Extender.hwnd
    , WM_NCLBUTTONDOWN, _
    HTCAPTION, 0&)

  3. #3

    Thread Starter
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225
    i tested it .. while run time i move the control it says .. object doesnt support this property and get crash ...
    Chander
    Email:[email protected]

  4. #4
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    321
    why not try using PostMessage instead of Sendmessage?

  5. #5
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    Are you sure that you've set the WindowLess property to false and does contain a hwnd..
    If you just want to move the control.. why don't you set its left and top properties by the way?

  6. #6

    Thread Starter
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225
    move means i want to drag it like form ... it happens with normal controls like command button and works properly but with my control its not happening .. actually its moving but not going on same position again once i drag it if i move it to some other pos then it will go but again it will not go at same pos but will go at different pos .. the only prob i thinking is hwnd ... as there hwnd in normal control my control doesnt has hwnd .. how to get hwnd of a control ?? means there is usercontrol.hwnd but when my control is on form i dont hv its hwnd ....
    Chander
    Email:[email protected]

  7. #7
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    you want to move the control during design time? I think it happens automatically... and you don't have to code for achieveing this behavior...

  8. #8
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    to add the hwnd to the design and runtime instance of your control make a property hwnd and map is to UserControl.hwnd and for the runtime you'll have to use UserControl.Extender.hwnd

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