|
Implement the singleton pattern using a static class:
public class MyGlobalClass
{
private MyGlobalClass()
{
// Init any local info
}
public readonly static Instance =
new MyGlobalClass();
private int someField;
public int someProperty
{
get { return someField; }
set { someField = value; }
}
}
Gary
While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'
- Dilbert
|
|
|
|
|
were should i start, im still reading about neural networks and how to implement them, but how would i make it in a real-life situation, i would like to scan documents from my scanner, save them to a bitmap, and then get the text from it. I would like to expirement and this is just a project i am interested in doing..
|
|
|
|
|
There are some books on Amazon that talk at length about OCR. I've never seen useful info on the web, nor have I done it myself.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi, I have a question about the function SendInput from the Win32 API. Does it send the input to the active application? The documentation states that it puts it serially into the keyboard and mouse streams, but I am calling it as follows: with Notepad or Microsoft Word open
SendInput(1, ref input, Marshal.SizeOf(input));
where input is define as follows:
public struct INPUT
{
public int type;
public MOUSEINPUT mi;
public KEYBOARDINPUT ki;
}
I am getting the information to fill in the structs from another computer, and they are the same, but it does not actually send a keystroke. For example, if I type 'a' on computer 1, then it should SendInput 'a' on the second computer.
Thanks for your help.
Keith La Force
|
|
|
|
|
The SendInput API function only works on the local machine. SendInput sends keyboard and mouse message to whatever application has the input focus at the time. It will NOT inject input into a remote machine's message queues. There is no function that will do this for you.
In order to do something like this, you'll need to write two applications. One to receive and interpret commands and data on what to do (like posting keyboard messages and what keys to post), and a second app to send appropriate commands to tell the first app what to do.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, I'm sorry for the confusion. The app that you describe is exactly what I have setup. I have the SendInput calls in the recieving application, which interprets the data from the sending application, and proceeds to call SendInput.
|
|
|
|
|
Your struct isn't declared correctly. The mouse, keyboard, and (other) hardware input is a union. Right now you're not only mis-aligning your data but more than likely clobbering the stack. To declare unions in .NET, you must use an explicit layout like so:
[StructLayout(LayoutKind.Explicit)]
public struct INPUT
{
[FieldOffset(0), MarshalAs(UnmanagedType.U4)] public int type;
[FieldOffset(4)] public MOUSEINPUT mi;
[FieldOffset(4)] public KEYBOARDINPUT ki;
}
[StructLayout(LayoutKind.Sequential)]
public struct MOUSEINPUT
{
public int dx;
public int dy;
[MarshalAs(UnmanagedType.U4)] public int mouseData;
[MarshalAs(UnmanagedType.U4)] public int dwFlags;
[MarshalAs(UnmanagedType.U4)] public int time;
[MarshalAs(UnmanagedType.SysUInt)] public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
public struct KEYBOARDINPUT
{
public short wVk;
public short wScan;
[MarshalAs(UnmanagedType.U4)] public int dwFlags;
[MarshalAs(UnmanagedType.U4)] public int time;
[MarshalAs(UnmanagedType.SysUInt)] public IntPtr dwExtraInfo;
} The way you've declared it your keyboard data would not even be read because the SendInput function will read the data immediately after INPUT.type , which is your unused MOUSEINPUT . A union is declare in unmanaged code so that, depending on some variable (like type ), data representing different structures is packed onto the stack in the same location (this may, however, affect the bit alignment of fields after the union, which is why unions are typically declared last in a structure - but not always).
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]
|
|
|
|
|
Hi, I changed my code to fix the align problems, but it still does not do the SendInput correctly. Does SendInput send it to the active application? If not, how does it determine what program it will send it to?
Thanks for your help.
Keith
|
|
|
|
|
Given that you don't specify an HWND , logically it targets the foreground window's message pump. This is what you should assume since the documentation does not specify (this is typically the case when no HWND is specified with Windows APIs).
Have you looked at the documentation for the KEYBDINPUT struct to determine to what every field should be set?
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]
|
|
|
|
|
Hello,
can anyone please explain this code to me. What it is doing in detail? I still don't get the way override TOstring functions are used. This particular one is used in a class that is creating tokens for an interpreter program:
public override string ToString()
{
return "[" + kind.ToString() + "(" + (int)kind + "):" + line + ":" + column + ":" + str + "]";
}
Thank you in advance,
Newbie in tha block
|
|
|
|
|
BelMcGrady wrote:
I still don't get the way override TOstring functions are used
They are used to provide a string representation of the information a class represents.
BelMcGrady wrote:
"(" + (int)kind + "):"
I'm not sure how this would work. There's no default conversion from int to string that I know of.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
|
wow - cool. I will try that out next time I need it
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
BelMcGrady wrote:
can anyone please explain this code to me.
Sure, they are simply overriding what ToString() will produce when the ToString() method is called of the class instance it refers to. kind is some type defined within the class itself, where they are calling the ToString() method on the type of data type that kind represents. The (int)kind portion of the statement is simple a C-style cast of whatever value is held within the data type kind to an integer.
- Nick Parker My Blog | My Articles
|
|
|
|
|
i'm trying to track down why my app sometimes does not remove itself from memory when i hit the upper right hand X close button. what are some of the common things that don't get cleaned that would keep an app from closing down? i only create one other thread in my app, and i know that's not the problem because it wasn't even created yet at the times the app hung at close. thanks
|
|
|
|
|
actually, after further inspection, it appears it might be thread related. after a thread is created, it seems to not clean up sometimes. the thread is cleaned up by calling .Abort() on it. is this a guaranteed way to clean up a thread?
|
|
|
|
|
As MSDN states: "The thread is not guaranteed to abort immediately, or at all. This situation can occur if a thread does an unbounded amount of computation in the finally blocks that are called as part of the abort procedure, thereby indefinitely delaying the abort. To ensure a thread has aborted, invoke a Join method on the thread after calling Abort."
www.troschuetz.de
|
|
|
|
|
Are you hiding any forms? If the form is hidden it doesn't close, therefore the application stays open.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
hi, anyone knows how to delete a row or multiple rows in a datagrid?
Chris
|
|
|
|
|
a datagrid has it source binded to it, so when you delete an row from its datasource the row from the grid it will be deleted too.
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
Hi,
I use VS.NET 2003 to create a Crystal Report CallType.rpt and do the following
CallType rptCallType = new CallType();
crystalReportViewer1.ReportSource = rptCallType;
The report's data is from SQL Server. Every time I view the report using CrystalReportViewer, I am prompted for the database's password. Is there a way to save or fill in the password by code? I don't want to give the database's password to my application's users.
Thank you.
|
|
|
|
|
Hi,
iam using windows application. I have file named myfile.txt which can be located anywhere in my harddisk. I want to know whether there is anything equivalent in windows application for Server.Mappath to map to my file virtually.
Any furthur comments and suggestions are welcome.
Thanks in advance.
|
|
|
|
|
Unless you are somehow running your windows application inside IIS then the concept of a virtual path does not exist.
Perhaps you are confusing the concept with something else. Can you explain what you mean by "to map to my file virtually"?
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
virtually i mean that the file can be anywhere in my computer.I should to the location of my file by just specifying my filename.
|
|
|
|
|
A virtual path in the context of an ASP.NET application means that it is a URL, e.g. http://myserver.tld/mydir/myfile.txt
If your application is on your computer, and the file is on the computer then you just need to specify the file name, e.g. C:\mydir\myfile.txt
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|