I'd like a tutorial on how to drag and drop. Something like
the Solitaire game in windows 98. But with one additional
condition. Variable Source and variable destination.

Posted on 2001-08-02 12:12:25 by shankle
Hmm, what do you mean by drag and drop? If you mean dragging and dropping files then theres an example of that in the Example3 subfolder of masm32.

If however you mean something completely differnt, namely something like whats in Solitaire then be slighty more specific about what you mean when you say "Variable Source and variable destination".

Do you just want to be able to click on an object an move it somewhere else inside the window? If so thats not too hard.
Posted on 2001-08-02 12:40:06 by Eóin
Thanks for the reply.

Yes I want to pick up (for instance the letter A in a small square)
from anywhere on the screen and move it to somewhere alse
on the screen.
The example in MASM32 doesn't quite do this.
Posted on 2001-08-03 08:14:07 by shankle
Ok, there no point writing a tutorial on something like that simply because theres a couple of ways of doing it and each one has its own merits depending on the situation.

Instead why don't you describe to me what you want to do and I'll show you the solution I think best fits your problem. I can even code it for you, I don't mind.
Posted on 2001-08-04 03:05:14 by Eóin
thanks for your offer to help.

First I've looked in Hutches Windows inc for what I thought
were drag and drop API's. Couldn't find any.

Let's say The Letter A is in a square of 30 by 30 pixels at
position 100 by 100. It's a bitmap. I want to move it to
400 by 400. I want to to reinstate at 100 by 100 whatever
was there before I placed the bitmap at that position.
The position at 100 by 100 is a holding area.

Using Hutches MASM32 and windows 98.
Assembler is not my problem but windows APIs are.

Posted on 2001-08-04 09:09:18 by shankle

I think shankle means like a deck of cards, one on top of the
other. Drag the top one off showing the one beneath. I know
how to drag something around a window simply by erasing
getting the current mouse position then repainting the object.

I?d like to know myself how you?d accomplish shankle?s needs.

I assume you would load 52 bitmaps and use an indexing method
of some kind to keep track of the bitmaps handle and position in
the deck.

That might make an interesting tut. :)
Posted on 2001-08-04 11:03:30 by bcraven
Sure I'll write one for that method, see how it turns out.
Posted on 2001-08-04 11:20:32 by Eóin
perhaps i've a program that could be interesting for you. it has something to do with drag & drop, but have a look at it yourself.
my homepage: www.noperator.cjb.net
just click on win32asm, and choose "Color mixing".

tell me if you like it.

Posted on 2001-08-05 03:11:42 by NOP-erator
[-alloces-], I love the site, its so easy to navigate and I ove the full description of each program.

I was going to use a backbuffer as well. I'll still finish what I ws doing seen as yours is specially written for 3 and I felt shankle would need a more addaptable drag and drop program.

I love your programs though I culd seem to get the electric filed lines one to work. the screen stayed blank.

And shankle, hopefully I'll have that ready for tonight.
Posted on 2001-08-05 06:56:11 by Eóin
thank you very much Zadkiel. sorry that this Electrical field program doesn't work on your system, but what OS are you running on?
i know that there are problems with NT, and so will be with win 2000.

Posted on 2001-08-05 07:41:53 by NOP-erator
What a strange little tutorial this turned out to be. I started it with some ideas on different methods and I was sort of annoyed that I'd have to chose one and implement it without the benifit of hindsight to know which one was the best.

Well as it happend the most difficult thing was screen flicker and I ended up merging every idea I had into one program just to eliminate that.

I tell you windows isn't designed for graphics. Another thing about this is its lenght which means I'm never happy that I explained the important aspects of it well enough so I'd appreciate feedback.

And NOP-erator, looking back at my post I must congradulate you on translating my spelling, how I typed culd istead of couldn't I don't know.

But regarding the electric filed program, I'm using win98. everything else seemed to run ok but that didn't, maybe its my computer though. If I get a chance I'll look at the source and see if anything pops out at me.
Posted on 2001-08-05 18:36:11 by Eóin
Hi Zadkiel,

Thank you very much for your time and effort with my
Drag and Drop problem. Your program does just what
I need to do. Pick up a bitmap restoring what was underneth
before and placing it anywhere on the screen.

I guess my problem was I thought I had to use a lot of
Windows DODRAG etc. to keep it compatible with Windows.
Obviously I was wrong.

Posted on 2001-08-05 20:09:54 by shankle
hi Zadkiel,
you've done very good work! :alright: I just looked over the source, and it seems that you've solved that better than me! I'm gonna read your tutorial about that later.
But one thing disturbs me: when you drag the bitmap, the mouse pointer is always in the center of it. perhaps you can have a look at my program again and change that. when you drag my bitmaps, the mouse pointer stays where it is.

Posted on 2001-08-06 03:50:06 by NOP-erator
Thats not a bug, thats a feature ;) . By default onbjects would be dragged by the top left corner, since obviously this would look terrible I simply added code to move the object back and up a bit so that it would drag by its center.

To maintain the position of the mouse relative to the object as your program does you'd simply need two more variables eg dX and dY. When the object is first clicked set dX to ObjectLeft-MouseX and set X to MouseX+dX. Keep resetting X to MouseX+dX as the object is moved and it should work. Dont forget to repeat this Y also.
Posted on 2001-08-06 04:35:39 by Eóin
Actually the above suggestion clearly isn't tested, not least because I suggested dx as a variable name.

Instead following the

mov X,eax
mov Y,ecx

in the LBUTTONDOWN message put

sub eax,edi
sub ecx,esi
mov Xd,eax
mov Yd,ecx

And then in both the MOUSEMOVE and LBUTTONUP messages replace

mov ebx,plObj
mov eax,(DgDpObj ptr ).r.right
shr eax,1
movsx edi,lpLow
sub edi,eax
mov eax,(DgDpObj ptr ).r.bottom
shr eax,1
movsx esi,lpHigh
sub esi,eax

With this

movsx edi,lpLow
movsx esi,lpHigh
add edi,Xd
add esi,Yd

mov ebx,plObj

I hope thats correct.
Posted on 2001-08-06 05:02:03 by Eóin

Wow, great job you've done on the drag and drop tutorial.
Its easy to follow and understand, very creatively coded.
You have a knack for making it all look simple. This old DOS
programmer envies your knowledge of graphics programming
in Windows. Its certainly a totally different environment to
program in then what I grew up with. This old programmers
learning the ins and outs of Windows coding though thanks
to young guys such as yourself. Keep up the good work!:alright:

I'll be keeping my eye out for more tuts!:grin:
Posted on 2001-08-06 08:24:58 by bcraven