Problem in Drag And Move Forms in .Net - c#

I Write a Windows Application By C Sharp.
I Use a Picture in Background of my Form (MainForm) And I Use Many Picture in Buttons in This Form,And also I Use Some Panel And Label with Transparent Background Color.
My Forms,Panels And Buttons has flicker. I solve this problem by a method in this thread.
But Still when other Forms Start over this Form,my Forms hangs when I Drag and Move my Forms over this Form.How can I Solve this Problem to Move And Drags my Forms easily And Speed?
Edit::
My Forms Load Data From Access 2007 DataBase file.I Use Datasets,DataGridViews And Other Components to Load And show Data in My Forms.

You just made it less obvious that your form paints very slowly by using the techniques shown in my answer. The tricks don't speed it up, they merely make the ugliness less visible. But they fall flat when you have to paint your form from scratch, which happens when you move another window across it. The painting cannot keep up with the barrage of paint requests that are generated each time the overlapping form moves by one or more pixels.
An instant fix is to upgrade your operating system to Vista or Windows 7, windows don't overlap anymore with Aero enabled.

Related

Handle a canvas in a Windows Forms Application

I want to create a level editor, using a Windows Forms Application.
Here is the layout that i want to achieve:
BLUE -> Windows form control
PURPLE -> Canvas, handled differently (Yeah, Windows forms controls too, but not for the same use of it)
I have a problem though, how to render the Canvas in a proper way without using a thread ?
(Look at my other thread here: Access object from other thread)
I thought about a timer, but I don't know if it's reliable.
Ideally a thread would be nice but Windows doesn't like the fact that you want to interact between thread so it's messed up to be polite.
If you know how to achieve that, well, thanks ! :)

How do I set form size and location synchronous

I made custom borders for my application, like the VisualStudio 2012
There is one central mainform and 4 smaller, dynamically positioned border forms.
In the mainform I have overidden the events OnMove, OnSizeChanged, OnActivate, OnDeactivate.
In those events I set the location, size and color of the borders.
It works quite nicely, but there is some awful artifacts!
Those are the same artifacts that appear when resizing ANY window.
I made a video with my application to show what kind of atrifacts I mean.
Those appear when moving or resizing the window.
Obviously this problem IS solveable, because VisualStudio2012 does it too (meaning that it doesn't have the problem. Just try it, resize the VS2012 window, it won't flicker)
In my implementation I used the same way that VS2012 uses: 4 layered windows that make up the border of the form.
In case someone doesn't the glitches I'm talking about. Here's the video:
http://youtu.be/kKiPke8ruaI
What I need is a way to "synchronously" set the location and size of the 4 border windows.

How do I create transparent labels over a Video control

I'm pretty much out of ideas here... for everything else, setting the background color to Color.Transparent or setting the TransparencyKey works fine...
I have an mp4 Video which I need to play as a "background" of my form. To do this, I'm currently using the WMP control. My problem: I can't add any controls on top of it, since they always render a background. Which looks ** on the video...
Any suggestions?
A hack I've used successfully in a similar situation:
Create a separate, borderless, transparent form (transparency works best at the Form level)
Host button controls on that form
Launch the control form when your video form launches
Wire event handling such that the floating form always moves, resizes etc. whenever the main form changes
Calculate position of the floating for based on parent form's specs
Always push the floating form to the top, above the parent form
Told you it was a hack. But if you get all the events and calculations wired up it should work fine.
P.S. I also recall having to do a poll timer with a function that made sure every 250 millis or so that the Z-order of the two forms was what you wanted. (Switching apps and windows changed the z-order unexpectedly and w/o events, thus the polling solution.)
P.S. II It is very easy to prototype the feasibility of this solution. Just create a separate app with the above-mentioned specs and move it over your video. (You will need to retain the Form border to be able to move/resize the window easily.)
Try rendering your labels using GDI+:
You can see sample here: (the Using GDI+ for drawing images with transparency part):
http://www.broculos.net/en/article/how-use-transparent-images-and-labels-windows-forms

I want to drag an image from a Silverlight UIElement and drop it on the users Desktop or Windows Explorer

I have a Silverlight control containing an image. I want the user to be able to drag the image out of the Silverlight application and drop it anywhere they would be able to drop an image. For example, to the Desktop or to a PowerPoint slide or Word document. Everything that I have read thus far says it cannot be done but I find that hard to believe. I'm very new to Silverlight and RIA development so any help would be much appreciated.
Below is the code sample in my WinForm Form but the drag never starts.
string[] aString = { imagePath };
DataObject data = new DataObject(DataFormats.FileDrop, aString);
data.SetData(DataFormats.StringFormat, imagePath);
DoDragDrop(data, DragDropEffects.Copy);
Well the trouble is that a drag operation in Silverlight doesn't have simple access to anything outside the browser (by design). Depending on the user's settings you even have to get explicit permission for clipboard operations and sandboxed temporary file storage. This really sounds like a task better suited to a WPF application (perhaps with web deployment?) or some other desktop application technology.
However, that being said here are some things you could try/consider:
Silverlight/Javascript/ActiveX combination hosted in Internet Explorer
Silverlight 5 "Out of Brower" & P/Invoke (I heard P/Invoke will be supported when Silverlight 5 comes out)
Silverlight connecting to a web service running on the same computer (crazy, but you didn't ask for "not crazy", you asked for possible)
I am not very familiar with drag and drop in the Win32 API so it would take a lot of research and experimentation before I could confirm that this was even possible (and I can already tell you it isn't practical).
Edit: Based on the extra information you provided about the question I suspect it is possible to do what you are attempting. First, are you using WPF or WinForms? I assume WPF but one of your comments says WinForms. I wasn't very familiar with WPF drag/drop operations, but having looked into it, I think your code is on the right path. I created a WPF application and initiated a drag during a KeyDown event. This meant that the mouse button was not necessarily pressed. If I initiated the DragDrop while the button was down it worked. If I initiated while the mouse button wasn't down, I had to push the mouse button down and the drag operation would start (this was unexpected since I assumed the mouse would have to already be down). If I pressed the mouse down outside the application, then gave the WPF app focus (ALT+Tab), then initiated the DragDrop while the mouse button was still down, it didn't work. I got a reference to the MouseDevice and checked the LeftButton property, and the state was showing as "Released" even though the button was still being held down. It seems the key here is the way drag/drop interacts with internal mouse state. You might have to find a way to set the mouse state (maybe with the UI Automation API?). At this point it should be painfully obvious that this whole thing is a hack (even though it is probably possible to get it to work somehow).
The solution we came up with was as follows. The RIA i.e. Silverlight sends a message to our Desktop application WinForms with the path of the image to drag along with the bounding rectangle in screen coordinates that we want to start the drag from. The Desktop code creates and places a Panel over the area that we want to drag from. This panel is where we use DoDragDrop to initiate the native drag when the user left clicks. Since this panel is placed outside and above the silverlight control, everything works perfect. Sandbox defeated.
I have been working on some Silverlight apps for the past few months and fully investigated your exact requirements only to find it was not possible. I believe you can drag from the file system, from Silverlight control to control, but not to the file system.
Does Silverlight 4 support drag and drop from app to desktop?
http://msdn.microsoft.com/en-us/library/dd772166%28v=vs.95%29.aspx

Hiding the cursor in Windows CE

I have a fullscreen application running on Windows CE 6.0 which will only be manipulated using the finger or a stylus.
So I don't need the mouse cursor, which I'm hiding using Cursor.Hide().
However, when I use the stylus to manipulate something on the screen, the mouse cursor is printed while the stylus touch the screen.
Is there a way to make the cursor not show when touching the screen?
BTW: the application will be the only thing running, so system-wide solution are possible, but I'd rather keep it inside the application.
For a system-wide solution, in case you can create the OS, you can remove the mouse cursor component from the catalog (SYSGEN_CURSOR).
For a local solution here is a suggestion (never tried it):
You can replace the icon with a blank icon so you won't see any cursor while inside your form. Once you leave the borders of your form you can restore the usual icon.
Read How to use custom cursors. I checked that the Cursor class is available with the CF. There are two other functions needed to be P/Invoked that are available under CE:
GetIconInfo
CreateIconIndirect

Categories

Resources