|
Yes, you need GPS. GPS data is not difficult to parse, but communication may depending on your device. Be sure to get a GPS that is NMEA 2.0 compatible, which most these days are. It's a simple text format that you can find lots of information about on the web by performing a search.
MSDN Online Library[^] has some articles, and you could always google[^] as well.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I want my C# program can cut some region of a picture,
What should I do in MouseDown, MouseMove, MouseUp Event,
to select the scale of the picture I want to cut,
Is there any sample...??
Thanks !!
|
|
|
|
|
When width and height are Changed of my program, How can I get the width and height of my program.
I see a code in example from a book but I'm not sure
code is start with like this
protected override void OnResize(EventArgs ea)
What deligate or event need to get Size Changed event.
and How can I get width and height of my program when it occurs?
Image will remind us some feelings and if I can ask someone about a problem, that's not a bad life.
|
|
|
|
|
form.Width
form.Height
A quick look at the object properties in VSS would have answered your question.
This signature left intentionally blank
|
|
|
|
|
I'm trying to caputre Logitech's USB gamepad using DirectInput with the following code. I use a timer to poll the gamepad's state. It seems the gamepad is captured but the buttons are not as I always get:
X: 32767
Y: 32767
Any ideas what could be the problem? Thanks in advance.
public class InputHandler
{
protected Device gamepad = null;
public InputHandler(Control Owner)
{
foreach (
DeviceInstance di in
Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly))
{
if (di.DeviceType == DeviceType.Joystick)
{
gamepad = new Device(di.InstanceGuid);
break;
}
}
gamepad.Properties.AxisModeAbsolute = true;
gamepad.SetCooperativeLevel(Owner,
CooperativeLevelFlags.Foreground |
CooperativeLevelFlags.NonExclusive);
gamepad.Acquire();
}
public JoystickState GetGamepadState()
{
return gamepad.CurrentJoystickState;
}
}
private void tmrPollInput_Tick(object sender, System.EventArgs e)
{
InputHandler input = new InputHandler(this);
JoystickState padstate = input.GetGamepadState();
byte [] buttons = padstate.GetButtons();
string info = "";
for (int i = 0; i < buttons.Length; i++)
{
if (buttons[i] != 0)
info += "Button: " + i + "\r\n";
}
txtGamepad.Text = "X: " + padstate.X + "\r\n"
+ "Y: " + padstate.Y + "\r\n"
+ info;
}
|
|
|
|
|
I'm not sure I completely understand your problem, but keep in mind that sticks by default give you a delta, not a position. If you move the stick right, for example, you'll get deltaX=+1, deltaY=0 for a small change (it's weighted against the amount of movement).
I don't currently have the Managed DX9 SDK installed on this machine, so I'm sorry I can't give you more help.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I am trying to make C++ api calls from my C# code. I don't know how to properly define my data structure in C# so that data can be properly marshalled. Here is how in C++ api and struct are defined:
*****C++ code ********
...........
typedef struct {
char uid[20]; // Max Len: xx
char *data; // Data on Tag
int len; // Data length
} DataBuffer;
class AFX_EXT_CLASS cObject
{
public:
bool ReadData(DataBuffer* RetVal, int iTime);
cObject();
virtual ~cObject();
private:
DataBuffer* mBufferData;
};
....
********End C++ code ***************************
Here is C# code i tried but failed
*********C# code ***************************8
....
namespace MyCAPI
{
[StructLayout(LayoutKind.Sequential)]
public struct DataBuffer
{
public StringBuilder uid; // Max Len: xx
public StringBuilder data; // Data on Tag
public int len; // Data length
}
/// <summary>
/// Summary description for Class1.
/// </summary>
public class CAPI
{
[DllImport("Cobject.dll")]
public static extern bool ReadData(ref DataBuffer RetVal, int iTime);
}
}
....
**********END OF C#*******************
Please advise. Thanks
Kevin
|
|
|
|
|
You should read Interop Marshalling[^] in the .NET Framework SDK to understand the differences in data types.
The struct is fairly straight-forward to marshal. Keep in mind that an unmanaged char is ANSI, so you must declare CharSet.Ansi (default for P/Invoke with C#, but still a good idea to set) and that a native int is actually an IntPtr in managed code, since it's platform-dependent:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public struct DataBuffer
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public char[] uid;
public string data;
public IntPtr len;
} IntPtr has constructors and other methods that will help wrap a managed int (Int32 ) or long (Int64 ). This is an important distinction because if you compile your native code for 64-bit platforms, the 64-bit signature is used. If you don't, your application will run under WOW64, a 32-bit emulator and IntPtr should still be 32 bits. If you don't plan on supporting a 64-bit native API, then you can change IntPtr both here and below to simply an int . Keep in mind that no one can predict the future, though. Declaring your fields, properties, and params as IntPtr now may save you time in the future if you ever do decide to recompile your native app/library for the 64-bit platforms.
The class is a different subject, though. A C++ class does not use C-style exports like most of your export functions would (should). You need to P/Invoke these using the CallingConvention.ThisCall calling convention. You declare your methods (member functions) with a 'this' pointer as the first parameter, as documented in the .NET Framework SDK for the CallingConvention enumeration.
So, ReadData becomes:
[DllImport("cobject.dll", CallingConvention=CallingConvention.ThisCall)]
extern static bool ReadData(ref DataBuffer RelVal, IntPtr iTime); Never declare P/Invoke methods as public, unless the defining class is internal. C and C++ give direct access to memory - the CLR does not (that's why it's call "managed"). P/Invoke requires unmanaged permissions to be granted to the assembly based on it's evidence and that's one level of protection. But trust only goes so far. Never let unknown code call P/Invoke functions because you should never trust your callers. If the P/Invoke function is private (lack of an access modifier in C# defines it as private), then only your class can makes calls to it. And don't let others classes in your library call it either, unless it's necessary. Calling the method incorrectly does not require malicious intent.
Finally, the ThisCall calling convention requires a class factory. You need to have an instance of that class to pass as the first parameter.
I have covered this in previous messages, so I redirect you to http://www.codeproject.com/script/comments/forums.asp?msg=771919&forumid=1649#xx771919xx[^] for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi there,
is there a way of specifying the order of Tests within a given TestFixture (class)?
It seems that the order how they appear in the nDoc GUI is alphabetically, but can I rely on this?
Thanks in advance,
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
Matthias Steinbart wrote:
is there a way of specifying the order of Tests within a given TestFixture (class)?
Using the Advanced Unit Test program (shameless plug) you can sequence tests, and also test what happens when processes are executed out of sequence. See sig.
Marc
MyXaml
Advanced Unit Testing
|
|
|
|
|
In an ideal world, tests should be able to successfully run independently of their ordering.
However, this is the real world. If you have a bunch that you really really absolutely have to run in order, then I would say to make a test that just calls the other tests, in order.
Alternatively, create Setup and Teardown subs that prepare the way for (and clean up after) each test.
my blog
|
|
|
|
|
Hi
I'm trying to get webrequest in BeforeNavigate2Event, and save it, but it seems that the postData object is not the same object what explorer actually send. In BeforeNavigate2 Event i save all objects (url,postData,headers) and than call the navigate2 method with those objects but it doesn't browse the same page. If i make the postData manually (string -> byte[]), there is no problem at all. I also looked the both byte arrays, they are different. and i decoded the explorers postData to string, it's the same string what i manually wrote. Why the two byte array are different and how can i get the actual postData?
thanks
|
|
|
|
|
Hi there,
i wonder if there is a way to open a window on a specific display.
i have workstations with 2 monitors attached, but programs always
show on the first display. is there a way to open them on the
second display?
any ideas?
thanks a lot
jkersch
|
|
|
|
|
What OS are you using? With XP, I've never encountered this problem. In fact, I have the opposite problem--when I take my laptop somewhere, many apps end up opening up off-screen because that's where the they were last on the now disconnected second monitor!
Marc
MyXaml
Advanced Unit Testing
|
|
|
|
|
well, i´m using WinXP,SP2 German.but it should also work on win2kpro german.
but normally displays won´t get disconnected.
is it possible to select explicitely which of the connected displays to use showing forms?
i know its possible to enumerate connected displays via native call
EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc, 0);
but i didn´t get it to work by now via native calls.
i wonder if there is possibility to do it with just .NET
|
|
|
|
|
I'm not aware of any .NET classes that deal with multiple monitors.
You might want to look at this though:
http://www.realtimesoft.com/ultramon/[^]
It has [edit] an SDK with [/edit] source code, but not .NET, unless someone has ported it. Still, it might give you some information as to the underlying API's and tricks to use.
Marc
MyXaml
Advanced Unit Testing
|
|
|
|
|
Hi
I have a form with a web browser control in it. I want to receive dragdrop notification when I drag things onto the from (mainly files from the desktop), however the browser control seems to be blocking the notifications. If a hold the icon over the borders of the form and title bar, I get notified, but not when the browser is in the way.
How can I get notified no matter where I'm holding the item in the form?
Dave
|
|
|
|
|
I have a main form that has an Apply button that is normally in disablled state, used to save the settings in the main form and another form called Option form. The Option form is used to set some other variables.
When I open Option form and change any thing on it, I want the change to reflect in main form and make the Apply button enable.
How to do this?
Please guide.
|
|
|
|
|
hi,
Change the modifiers property of your button which is there in main form to Public.
After this you can access the button to any other form using the instance of main form.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
thanks for the help, but its not working in my case.
rgds
|
|
|
|
|
hi,
A small senario. Suppose if you want to check the status (whether button is is disabled or not) of control in mainfrom you can go ahead with this idea.
otherwise please let me know what you want exactly.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Thanks for the reply
I would like to enable the Apply button in the main form as soon as I change the status of any control in the Option form. e.g. I have a check box in the Option form, if I click it and change the status from checked to unchecked or the other way, I would like to enable the Apply button in mail form so that is I click it, I will do some other processing of storing the status of the controls.
Sorry for not being acurate in stating the problem.
regards
|
|
|
|
|
hi,
Use little logic to achive that using my old post
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
You are going to have some limitations to doing this. Both forms must be in the same message thread (so your first form must launch the second form on the same thread).
To access data in a partner form you need to do a few things.
Situation : You have Form A. It will create Form B. Form B must change status in Form A.
Answer: Modify your constructor in Form B to take its' parent as a parameter. Then in Form A pass (this) in the creation logic.
If it is the reverse (Form A creates and modifies Form B) no special constructor is needed since you already have the form object at your disposal.
Now the second part of it: accessing the button, label, whatever. To follow proper coding convention, you would add an accessor to the form for each field you want to expose access. Your accessor would provide both a getter and setter.
One other approach is to implement an event bubbler. Tie each form together with your own event much like the Observer Pattern. Then when a change needs to occur, the observer raises the event, which can bubble up through the various forms, and each form can react to the event accordingly.
If your forms are in different application domains, then you would probably want some type of remote notification system (much more complex).
This signature left intentionally blank
|
|
|
|
|
thank you very much for the comprehensive reply.
my forms fit in first situation, they are in one thread only. in the main form i have Option button, on its click event Option form is created.
let me explain a bit more about what am i up to.
the main form is customized Print dialog, its upper half is like a normal print dialog and lower half is divided in two parts, left part is having a tree view and right part is kept for displaying user controls associated with the three node, each one is linked with the tag property of the tree view node. thus i have near about 115 controls ( check boxes, radio buttons, numeric up-down controls and combo boxes ). besides a few more in option form.
i have an Apply button to save the status of all controls. its normally in disable state and have to make it enable as soon as any controls status is changed, and have to again disable the Apply button is the user comes back to earlier status. how to keep track of all the controls is the big question for me. besides the earlier problem.
i was also thinking of passing 'this' in the constructor of Option form, but i read some where that parameterized form constructors are not advisable, thats why i wanted to have experts comments.
i understood the concept of getter-setter in your reply but being a new comer not able to understand the concept of an event bubbler. please explain it a bit more.
regards
|
|
|
|