Click here to Skip to main content
16,005,316 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Drag image on dialog box at run time Pin
rjkg8-May-07 22:53
rjkg8-May-07 22:53 
GeneralRe: Drag image on dialog box at run time Pin
_AnsHUMAN_ 9-May-07 0:20
_AnsHUMAN_ 9-May-07 0:20 
GeneralRe: Drag image on dialog box at run time Pin
rjkg9-May-07 1:10
rjkg9-May-07 1:10 
QuestionRe: Drag image on dialog box at run time Pin
Mark Salsbery9-May-07 5:05
Mark Salsbery9-May-07 5:05 
AnswerRe: Drag image on dialog box at run time Pin
rjkg9-May-07 19:27
rjkg9-May-07 19:27 
QuestionRe: Drag image on dialog box at run time Pin
Mark Salsbery10-May-07 5:17
Mark Salsbery10-May-07 5:17 
AnswerRe: Drag image on dialog box at run time Pin
rjkg10-May-07 19:40
rjkg10-May-07 19:40 
GeneralRe: Drag image on dialog box at run time Pin
Mark Salsbery11-May-07 4:42
Mark Salsbery11-May-07 4:42 
You can break this down into easier steps...

1) Load the bitmap
2) Sometime in or after the WM_INITDIALOG message is received in the dialog, calculate the rect
the image will be initially drawn at (relative to the client area of the window).
3) If you just want to draw the image on the face of the dialog, add a WM_PAINT handler to the
dialog which draws the image at the image rect position

That'sll get your image drawn in one place on the dialog. Now you want to be able to drag it...

1) Add handlers for the WM_LBUTTONDOWN, WM_MOUSEMOVE, and WM_LBUTTONUP messages.
2) When you receive a WM_LBUTTONDOWN, check if the cursor is within the image rect.
If it is, store the current cursor position and call SetCapture() to capture the mouse to your
window.
3) When you receive WM_MOUSEMOVE, call GetCapture() to see if you are in a drag (if the mouse is
captured to your window). If yes, compare the cursor position with the position saved in step 2.
If it has changed, then the position difference is how far you need to offset the image rect.
Erase the previous image, offset the image rect, and redraw the image at the new rect.
4) When you receive WM_LBUTTONUP, call ReleaseCapture().

Here's sample code: Using Mouse Input[^]

If you have a more specific problem with any of the steps outlined above then just ask Smile | :)

Mark


"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

AnswerRe: Drag image on dialog box at run time Pin
Hamid_RT9-May-07 7:13
Hamid_RT9-May-07 7:13 
Questionuploading a file Pin
p_8-May-07 22:11
p_8-May-07 22:11 
AnswerRe: uploading a file Pin
_AnsHUMAN_ 8-May-07 22:13
_AnsHUMAN_ 8-May-07 22:13 
AnswerRe: uploading a file Pin
David Crow9-May-07 2:48
David Crow9-May-07 2:48 
AnswerRe: uploading a file Pin
ThatsAlok16-May-07 20:34
ThatsAlok16-May-07 20:34 
QuestionOne Istance of the application Pin
Kiran Pinjala8-May-07 21:53
Kiran Pinjala8-May-07 21:53 
AnswerRe: One Istance of the application Pin
GuyM8-May-07 22:07
GuyM8-May-07 22:07 
GeneralRe: One Istance of the application Pin
Kiran Pinjala9-May-07 0:06
Kiran Pinjala9-May-07 0:06 
AnswerRe: One Istance of the application Pin
ThatsAlok16-May-07 20:33
ThatsAlok16-May-07 20:33 
Questionhttp request Pin
deeps_cute8-May-07 21:52
deeps_cute8-May-07 21:52 
AnswerRe: http request Pin
_AnsHUMAN_ 8-May-07 22:24
_AnsHUMAN_ 8-May-07 22:24 
GeneralRe: http request Pin
deeps_cute8-May-07 23:00
deeps_cute8-May-07 23:00 
GeneralRe: http request Pin
_AnsHUMAN_ 9-May-07 0:38
_AnsHUMAN_ 9-May-07 0:38 
QuestionRe: http request Pin
David Crow9-May-07 2:50
David Crow9-May-07 2:50 
AnswerRe: http request Pin
Hamid_RT9-May-07 7:04
Hamid_RT9-May-07 7:04 
QuestionAdding window form to VC 6.0 MFC App Pin
zubair_ahmed8-May-07 21:42
zubair_ahmed8-May-07 21:42 
AnswerRe: Adding window form to VC 6.0 MFC App Pin
Christian Graus8-May-07 21:52
protectorChristian Graus8-May-07 21:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.