|
I'd have to see some code, as I'm not able to duplicate your error.
|
|
|
|
|
I did a simple program just to check what was the problem.
The program:
private void Form1_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
textBox1.Text=MousePosition.X.ToString();<br />
textBox2.Text = MousePosition.Y.ToString();<br />
textBox3.Text = button1.Location.X.ToString();<br />
textBox4.Text = button1.Location.Y.ToString();<br />
}
which will show the (X,Y) of the button and the mouse..
and the problem is that even if u aim at the same pixel (the mouse and the button..), the (X,Y) are not the same..
|
|
|
|
|
A few things, your mouse position won't update when you hover over the button as the event isn't triggered when the mouse is over the button, furthermore the button x,y is relative to the parent (form) where the mouse position is relative to the desktop.
This means the button location will never change, but if you move the form and put the mouse in the exact same position relative to the top left of the form, your x,y coordinates will vary.
I still don't quite understand what it is you are trying to do so I can't offer you a solution, but I can explain my observations of different behavior.
Again the location (x,y as you put it) is relative to the parent , so form position is very important.
|
|
|
|
|
is there a way to override this thing?
I mean, for example, both button and mouse have the same parent?
A picture, will check from the desktop or the form?
|
|
|
|
|
I haven't tested but I supposed you could throw a panel on the form, it can dock to its parent to have the same size no matter what the size of the form is..
Again I haven't tested this or ever had to use such a technique, so I would say it's all trial and error from here on in.
Good luck.
|
|
|
|
|
ok i will check it out,
Thank you for your help.
|
|
|
|
|
The MousePosition property is always given in relation to the desktop, and controls are always given in relation to their immediate parent... But WinForms controls have a PointToScreen() function and a PointToClient() function.
Control.PointToScreen(pt): Take a point in control coordinates (Measured in relation to the top-left corner of the control), and return them in screen coordinates
Control.PointToClient(pt): Take a point in screen coordinates, and return them in relation to the control.
If you want everything in the same scope, for example, in relation to your Form:
myForm.PointToClient(myButton.PointToScreen(new Point(0,0)))
(This will work regardless of how nested your controls are, so if the button is inside a panel which is inside another panel, this will still give you the right coordinates)
myForm.PointToClient(MousePosition)
Alternatively, instead of using MousePosition, you can use e.X and e.Y (From the MouseEventArgs in the event), which will always be in relation to the control raising the event.
|
|
|
|
|
That fixed my problem!
Really thanks for the answer.
|
|
|
|
|
Hi, everyone. The situation is, I am converting a tiff image file into byte[], then to stream then saving it as jpeg image format, then display it on browser, so that the jpeg opens in a picture viewer instead of webpage. The code works in IE 6 and firefox, but does not work in IE 7. In IE 7, the blank page appears and automatically closes. The code is as follows:-
System.IO.Stream _stream = new MemoryStream(byteArray);
Bitmap _bmp = new Bitmap(_stream);
Response.Clear();
Response.AddHeader("Content-Disposition","attachment;filename=adc.gif");
Response.ContentType = "image/gif";
_bmp.Save(Response.OutputStream, ImageFormat.Gif);
Response.End();
_bmp.Dispose();
_stream.Close();
This code is called in the page_load of a page in server a. Since the tiff image is located on a different server(server b) other than the web server, the image path is passed to web service located at server b, image is read and converted to byteArray and returned to server a. I guess the problem is with Content-Disposition.
Any help is appreciated.
|
|
|
|
|
Just a guess, but you might have more luck with the ASP.NET forum we have here.
|
|
|
|
|
sudhirBirlapur wrote: The code works in IE 6 and firefox, but does not work in IE 7.
I tested your code and it works fine for me on IE7
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi, Manas. Thanks for your time. Could you please post the exact code you have used and the html source. Also I am using default IE 7 settings, but its not working, also the website url that I'm checking starts with https://, not http://
Regards,
Sudhir
|
|
|
|
|
How can i write usb driver software for microcontrollers?
i have a poject with microcontroller. When my project connects with usb cable to PC so i want my software connects with microcontroller.i want to send data and get data from microcontroller. i wish i could explain my aim.
for example when i click a button in PC side(in visual studio or delphi etc.) so microcontroller and pc can send-get datas with usb cable.
|
|
|
|
|
Mir_As wrote: How can i write usb driver software for microcontrollers?
Using C#?? You can't. The microcontroller cannot run the .NET Framework, so any C# code you write will also not run.
You can write an app to talk to something on the microcontroller, but whatever you write for the micro will most likely have to be written in C, not C#. How you do the communication depends entirely on the micro and how you expose the data to the outside world. It's entirely up to you.
|
|
|
|
|
i want to write driver for my microcontroller. when i connect to microcontroller project to Pc so i want they connect eachother.and send and get datas. i think it can be.but how? serialports connect to microcontroller i think USB can connect to microcontrollers too.
|
|
|
|
|
Mir_As wrote: i want to write driver for my microcontroller
You where just explained that a task like that is geared for C, not .Net.
|
|
|
|
|
What part of "you can NOT run a C# app on a microcontroller" is so difficult to understand?
|
|
|
|
|
okay thats right, but what if we merge the .Net Framework with the application ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
First, you'll have to find a compiler that will generate native code with the app and framework all rolled into one. There are some out there, but they cost a small fortune to buy.
Next, that compiler will have to generate native code for the CPU in the microcontroller. That probably doesn't exist.
Those compilers will generate code libraries that are significantly larger than the app itself. You'll have to make sure the MC has the storage capacity to hold such a large executable.
Lastly, the .NET CLR depends on Windows, which the MC will not run.
|
|
|
|
|
Xmen W.K. wrote: okay thats right, but what if we merge the .Net Framework with the application ?
Good luck!
|
|
|
|
|
Like I'm gonna test ? It was just an idea. Thats it...
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
The short answer is: NO
1. PC side
if your microcontroller is to show up as a special peripheral to your PC, with an entry in the Hardware list, with multi-user capabilities, etc, then you need a device driver; such drivers can not be written in any of the .NET languages, the CLR isn't capable of doing system work.
if your microcontroller:
1) would be connected through a serial port (possibly using a USB-to-RS232C cable plugged into one of your PC's USB ports),
2) would not be a multi-user device
3) would not need permanent software support
then you could develop an app in any language you choose, including C#. It then couldt use the SerialPort class and go without a special driver.
2. Target side
microcontrollers in general don't support .NET, and most people still believe you need .NET to run a C#-based app, so no there will not be any C# code running on the microcontroller.
(One could create a cross-compiler for C# and compile it to either native or intermediate language, and come up with a small virtual machine to execute it; there is a sufficient number of small Java examples around to proof it is possible; I have not seen anyone do it for C# though).
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: and most people still believe you need .NET to run a C#-based app
You just blew my mind.
|
|
|
|
|
Luc Pattyn wrote: I have not seen anyone do it for C# though
A new article perhaps? If you do, let me know - it would be VERY interesting!
|
|
|
|
|
No, I have no such intentions; I am happy with C# (or Java) on a PC, and C and Java everywhere else.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|