|
I have a PictureBox on a Panel,
I want my PictureBox can move on the Panel by the mouse,
my mouse's drag and drop just change the position of the PictureBox,
I know it's a simple question but I can't find any examples,
Can anyone tell me where I can find a example...??
|
|
|
|
|
<br />
Dim Xstart As Integer<br />
Dim Ystart As Integer<br />
Dim movin As Boolean<br />
Const Increment As Integer = 10<br />
Const TrueMotion As Boolean = False<br />
Const MOE As Integer = 5<br />
Private Sub Panel_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMain.MouseMove<br />
If movin Then<br />
Dim ThisPanel As Panel = CType(sender, Panel)<br />
Dim moveX As Integer<br />
Dim moveY As Integer<br />
If TrueMotion Then<br />
moveX = Me.MousePosition.X - Xstart<br />
moveY = Me.MousePosition.Y - Ystart<br />
Else<br />
moveX = Me.MousePosition.X - Xstart - ((Me.MousePosition.X - Xstart) Mod Increment)<br />
moveY = Me.MousePosition.Y - Ystart - ((Me.MousePosition.Y - Ystart) Mod Increment)<br />
End If<br />
ThisPanel.Top = moveY<br />
ThisPanel.Left = moveX<br />
pnlBlack.Left = ThisPanel.Left - pnlWhite.Left<br />
pnlBlack.Top = ThisPanel.Top - pnlWhite.Top<br />
If ThisPanel.Top + MOE >= pnlWhite.Top And ThisPanel.Top - MOE <= pnlWhite.Top And ThisPanel.Left + MOE >= pnlWhite.Left And ThisPanel.Left - MOE <= pnlWhite.Left Then<br />
Label1.Visible = True<br />
Else<br />
Label1.Visible = False<br />
End If<br />
End If<br />
End Sub<br />
<br />
Private Sub Panel_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMain.MouseDown<br />
movin = True<br />
Dim ThisPanel As Panel = CType(sender, Panel)<br />
ThisPanel.BorderStyle = BorderStyle.FixedSingle<br />
Xstart = Me.MousePosition.X - ThisPanel.Left<br />
Ystart = Me.MousePosition.Y - ThisPanel.Top<br />
End Sub<br />
<br />
Private Sub Panel_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMain.MouseUp<br />
movin = False<br />
Dim ThisPanel As Panel = CType(sender, Panel)<br />
ThisPanel.BorderStyle = BorderStyle.None<br />
If ThisPanel.Top + MOE >= pnlWhite.Top And ThisPanel.Top - MOE <= pnlWhite.Top And ThisPanel.Left + MOE >= pnlWhite.Left And ThisPanel.Left - MOE <= pnlWhite.Left Then<br />
Me.Close()<br />
End If<br />
End Sub<br />
<br />
Private Sub btnNewPanel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewPanel.Click<br />
Dim Newpanel As System.Windows.Forms.Panel<br />
Newpanel = New System.Windows.Forms.Panel()<br />
Newpanel.Location = New System.Drawing.Point(50, 50)<br />
Newpanel.BackColor = System.Drawing.Color.FromArgb(255, 192, 192)<br />
Newpanel.Size = New System.Drawing.Size(40, 40)<br />
Me.Controls.Add(Newpanel)<br />
AddHandler Newpanel.MouseUp, AddressOf Panel_MouseUp<br />
AddHandler Newpanel.MouseDown, AddressOf Panel_MouseDown<br />
AddHandler Newpanel.MouseMove, AddressOf Panel_MouseMove<br />
End Sub<br />
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
Thank you very much ~
I forget to say I use C# language...
I read your code and mostly know what I should do in every event handler,
but I still have some questions,
1.
During MouseMove,if I don't use a ---(dot line) Rectangle,
would the picture in the PictureBox flicker...??
And how to draw the Rectangle...??
2.
And mouse events should be write in the PictureBox_MouseXX or Panel_MouseXX...??
Thank you for your answer
|
|
|
|
|
When the application is running,how can i update the componets (dlls)the app used?
thanks a lot
|
|
|
|
|
How can make the tcpchannel stop listening the port without stop de application?
Thanks a lot!
|
|
|
|
|
hi,
You can do so by using :
System.Runtime.Remoting.Channels.Tcp.TcpChannel().StopListening();
method...
Hope this solves your prob...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
o, thanks for your replying!
but it seems do not work as expected!
the port is still open,then i use System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel ,and it's ok!
thanks a lot,my dear friend!
|
|
|
|
|
It might have worked but it doesnt seem to be the correct procedure. The next time you need the tcpchannel to listen again then you have to register it. Succedding calls mean registering and unregistering the channel and thats quite tedious process and surely wud entail performance penalty. Is there other way we cud do that?
|
|
|
|
|
I cant debug my project, as it is opened in a readonly mode. Does anyone know how to turn off the readonly mode? privileges??
I am logged in as Administrator.
|
|
|
|
|
hi,
As far as I guess, a project can go into readonly mode probably in 2 senarios...
one: The project is on a network drive and somebody else is already accessing the project
Two : The project is "checked in" in VSS or any other source control.
In possibility no :2 all you need to do is go to the project folder, select all the files and right click to get properties.
In property window uncheck the readonly attribute and you are done.
Hope this solves your problem... sorry if I'm wrong...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
I have a question about PictureBox:
I use a PictureBox to show my picture,
Now if I want to insert some small pictures on it,
I am not sure how many pictures will be inserted,
How can I show and save the positions of these pictures,
then I can show it next time...??
Please give me a hand,thanks a lot ~
ps.I use C# language
|
|
|
|
|
First, this should have been posted in the C# forum.
I use a PictureBox to show my picture,
Now if I want to insert some small pictures on it,
I am not sure how many pictures will be inserted,
How can I show and save the positions of these pictures,
then I can show it next time...??
The easiest way to do this would be using GDI+. You can draw each little picture separately, and store their positions in arrays. Then when the form closes, save the array into a textfile.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
When I make an installer project I get a set of files that have to be either zipped or packaged somehow. Is it possible to use .NET to make a setup .exe only containing everything I need?
|
|
|
|
|
You should create a project whose type is a setup project. By doing so you can assign the files needed to get installed by using the filesystem editor(the area where you can see the application folders and the likes...). When you build the project it will create a setup.exe and its equivalent .msi file. Both are executable files
|
|
|
|
|
i have the same problem, when i made a new deployment prject..on build i must exclude the .net framwork from the project, so i must install it separete on the client machine, have u got any way to include the dot net framwork on the project? else i want to include the internet explorere update and the mdac 7.2
|
|
|
|
|
http://www.codeproject.com/dotnet/dotNetInstaller.asp?target=bootstrapper
It seems to be the program going around to install the .NET framework with our applications.
|
|
|
|
|
Does anyone know how to set environment variables in .NET?
|
|
|
|
|
The System.Environment class has methods to read the environment variables. However, this class has no method to set the environment variables for the current process.
To work around this problem, use the interop services to set the environment variables. Use SetEnvironmentVariable function.
ex
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
namespace SetEnv
{
///
/// Summary description for Class1.
///
public class SampleSetEnvironmentVariable
{
// Import the kernel32 dll.
[DllImport("kernel32.dll",CharSet=CharSet.Auto, SetLastError=true)]
[return:MarshalAs(UnmanagedType.Bool)]
// The declaration is similar to the SDK function
public static extern bool SetEnvironmentVariable(string lpName, string lpValue);
public SampleSetEnvironmentVariable()
{
}
public static bool SetEnvironmentVariableEx(string environmentVariable, string variableValue)
{
try
{
// Get the write permission to set the environment variable.
EnvironmentPermission environmentPermission = new EnvironmentPermission(EnvironmentPermissionAccess.Write,environmentVariable);
environmentPermission.Demand();
return SetEnvironmentVariable(environmentVariable, variableValue);
}
catch( SecurityException e)
{
Console.WriteLine("Exception:" + e.Message);
}
return false;
}
}
class MyClass
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
// Create a sample environment variable and set its value (for the current process).
SampleSetEnvironmentVariable.SetEnvironmentVariableEx("TESTENV", "TestValue");
// Verify that environment variable is set correctly.
Console.WriteLine("The value of TESTENV is: " + Environment.GetEnvironmentVariable("TESTENV"));
}
}
}
Hi all this is Deeps..
|
|
|
|
|
During loading HTML page into HTMLDocument (IHTMLDocument2.write method), how could be launching of scripts in that page prevented?
|
|
|
|
|
Anyone out there know of a .net control for writing/printing cheques?
Can't seem to find anything!
Thanks, Brent
|
|
|
|
|
Do people still use cheques?!?
[Sorry, I don't know of such a control]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Most people don't
Most Businesses still do :*)
Brent
|
|
|
|
|
|
I wish there was an advanced .NET board but here goes.
Does anyone have experience with sending faxes from a .NET Website? I believe I am looking for a service that would allow someone to fax a PDF document or the actual web page to someone. I have looked around and saw a few but I am not sure about the system requirements. It looks like some of them are Web Services with no installations which is good (I think). It will be on a shared hosting plan but hopefully my shared hosting plan if anything special is needed.
Thanks.....Rob
Rob Taylor
www.tconsult.com
|
|
|
|
|
My colleagues and I are using .NET 2003 along with visual source safe on our developments. We keep running into compilation problems where we have multiple projects in our solution and some of the projects have references to other projects in the same solution. We keep getting errors when we compile saying that Visual Studio can't copy the dlls that we are making into the runtime folder because they are being held by another process. We've tried endless permutations of the Copy Local property on each of the references.
Has anyone run into similar problems?
does anyone know how to help?
Thanks.
|
|
|
|