Moving a Static box with the mouse

This is a discussion on Moving a Static box with the mouse within the Windows Programming forums, part of the Platform Specific Boards category; is there a way to move a static box allong with the mouse when you click? i need to have ...

  1. #1
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120

    Moving a Static box with the mouse

    is there a way to move a static box allong with the mouse when you click? i need to have it be able to move it like i was dragging it along and placing it in another position. i am useing c++ and the windows api any help would be appriciated
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,266
    A... stah... tic... box...?

    What do you mean? Do you mean a static control (Set up to be a box), in which case it's a window and you use MoveWindow inside your main window's WindowProc, for the WM_MOUSEMOVE message (The wParam or lParam gives you the details on the mouse, I don't know it off the top of my head, try MSDN).

    Or, if you mean a rectangle that you draw yourself (Which would be static if it isn't moving) then you'd just have a global RECT structure and update it with the mouse and it will be drawn in its new position via your (Properly written) WM_PAINT handler.

  3. #3
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120
    omg ok, thanks for the input, i was doing it correctly but in the MoveWindow function i had repaint set to 0 so nothing was happening, hahahaha thanks again
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

  4. #4
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120
    ok so is there an easy way to find which window holds the mouse and move only that window? would i use getcapture or what?
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    70
    Ya.....you can use GetCapture() to determin which window holds mouse....

    One another solution to determine on which window mouse is currently moving is to use api WindowFromPoint() . If window you get from this function is same as you static box window then you can move your static box window accordingly.
    Chintan R Naik

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Moving objects with mouse in 3D.
    By psychopath in forum Game Programming
    Replies: 15
    Last Post: 07-10-2011, 05:20 PM
  2. Moving mouse
    By Bill83 in forum Windows Programming
    Replies: 1
    Last Post: 04-02-2006, 09:58 AM
  3. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 06:48 PM
  4. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  5. how to set the background colour of a static box?
    By Cobras2 in forum Windows Programming
    Replies: 2
    Last Post: 08-01-2002, 05:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21