|
Eddy Vluggen wrote: In VB6
that explains it
|
|
|
|
|
Hi..if sumone knows how to do it plz help i m a beginner in C#.
i have made the reactangle don't know how to drag it with the help of mouse and redraw it where i release the mouse button..
private void Shapes_Paint(object sender, PaintEventArgs e)<br />
{<br />
if (Square.Checked == true)<br />
{<br />
e.Graphics.DrawRectangle(Pens.Red, 180, 80, 80, 80);<br />
}<br />
if (Triangle.Checked == true)<br />
{<br />
e.Graphics.DrawPolygon(Pens.Red, new Point[] { <br />
new Point (300, 150), new Point(400, 250), new Point<br />
(200, 250) });<br />
}<br />
}
if i click mouse buton while the mouse is on top of the square, and then holds the mouse button down and drags the mouse, then the square will be dragged by the mouse:
1. As the square is being dragged, the mouse pointer should
remain over the same point on the square as it was when the
mouse was initially clicked. As the mouse is moving, the
square should move continuously with the mouse.
2. If the user clicks the left mouse button with the mouse
outside of the square and then drags the mouse, the square
should not move, even if the mouse is dragged over the
square.
|
|
|
|
|
Hi,
this is the scheme; items marked OPT are optional (they show the object in a different style while dragging):
1) add class members to keep track of rect position, hit position, ...
OPT: provide a bool "dragging"
2) inside MouseDown:
store mouse position
calculate and store hit position (the point going to be dragged around)
OPT: set dragging true and call Invalidate()
3) inside MouseMove:
calculate and store new rect position
call Invalidate()
4) inside Paint:
draw rectangle based on stored rect position (do NOT use Control.MousePosition)
OPT: the way it is drawn (color, line thickness, ...) may depend on dragging
5) inside MouseUp:
OPT: set dragging false and call Invalidate()
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hi..!!
i understand the above points but don't know how to add class members and how to calculate the positions and store them..
what i know is that i have to use 'e' like e.X, e.Y but don't know the proper way for this..
can sumone help me plzz....
|
|
|
|
|
hina123tariq wrote: don't know how to add class members
yes you do. Inside a class, but not inside any method, add lines such as private int mouseX;
hina123tariq wrote: how to calculate the positions
some positions may be absolute (i.e. top left of the screen is 0,0); most positions are relative to their container (i.e. top left of the Control or Form is 0,0). Hence what it takes most often is one addition or one subtraction. Make a little drawing to help yourself.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hi all,
I need to send some text from c# to javascript.
So how can I format it so that compatible it will be compatible to javascript.
the c# text includes tab, newline ,', ", \,/,// and other special characters
|
|
|
|
|
Take a look at http://www.json.org[^].
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi all,
writing a small app that reads a registry setting and based on the content on that, should either show the form or hide it in the tray bar.
RegistryKey masterKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Policies\\OTM");
if (masterKey != null)
{
if (masterKey.GetValue("Serial").ToString().Length == 36)
{
textBox1.Text = masterKey.GetValue("Serial").ToString();
textBox1.Enabled = false;
this.Hide();
}
else
{
textBox1.Enabled = true;
this.StartPosition = FormStartPosition.CenterScreen;
this.WindowState = FormWindowState.Normal;
this.Show();
}
}
unfortunately the window always stays open. Anyone who have a quick tip to what Im missing?
I tried to include this.WindowState = FormWindowState.Minimized; , but that just minimized to app, but didnt hide it in the tray bar. - sorry writing error here. Meant didnt hide the form at all. At best it gets to be minimized in the lower left corner.
modified on Friday, November 6, 2009 4:27 AM
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:20am.
|
|
|
|
|
sorry i didnt mean the tray bay, but it is shown minimized in the left corner just above the traybar ifi i force the app to start minimized.
ShowInTaskbar is already set to false.
|
|
|
|
|
Did a small change
RegistryKey masterKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Policies\\OTM");
if (masterKey != null)
{
if (masterKey.GetValue("Serial").ToString().Length == 36)
{
textBox1.Text = masterKey.GetValue("Serial").ToString();
textBox1.Enabled = false;
this.WindowState = FormWindowState.Minimized;
this.Hide();
}
else
{
textBox1.Enabled = true;
this.StartPosition = FormStartPosition.CenterScreen;
this.WindowState = FormWindowState.Normal;
this.Show();
}
}
plus included this:
private void Form1_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
Hide();
}
}
It is far from beautiful but it works for now...
|
|
|
|
|
Dear friends,
is there some one worked with
"System.Security.RightsManagement" i think we can develop a IRM application using these namespace...
i do not know how to work with
i want to set policy for a file
all the policy i want to set is availble in
"System.Security.RightsManagement.ContentRight" class
give me some link ... i could not find useful llinks
thank You
joe.I
|
|
|
|
|
hello @all,
i use this code to format number values in a textbox:
tbxProzentwert1.DataBindings.Add("Text", bs, "prozentwert1", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, null, "#0.00#");
I have no other Validation-Formatting in my prog.
So the value will be formatted like
1 -> 1.00
0 -> 0.00
1.4 -> 1.40
thats ok.
But if i write a character or leave the value blank, the focus will stick to the field.
Now i have to put a 0 or any number i it to leave the textbox ...
Is it possible to write a 0 to the value if the value can not be formated ?
Bye jo
|
|
|
|
|
Hi,
I Add New Class in My Solution For Use Some Functions in Other Forms.
If i Use this Code
public static void RefreshUserList()
{
dtTableUserList = new DataTable();
try
{
dtTableUserList.Rows.Clear();
string cmd = "select * from tblLogin order by UserName";
da = new OleDbDataAdapter(cmd, con);
con.Open();
da.Fill(dtTableUserList);
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
here ERROR is in
MessageBox.Show(ex.Message);
How i show messegebox in class
Thanks & Regards
Form :-
Vikash Yadav
Mob : 9210907172
|
|
|
|
|
Create a function in your class e.g. ShowErrorMsg
pass Active form as parameter and use this syntex
MessageBox.Show(ActiveForm, "Error: " & vbNewLine & vbNewLine & msg, My.Application.Info.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
|
|
|
No, that is useless
1 - Application.Current.MainWindow works anywhere
2 - his issue is that he's in a dll, or he's just not scoped Windows.Forms.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: 1 - Application.Current.MainWindow works anywhere
Not in applications without UI's...
The simple answer is that DLL's should never try to make messageboxes unless they are part of the UI. Classes that create errors like that should bubble the error up to a UI or logging component using mechanisms like "throw". That way the application can decide how to alert the user, whether through UI pop-ups, log files, etc.
I've also found it very useful to create an application settings file and store error text information in there, rather than hard code error strings in the application. This allows me to ensure that the grammar, punctuation, spelling, and format of errors are all the same throughout the application. It also makes it very easy to edit particular errors if your test team says that the text is incorrect or vague, you just look in the setting file instead of combing through thousands of lines of code to find every instance.
|
|
|
|
|
If this does not work, then you must import the Windows.Forms dll into your dll, or you need using Windows.Forms at the top of your class. Intellisense will show you the namespace you need if you hover the mouse over the end of the statement that has the error. You're really better off throwing an exception tho and letting your presentation layer decide how to deal with it. You can use Application.Current.MainWindow to specific a parent to the messagebox anywhere inside your windows forms app.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello friends,
I have a program to connect to url using HttpWebRequest object and download a file from that url.
I have set
httpwebRequest.Proxy = null;
Question: In my application, no setting field available for to define the specific proxy settings - so, does the my programming foresee to use by default the internet explorer proxy setting?
or are there any other ways to bypass the proxy?
Thank You
|
|
|
|
|
Hi...
I had a group of computers in LAN. In one of the Systems one PC is server which is having MYSQL databse. I want to connect from another PC which is in LAN. My LAN server name is "Desktop1".
I am using the Connection String as
Constr="Server=Desktop1;User Id=root;Password=sa;";
in c#.net. But it is not connecting the Server which is having MYSQL database. To establish the connection in between the PC's am i need to do anything more.....
Plz help me . I am looking for this from a loooong days...
Thank you...
|
|
|
|
|
I believe you need \\Desktop1, to create a network path.
gopal_bnvs wrote: Plz help me . I am looking for this from a loooong days...
Well, that's a little concerning. If you can't work out a connection string, I'd be worried about your ability to do C# AND SQL.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Heelllllll
I tried evrythng....
but its not connecting...
If u knows y don't u mention the connection string.....
|
|
|
|
|
Like I said, it's plain that programming is probably beyond you.
You can have a connection string to a local file, so you need to start your connection string with \\ to show it's a network path. Like I said.
If you can see the machine over the network, then your issue is the connection string, perhaps the user the program runs under, or a combination of the two.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
You need to specify the database name as well. Check out ConnectionStrings.com to see all kinds of connection strings.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
hellooo
i searched all and tried all ...
if u knows abt that y don't u mention the connection string?????
|
|
|
|