|
Ok. I'm going to check this class.
Thanks
There is no spoon.
|
|
|
|
|
The .NET Framework is not an application - it's a framework (hence the name) on which applications are built. The JRE (Java runtime environment) doesn't implement bulk importers either, but gives you the classes (i.e., the framework) with which to create bulk importers.
Yes, ODBC and OLE DB both have a driver to treat delimited text files as data sources and you can use that using either the System.Data.Odbc or System.Data.OleDb classes, buth that would be very inefficient because you're P/Invoking (indirectly) native calls and marshaling data. Reading it faster like the other reply (from Nick) mentions is much faster.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I'm new at C#, okay with C++
Lets say hypothetically that i'm making a video game and I want to make a button that fires a weapon.. I've made an enum for my "special keys"... so instead of using the Keys enum which doesn't give the keys any more of a description more than what letter it is. So I wanted to make a new Keys enum called myKeys and do something like this
<br />
enum myKeys <br />
{<br />
SpecialKey1 = Keys.N,<br />
FireWeapon = Keys.P,<br />
}<br />
<br />
protected override void OnKeyUp(KeyEventArgs e)<br />
{<br />
if (e.KeyCode == myKeys.SpecialKey1)
{<br />
}<br />
if (e.KeyCode == Keys.N)
{<br />
}<br />
}<br />
What am I doing wrong here?
This is the error...
<br />
Operator '==' cannot be applied to operands of type 'System.Windows.Forms.Keys' and 'myApp.myKeys'<br />
Seems like neither of the above should work by looking at this error? What going on here? Suggestions for other ways of accomplishing the same task
Thanks for responses guys
|
|
|
|
|
niceguyeddie wrote:
Operator '==' cannot be applied to operands of type 'System.Windows.Forms.Keys' and 'myApp.myKeys'
Each enum is a different type, you'll need to explicitly cast both to int to compare them.
Yes, even I am blogging now!
|
|
|
|
|
niceguyeddie wrote:
What am I doing wrong here?
C# is type-safe and the type of KeyEventArgs.KeyCode [^] is Keys [^]. Therefore you have to explicitly cast the type:
if (e.KeyCode == (Keys)myKeys.SpecialKey1)
{
}
Lets say hypothetically that i'm making a video game and I want to make a button that fires a weapon.
I would definitely not use an enumeration to store the keys because a modern video game should provide a setup for reassigning the keys.
Best regards
Dennis
|
|
|
|
|
thanks guys, that completly makes sense.. those are the things that make you pull hair out for an hour because the solution is so easy yet just can't seem to see it.
this is actually not for a video game, the keys won't have to be reassigned. I can recompile if I need to change something.
|
|
|
|
|
On a different note (since your question was accurately answered) you should consider not hard-coding certain keys. Many people agree that a good game allows for key mapping, and - in a basic capacity - it's not that hard to add.
Lets say you host your game in a Form (this is typically the came even with Managed DirectX). There is a method you can override (actually several) named ProcessDialogKey . You would also keep a key map of what keys map to which actions. One way would be to use the hash table and an enumeration (like you already have) of Keys to Actions (assuming Actions is your action enumeration), which you could persist in a file, database, etc.
Take the following example (doesn't include persistence):
protected override bool ProcessDialogKey(Keys keyData)
{
if (keyMap.ContainsKey(keyData))
{
Action a = (Action)keyMap[keyData];
switch (a)
{
case Action.Shoot:
Shoot();
break;
case Action.Duck;
Duck();
break;
}
return true;
}
return false;
} Depending on how your game's Form is set up, you may also need to set the Form 's KeyPreview property to true to make sure that the form processes the keys before its child controls do.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath Stewart wrote:
switch (a)
{
case Action.Shoot:
Shoot();
break;
case Action.Duck;
Duck();
break;
// ...
}
return true;
}
Actually, you could get rid of this switch by storing interface pointers in the hashtable and simply call an "executeAction" method, or something like that.
Yes, even I am blogging now!
|
|
|
|
|
that indeed seems like a good way to go - only thing that looks like may not be good is that theres no way to tell if it was a keyup or keydown...
okay heres one more, this one is equally as retarded hahah
enum EnumType{Up, Down, Left Right}
public void myMethod(EnumType Direction)
{
}
and the error....
Inconsistent accessibility: parameter type '..EnumType' is less accessible than method '..myMethod'
I'd rather do this than the less meaningfull int 1,2,3,4 etc.
any ideas. ?
|
|
|
|
|
niceguyeddie wrote:
Inconsistent accessibility: parameter type '..EnumType' is less accessible than method '..myMethod'
Your enum is private, but your method is public and you are using the EnumType on the parameter list.
Yes, even I am blogging now!
|
|
|
|
|
Hi,
I create an ImageList with some BMP file and create a PictureBox.
I would like to know how can I do for selecting an image from my list and put it on the Picturebox.
Best Regrads
youssef
|
|
|
|
|
pictureBox1.Image = imageList1.Images[3];
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
I have a Application that has to connect via ras to other devices. For this I have imported some RasAPI32-functions (RasDial, RasHangup). When an error occured while connecting, a call of the rasdial function results in the error code 756 - Dial already in progress).
When i stop my application and restart it, i can connect again.
How can I 'reset' a connection that is blocked in this way?
Thanks
Roland
Wenn Du diesen Satz irgendwo liest, ignoriere ihn.
|
|
|
|
|
Roland Bär wrote:
How can I 'reset' a connection that is blocked in this way?
IIRC, you need to call RasHangup even when RasDial fails. But I may be wrong, I didn't work with RAS in the past few years.
Yes, even I am blogging now!
|
|
|
|
|
Thanks Daniel, your help saved me a lot of trouble!
Roland
Wenn Du diesen Satz irgendwo liest, ignoriere ihn.
|
|
|
|
|
Hello,
I have a windows service that updates the database. I installed it on the machine with SQL Server installed, it worked perfectly. But when I installed it on a client machine, the service does not start, and ends up with JIT compiltation error :
Could not start Data Update service on the Local Computer. The service did not return an error. This could be internal Windows error or internal Service error.
I have changed the connection string accordingly. But it always breaks on
this.sqlConn.Open();
Can anyone tell me what am I missing?
regards,
Zishan
|
|
|
|
|
Zishan wrote:
I installed it on the machine with SQL Server installed, it worked perfectly. But when I installed it on a client machine, the service does not start, and ends up with JIT compiltation error
Are the MDAC correctly installed on the target machine (see also .NET Framework 1.1 Redistributable Prerequisites[^])?
Best regards
Dennis
|
|
|
|
|
Anonymous wrote:
Can anyone tell me what am I missing?
Do you have an error message and/or the stack trace? (on the catch, try calling ToString() on the exception to get this information).
Yes, even I am blogging now!
|
|
|
|
|
Windows services run with the current app directory set to %SYSTEM32%, which can cause problems if you are reading your connection string from an external config file. To see if that is the case, try copying your config file to the %SYSTEM32% directory.
my blog
|
|
|
|
|
Yes, I have MDAC 2.8 installed on machines. I do not have a stack trace and I have hard coded the connection string in the program.
Its a very strange problem, because when I make it a Windows Application rather than a Windows Service, it works perfect.
My database server is running WinXp with SP2 and SQL Server 2000 with SP3, and my client machine is running Windows 2000 with SP3.
Same is the problem with the file access. I am trying to access a text file on a client machine with UNC address. The Windows Service is not starting. When I copy the same code on a Windows Appliaction, it is working fine. The Service does not have any problem with text file on the local drive.
Regards,
Zishan
|
|
|
|
|
Zishan wrote:
Same is the problem with the file access. I am trying to access a text file on a client machine with UNC address. The Windows Service is not starting. When I copy the same code on a Windows Appliaction, it is working fine. The Service does not have any problem with text file on the local drive.
I agree with Daniel that you should modify your program so it saves a stack trace in case of an unhandled exception and if I were system administrator and had to use your service I would expect it to write everything relevant into the Windows logs.
Without a stack trace however I can just give you my next best guess. And because you say that the service can access local files but can't access remote files with UNC paths then I'd say you're getting some kind of access denied exception. Remember that when you execute your code as a normal exe (and don't use run as) it runs with your permissions. As developer I assume you might have administrative privileges on your local machine and maybe even on the servers. Your service however runs with the permissions of the account you set in the service configuration. That's by default LOCAL_MACHINE\SYSTEM. Of course any local system account has no privileges on any remote machine. Even if it indeed is an domain account you setup for your service it might not have enough permissions to access the data you want to use. So check out your service configuration and see if that's the problem.
Best regards
Dennis
P.S. Why are you posting as Anonymous? Don't you have an account or are you just not logged in. Well, it's not like it really bothers me, but I'm curious to whom I'm writing.
|
|
|
|
|
Yes, that was an Access Denied error. I changed the service configuration to NT AUTHORITY/NetworkService and that started. Thanks for your help
Zishan
PS : I had an account here but I was too lazy to log in.
|
|
|
|
|
Hello all,
I am working on a program that displays descision trees in a panel control. The links between the nodes are drawn straight on to the panel whereas the nodes are custom controls.
Trying to print the contents of the panel I have used GetImage, unfortunately this only gives me the links and not the nodes. I suspect having studied further I should have drawn the whole lot to a graphics path... any way I can bodge it without rewriting all the graphics code? I wish to keep the custom controls as they allow me to process mouse events easily.
Rob
|
|
|
|
|
What you could do is create an Image object (as a member of your form class), give that to the PictureBox's Image property, then do all your drawing operations onto the Image itself instead of the picturebox (you can get a Graphics handle just as easily from the Image, so your code should need only minor modifications)
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|