473,659 Members | 3,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shape DragOver and DragDrop

PM
Hi,

Im a student currently designing a game for a project.

As part of my game, I want to be able to drag a shape over a series of
panels. The shape needs to be able to be dropped on any of the panels.

If the shape is dropped outside any of the panels, I want it to be
returned to its original position.

Does anyone have any hints to the code I should be using?

Thanks

Jan 3 '06 #1
3 2203
PM wrote:
Hi,

Im a student currently designing a game for a project.

As part of my game, I want to be able to drag a shape over a series of
panels. The shape needs to be able to be dropped on any of the panels.

If the shape is dropped outside any of the panels, I want it to be
returned to its original position.

Does anyone have any hints to the code I should be using?

Thanks


You want to post in comp.sources.wa nted. This group is for discussing
C++ *language* issues, not platform-dependent applications. See the FAQ
for what is on topic here and for some additional suggestion of where
to post:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Cheers! --M

Jan 3 '06 #2
PM wrote:
Hi,

Im a student currently designing a game for a project.

As part of my game, I want to be able to drag a shape over a series of
panels. The shape needs to be able to be dropped on any of the panels.

If the shape is dropped outside any of the panels, I want it to be
returned to its original position.

Does anyone have any hints to the code I should be using?

Thanks


Hi,

This news group discuss the C++ language as defined by the ANSI/ISO
standard; Therefore, I assume that your "game", "shape" and "panel"
objects are standard C++ classes and further assume that you have the
methods "drop(const shape&)" and "position() " implemented somewhere in
your code.

If so, I guess you need a loop over all panels and an if-statement to
check that the shape is within all panels and a method to set the
position of your "shape" object.

If not, go to a more appropriate news group.

Regards,
Peter Jansson
http://www.jansson.net/
Jan 3 '06 #3
It will depend heavily on the GUI framework you're using, and specific
questions about that will have to be addressed in another forum than
this one. However, I can give you a general indication of how that
functionality is likely to be implemented.

GUIs are generally implemented with an event loop. Events such as
mouse clicks occur, and you write handlers for them. Often it's rolled
up into a big switch statement, with a case for each kind of event.
Some pseudocode for a case like you described:

void processEvent(Ev ent e) {
switch (e.eventType) {
case MOUSE_DOWN:
// Grab hold of a shape
break;
case MOUSE_UP:
if (draggingShape)
if (inPanel())
dropShape();
else revertShape();
break;
// etc.
}
}

HTH,
Luke

Jan 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
5838
by: Kate | last post by:
Hi: I have a form with a picture box and some command buttons to make certain shapes appear in the picture box. The shapes are drawn on blank UserControls added like this: 'at top of form module Dim WithEvents tc As testControl 'button1_click (for example)
0
1677
by: asra_baig | last post by:
Wherever I see the dragOver(DropTargetDragEvent ev) method in the examples, it calls the dropTargetDrag(DropTargetDragEvent ev) method which calls ev.acceptDrag method. I can't seem to find when is dropTargetDrag called apart from by dragOver. Does anyone have the answer? -Asra
1
2518
by: KS | last post by:
In want to visualy drag a Button to a Label and when I depress the mousebutton on top of the label I want to show some dato from the Button in a MsgBox - that's my primary goal. I have made a simple sample code - a form with a Button1, a Label1 and a Timer1. The Button1 has Tag="SomeData", the Label1 has AllowDrop=True and the Timer1 has an Interval=20.
0
1310
by: Flack | last post by:
Hello, Is it possible to find out how many methods are listening to a certain event? For example, if a number of methods subscribed to a controls DragDrop event using +=, can I find out how many methods in total are listening to the DragDrop event of the control? If I can't find out the exact number of methods listening to the DragDrop event, can I somehow remove all listeners of that event at once? I tried using m_Control.DragDrop =...
0
1011
by: Gene Hubert | last post by:
Well, it seems fundamental to me anyway. Hopefully it is simple enough. The question is for when the source for the dragdrop is a different application that the target for the dragdrop. How does the source for the dragdrop operation know that a drop has been completed onto a valid target? And then, how does the source know what the drop target is? I've got dragdrop working within my application but I can't see any
3
3786
by: Gary Dunne | last post by:
I'm writing an app that requires drag and drop operation between a ListView and a TreeView control. (The source is the ListView). During the drag drop operation I want to be able to detect the target node in the treeview and auto expand it if applicable... but after a fair bit of head scratching I can't find any easy way to accomplish this. I think what i really need is the equivalent of the HitTest method from the COM version of the...
7
3995
by: JohnR | last post by:
I am using dragdrop to drag and drop a custom class instance. When I drag/drop from one window to another window in the same application everything works fine. But when trying to move between the same windows running in different instances of the application the "dropped" data comes across as a system.__ComObject and I can't CType it to my class to extract the data. I've been searching for hours and haven't found any solution so I am...
1
11347
by: Gary Brown | last post by:
Hi, I just implemented drag drop in one of my programs. In researching there are implementations that use DragEnter, a few use DragOver, and a some use both. From the available documentation it is difficult to tell just why this is. Can someone clarify? Thanks, Gary
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.