I need to know is some object being dragged over my Delphi application.
For example: while the user dragging some item from ListView to ListBox, or dragging some file from Explorer into my LitsView, I want to check at any moment is he still dragging or not dragging anymore.
Can I find this without hooking drag events?
Delphi XE
I would do this by making a note when the drag process starts, for example when IDropTarget.DragEnter is called. And then reset the flag when the DragLeave or Drop is subsequently called.
Related
I have created a game that basically add the numbers in the blocks to each other by dragging them on top of each other. It works great. But I would like to add sound effects to the drag and drop move that is being done with the floatanimation feature of the button. I couldnt see an event or a property that handles this action.
How could I include a sound effect to the floatanimation of the pressing, draggin and dropping of an object (such as button) ?
Thank you.
Raf.
try using TMediaPlayer, before you start your TFloatAnimation
I want to implement a OLE Drag&Drop feature. Doing this, I have to detect the mouse button is clicked and moved. Than I call DoDragDrop to start the Drag&Drop feature.
To receive the Drag&Drop feature, I have to call RegisterDragDrop before of it to register a window as a target of the Drag&Drop operation. Like the most applications, my main window based on several sub windows: TreeView, ListView, Edit, etc.. With IDropTarget::DragOver I can detect, if the target sub window accepts the Drag&Drop operation. This works fine, if I drag an object from a different application and the mouse cursor shows as well, if the target sub window accept the Drag&Drop operation.
But if I start the Drag&Drop feature inside my application with DoDragDrop the mouse cursor does now change automatically. Why?
So I can use the IDropSource::GiveFeedback method to change the cursor of the target sub window. But I can't find out, which sub window has to change the cursor.
If I'm right, the IDropSourceNotify should provide this informations. But how can I involve this class into the Drag&Drop operation?
Additional, I don't understand, why I have to handle the mouse cursor by my self, if the source window is inside my application - but it will be handled automatically, if the source window is inside an other application.
Last but not least, if I change the cursor of my sub window inside IDropSource::GiveFeedback it will be shown like I changed it. But since the my main thread is inside DoDragDrop I wonder how Windows detect the changed cursor. If I'm right, Windows ask my application with the WM_NCHITTEST message, which cursor should be shown. But how does my application answer this message, while the main thread is blocked inside DoDragDrop?
I'm working with Delphi XE4 on a Window 7 system.
The drop source should not make any assumptions about the drop target - and should never attempt to modify the UI of the target.
In other words: Do not mess with the cursor property of the control under the cursor.
The return value from IDropSource.GiveFeedback instructs Windows to either use the standard drag drop cursors or let you handle that detail yourself.
If you return DRAGDROP_S_USEDEFAULTCURSORS then the standard cursor corresponding to the current drop effect (the parameter passed to GiveFeedback) will be used. If you return S_OK then you can set the cursor by calling the SetCursor API function.
I would recommend that you just return DRAGDROP_S_USEDEFAULTCURSORS.
Actually unless you have a burning desire to learn the inner details of COM based drag and drop I would recommend you Google "drag drop delphi" and use one of the already available libraries.
I have recently come to need some popup menus to be linked with multiple TTreeViewItem controls. The first time, I right click any of the TTreeViewItems, the delay in the showing of the popup is enough to make me believe that the click didn't register somehow and then it appears. All the subsequent times I click, the reaction is instantaneous.
I have to make my applications so that they are compatible and smooth even on Pentium 4s and the subsequent buit-in horsepower of their generation.
To reproduce:
Place a TTreeView on an empty form.
Add 5 or 6 TTreeViewItems.
Add a TPopupMenu and add a single TMenuItem to it.
Link the TPopupMenu with 2-3 of the TTreeViewItems.
Optionally add another TPopMenu with a single TMenuItem and link with the rest.
Run the application and right-click on any of the TTreeViewItems.
Is there a method I can call to bring the popup menu into the cache immediately after form creation and also not make it visible in doing so?
In Google Chrome when you click the mouse wheel button you get this cursor:
And then you are able to scroll to all possible directions, when you move around with your mouse...
IE also has this, but only moves up and down:
Is there any component for Delphi that can do this? (for a TScrollBox for example)
TMemo, for example, can do that for you, provided you set its ScrollBars property to something else than ssNone. It will even adjust according to which scroll bars are enabled. Problem with TScrollBar component is that on its own it doesn't have any focusable parts and won't receive OnMouseWheel(/Up/Down) events, but its included windowed controls might. You could write a workaround for that on main form events, though. Check solutions at http://www.delphipages.com/forum/showthread.php?t=197309
EDIT: OnMouseWheel(/Up/Down) should be OnMouse(/Up/Down), thanks to #Sertac Akyuz for pointing this out ;)
Seems like this feature is available in RAD studio 2009 (but not in D7).
You need to use Imouse (imouse.pas unit) and the control must have ControlStyle of csPannable.
quote:
Imouse (imouse.pas unit) is a standard implementation of scrolling
with middle button (called also "mouse panning"). It's also used in
RAD Studio. Imouse functionality relays on standard window scrollbars
and sends WM_HSCROLL/WM_VSCROLL to the window to make it scroll. It
works on every window, that have a scrollbar (e.g. TListView,
TTreeView, even TForm/TFrame if AutoScroll is True and at least one
scrollbar is visible).
Oh, I've forgotten one thing. Control must have csPannable in
ControlStyle, but RichView hasn't by default. So, after adding Code:
RichViewEdit1.ControlStyle := RichViewEdit1.ControlStyle +
[csPannable];
I didn't test it though.
All that is left for me is to look into the source code (When I can get my hands on copy of D2009) and maybe impliment this with D7...
I have a wpf project which uses transparent windows and I share this transparent window styling for my dialog windows and my mainwindow.
I am getting an error on my DragMove() event of my MainWindow AFTER I close a dialog window that uses the same window style. To make this even more strange this exception only occurs when I handle a mouseleftbutton event on a label in my Status Bar on the MainWindow. IF I swap out the label for a button and replace the mouseleftbuttondown with a click event I do not get the error.
The strange thing is that the dialog window that pops up does not implement dragmove, and I'm not dragging around my mainwindow either. Somehow dragmove gets called after my code execution returns to the mainwindow after a showdialog() call.
An easy fix for me currently is to swap my label for a button and wire up the click event instead.
However, I'm more interested in hearing about what causes this issue and why a click event works but the mouse one fails miserably.
My "StatusBar" is simply a stackpanel with labels and other stackpanels (which contain more labels).
Has anyone else fought this issue before? Would I need to implement some sort of mouseclick event handler override so that I can capture and cancel this exception from happening?
Repro code can be provided if needed. I got enough hits on dragmove here so I am hoping this is an easy one for somebody out there.
Thanks in advance for any help!
my brain isn't working properly today. I forgot about routing of events in this scenario. I simply needed to set the Handled property on my routedevent that fired off when the mousebutton was down. Somehow I missed that in the debugger before posting the thread.
The 'correct' way to make a borderless window movable --> https://stackoverflow.com/a/3275712/146032
Be sure to only call DragMove when triggered by event MouseLeftButtonDown and don't forget to handle the event using e.Handled=true;
if you receive this exception when messagebox show complete. place Dragemove();
inside try and empty in catch.