|
Hi i am trying to move a child windows within an mdi window
i have a control on the child that when clicked it allows me to drag the child around
however the child is actualy offset a whole lot below and to the right
i do not know how to get the window to move to my mouse position within the parent form
i think the problem has to do with the mouse coords being from the child form and not the parents coordinates how do i move the child window to exactly where my mouse pointer is?
if(dragging)
{
this.Location = MousePosition;
}
ive tried everything subtratcing and adding the forms original positon
PointToScreen and ScreenToClient
can someone please help me!
|
|
|
|
|
when the mouse is clicked on the child window, it is not clicked in the upper lefthand corner, it's offset by some (x, y), record that offset when the mouse is clicked, and add it the mouse position when you do the move
mouseclick (x, y) {
mouseoffet = point (x, y);
}
mousemouse () {
if(dragging)
{
this.Location = MousePosition + mouseoffset;
}
you're losing that offset.
|
|
|
|
|
when the mouse is clicked on the child window, it is not clicked in the upper lefthand corner, it's offset by some (x, y), record that offset when the mouse is clicked, and add it the mouse position when you do the move
mouseclick {
mouseoffset = MousePosition - this.Location;
}
mousemouse () {
if(dragging)
{
this.Location = MousePosition + mouseoffset;
}
you're losing that offset.
|
|
|
|
|
Try the following:
if(dragging)
{
this.Location = parentform.ScreenToClient(Cursor.Position);
}
www.troschuetz.de
|
|
|
|
|
I created my first C# application. When the application runs, the user can drag the bottom-right corner to resize it.
Is there a property that I can turn that option off?
|
|
|
|
|
yes change the form border style
|
|
|
|
|
Hello
I am want to query a database in my book table. I want to find all the books that are over due. This is the query below, but when l execute it, it returns no records. I think it is because of the datatype. I am using MS Access in the datadue field l have it set as a DateTime datatype.
I am using C#
DateTime today = Convert.ToDateTime(DateTime.Today.ToShortDateString());
string queryOverdueBooks = @"SELECT RefNumber, Title, DateOut, DateDue FROM Book WHERE DateDue < '" + today + "' ";
Does anyone know how to correct this query so that it will return the books that are overdue.
Many thanks in advance,
Steve
|
|
|
|
|
Try using some function which is equivalent of To_Date function of oracle.
string queryOverdueBooks = @"SELECT RefNumber, Title, DateOut, DateDue FROM Book WHERE DateDue < To_date('" + today + "' " + ", yyyy/mm/dd");
|
|
|
|
|
just checked the access syntax. the below should also do.
DateTime today = Convert.ToDateTime(DateTime.Today.ToShortDateString());
string queryOverdueBooks = @"SELECT RefNumber, Title, DateOut, DateDue FROM Book WHERE DateDue < " + today + ";
Another solution:
DateTime today = Convert.ToDateTime(DateTime.Today.ToShortDateString());
string queryOverdueBooks = @"SELECT RefNumber, Title, DateOut, DateDue FROM Book WHERE DateDue < Format(" + "'" + today + "', 'YYYY/MM/DD') ";
Do reply whether it could solve your problem or not.
|
|
|
|
|
Here's my code, designed to query a definition from dict.org (ironically, there are only a handful of Windows programs out there that do that):
**************************
IPHostEntry IPAdd = Dns.Resolve("dict.org");
IPEndPoint IPEP = new IPEndPoint(IPAdd.AddressList[0], 2628);
Socket s = new Socket(IPEP.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
string str = "DEFINE * " + Convert.ToChar(034) + SelectedWord + Convert.ToChar(034) + Convert.ToChar(013) + Convert.ToChar(10);
Byte[] Sender = System.Text.Encoding.ASCII.GetBytes(str);
Byte[] Receiver = new Byte[20000];
s.Connect(IPEP);
Int32 bytes = s.Receive(Receiver, Receiver.Length, 0);
s.Send(Sender, Sender.Length, 0);
bytes = s.Receive(Receiver, Receiver.Length, 0);
strDefinition = System.Text.Encoding.ASCII.GetString(Receiver, 0, bytes);
************************
My problem is, every so often I get a response that is so long it overflows my Receiver array (ever look up "at" in the dictionary? ). Declaring a 1,000,000 member array seems a bit silly, so is there a way to declare a dynamic Byte array that can be added to like an ArrayList? Or maybe some other workaround for this algorithm?
|
|
|
|
|
tantiboh wrote:
My problem is, every so often I get a response that is so long it overflows my Receiver array (ever look up "at" in the dictionary? ). Declaring a 1,000,000 member array seems a bit silly, so is there a way to declare a dynamic Byte array that can be added to like an ArrayList? Or maybe some other workaround for this algorithm?
Something like this:
StringBuilder sb = new StringBuilder();
while ((bytes = s.Receive(Receiver, Receiver.Length, 0)) != 0)
{
sb.Append(System.Text.Encoding.ASCII.GetString(Receiver, 0, bytes));
}
strDefinition = sb.ToString();
Yes, even I am blogging now!
|
|
|
|
|
It's an interesting approach. Apparently, GetString doesn't like it when bytes hits zero, so I rewrote it like this to prevent a lock-up:
*************************
Byte[] Receiver = new Byte[150];
System.Text.StringBuilder sb = new System.Text.StringBuilder():
Int32 bytes = s.Receive(Receiver, Receiver.Length, 0);
do
{
sb.Append(System.Text.Encoding.ASCII.GetString(Receiver, 0, bytes));
}while ((bytes = s.Receive(Receiver, Receiver.Length, 0)) == 150);
sb.Append(System.Text.Encoding.ASCII.GetString(Receiver, 0, bytes));
strDefinition = sb.ToString();
**********************
The problem I'm encountering now is that the algorithm doesn't wait until all the data is retrieved before it starts processing it. Is there a way to stop the program until all the data is received? How does the program know that the sender has finished sending data?
|
|
|
|
|
Hi all,
I try to write to a Form1 class which extend a window Form class, and serves
as the base class for another class Form2(not extend Window Form class) (i.e. Form2 extend Form1).However, when I try to use the VS.net Form designer for putting control on the Form1, I got errors. Why ?
Thanks
|
|
|
|
|
Hi,
If you could list the type of errors you are getting, it will make it easier for us to help you. Also, a quick code snippet never hurts.
~javier lozano
(blog)
|
|
|
|
|
Sorry
In fact,
I write 2 form class
one entitled "class Form1 : System.Windows.Forms.Form"
another entitled "class Form2 : Form1"
How do I use the VS .Net Form designer to design form2?
Thanks
|
|
|
|
|
Hi,
I am wondering whether it is possible to open and run or run a matlab program from an interface developed in c#.
I mean i have a matlab xyz.m file which runs directly, when u type at matlab interface command prompt. Can we automate it by doin tht directly from an interface developed in c#?
thanks in advance,
Suman.
Suman
|
|
|
|
|
Matlab is in C, isn't it ? To run it in C#, MC++ or COM are probably your only hope.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi Graus,
yeah Matlab is developed in C, but i need to run matlab program directly from C#.
BTW how to use MC++ or COM in implementing this type of applications. I mean can u gimme an example of a simple program.
Thanks,
Suman.
Suman
|
|
|
|
|
|
I'd like to affect specific items in a List Box. In other words, I'd like to take any one (or more) elements of the List Box Collection and, say, turn it red, or turn it bold.
Anybody know how to do this?
|
|
|
|
|
|
|
winForms - C#
This should be simple. Does the richtextbox control support dragging and dropping?
I know of the DoDragDrop method. It doesn't help me if I can't interrogate the system to find out what the mouse is actually dragging.
I've written a bunch of custom event handling to deal with this, but the last thing I'm missing is the event arguments you would normally get in a DragEventHandler. And short of changing the signatures on delegate event handlers (doesn't work, obviously), I'm not sure how to get the mouse args.
Is there any easier way to do this? Does the RTB actually support easier DND capability?
Thanks in advance.
|
|
|
|
|
Yes, it is supported. Search MSDN, in particular, try here[^].
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
Hi all,
Are there any references for writing a scalable server application ?
I searched on internet but find nothing, just can find some
product info on scalable server application.
Thanks
|
|
|
|
|