|
Nick Hodapp (MSFT) wrote:
I take it back
hmm, both does the same, but thanx for the replies
Time to start the VB.Net to C# project then
Or maybe one of you MS guys can beat me to it.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
My take on the whole thing is rather use C# from the beginning.
Trolling, sure, but C# has always seemed to have more backing by MS and I hear the only reason why VB hasn't died is that it's Bill's baby.
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
SimonS wrote:
My take on the whole thing is rather use C# from the beginning.
I agree, but unfortunately there are quite alot of good code being published in VB.Net format
So now i have to manually parse files and change the structure, eg it took me 2 1/2 hours just to convert a 1700 line VB.Net class, excluding loops and other VB specifics, that normally would take just as long.
The thing is, in CLR its all the same. Then you can use Anakrino to view the code. That said, it does crash in some parts (maybe vb specific stuff???)
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
leppie wrote:
I agree, but unfortunately there are quite alot of good code being published in VB.Net format
That's funny, this is the major reason I was learning C# (because I keep finding alot of good code written there )
|
|
|
|
|
first of all i start a process by process start method
and then i get its parent and then child hwnd but now what want is that
if i have a button hwndle on a processs main window how to
check that this button is clicked or not or any other operation is performed on it or not.
and if i want to generate any mouse event let say mouse click event then how to generate it or any other message?
Remember that i have only the button hwndle do not have its object .
r00d0034@yahoo.com
|
|
|
|
|
Your project looks very much like a non .Net project, full with "hwnd" and so on.
I would recommend to choose a lower-level language such like C++/MFC that looks more adequate.
If you've got to stick with C#, you've got at least two choices :
- use interop, such as the code shown in the other thread
- use MessageQueue, which is a reliable messaging tunnel. I just gave a look and the .Net framrwork QuickStart tutorials are just helpful to start with. MessageQueue will not do everything, you'll have to do plummering between queues and the actual message subscribers/senders.
get to www.dotnet247.com. This server is almost as down as codeproject, but it is full of useful code snippets and revelant answers.
|
|
|
|
|
when i execute that line compiler coulde not recognise HWND structure what to do?
HWND h =(HWND)m_Handle.ToInt32();
r00d0034@yahoo.com
|
|
|
|
|
This object does not exist is C#. Use any int instead :
(from MSDN)
public static bool Report(int hwnd, int lParam) {
Console.Write("Window handle is ");
Console.WriteLine(hwnd);
return true;
}
|
|
|
|
|
but if i have to call vc++ sendMessage then i have to provide a valied hwnd .
i f not like that how to do it?
r00d0034@yahoo.com
|
|
|
|
|
I am afraid there is no more windows messaging API in C#. I guess you have to use interop and pass the HWND to lower-level code to send the message for you.
Here we go : (MSDN)
public class NativeMethods
{
public NativeMethods(){}
[StructLayout(LayoutKind.Sequential)]
public struct CopyDataStruct
{
public string ID;
public int Length;
public string Data;
}
[DllImport("user32.dll", EntryPoint="FindWindow")]
public extern static System.IntPtr FindWindow(string lpClasName,
string lpWindowName);
public const int WM_COPYDATA = 0x004a;
[DllImport("user32.dll", EntryPoint="SendMessage")]
public extern static int SendMessage(System.IntPtr hWnd,
int Msg, int wParam,
ref CopyDataStruct lParam);
}
private void SendingForm_Load(object sender, System.EventArgs e)
{
ReceivingForm rec = new ReceivingForm();
rec.Show();
}
private void button1_Click(object sender, System.EventArgs e)
{
NativeMethods.CopyDataStruct DataStruct = new NativeMethods.CopyDataStruct
();
DataStruct.ID = "1";
DataStruct.Data = "Sample Text";
DataStruct.Length = DataStruct.Data.Length;
IntPtr WHnd = NativeMethods.FindWindow(null, "ReceivingForm");
if(!WHnd.Equals(System.IntPtr.Zero))
{
NativeMethods.SendMessage(WHnd, NativeMethods.WM_COPYDATA,
0, ref DataStruct);
}
}
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case(NativeMethods.WM_COPYDATA) :
NativeMethods.CopyDataStruct ds =
(NativeMethods.CopyDataStruct)m.GetLParam(typeof
(NativeMethods.CopyDataStruct));
string s = ds.Data;
break;
default :
break;
}
base.WndProc(ref m);
}
|
|
|
|
|
You can get the Handle to the main window of a process from the "System.Diagnostics.Process" class. It has a "MainWindowHandle" property. Don't know if this helps, but hopefully it will
m
|
|
|
|
|
anybody done or know of anything fancy done with this.
the templates in visual studio aren't bad but they seem to ignore the <exception> and <example> fields amongst others
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Go to http://www.gotdotnet.com/team/csharp, choose tools and utilities on the right. There are a couple of better programs there.
|
|
|
|
|
thanks eric - by the way what are your favourite tools? I see you have created a regular expression workbench - a tool I wish was in Visual Studio from the beginning.
My particular favourite is XML spy - damn useful for creating xpath queries and such.
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Please help me solve this problem
I created an application that saves its settings to a file. This file has to be globally accessible. Here is the problem: If the administrator is the first to use the program, then the file will be created by the administrator. When a user with less rights logs-in, the application tries to modify the file. But, the they dont have enough rights.
How do I create a file that everyone has rights to? Or, How do I change the permissions to allow everyone to read, write to the file? (note: this file doesn't contain anything important, so its safe to allow unlimited access)
If someone could do me a favor and post an answer, I would be very glad. Thanks!
|
|
|
|
|
AK wrote:
Here is the problem: If the administrator is the first to use the program, then the file will be created by the administrator. When a user with less rights logs-in, the application tries to modify the file. But, the they dont have enough rights.
AK,
What you are describing sounds like a network rights issue. When the app is first installed the Admin needs to set the rights to the file for use by everyone.
With that said, are you sure that you want to be using a file for multi-user read-write? You will run into all kinds of issues related to concurrency. A database (even an Access MDB) would serve you better. (If you were using the file for read-only you could get away w/o any problems but read/write will give you headaches in a multi-user environ.)
|
|
|
|
|
Actually this is pretty similar to a network issue. But, in my case the problem resides in the NT file system. When an admin account creats a file the users with less rights (ie. normal users) cannot access the file that was created. Another thing, if a person with low rights creats this file it is accessible to the admins and people that have more power.
I just dont know how to change the permissions, to allow everyone to have full control.
|
|
|
|
|
AK,
Yeah, thats what I'm talking about. The Admin needs to change the rights.
|
|
|
|
|
I have a library at http://www.codeproject.com/useritems/NTSecurityNET.asp that allows one to manipulate NTFS access control lists. This may help you change the permissions of the file so that the appropriate users have access.
|
|
|
|
|
I sincerly thank you for point out the article. Its a wonderful peice of work. In fact, it solved my problem in only 3 lines of code!
Thanks again.
|
|
|
|
|
I'm trying to draw directly on the screen. Whatever is drawn needs to be "above" the controls on the form. And, of course, I need to erase whatever is drawn to restore the way things looked before I did my drawing.
I looked at the "Reversible" drawing functions on the ControlPaint object but these don't give me the control over the color that I need. (I really only need Black, White, and a dotted grid of Gray.)
What should I be looking at now to get GDI+ to work with me on this?
-----
I'm essentially trying allow users to select controls. If one control overlaps another I still want the selection cues to appear atop the covering control.
|
|
|
|
|
With DirectDraw you are able to draw directly on the screen!
|
|
|
|
|
Really all I'm trying to do is recreate Visual Studio's form desinger. I think adding DirectDraw would be overkill.
|
|
|
|
|
You got me interested!
What do you mean recreate VisualStudio's form designer?
I think there is a way you can just import the functionality from a the original libary. I think its located in C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\Microsoft.VSDesigner.dll.
If you want to do it another way, it can get very messy very fast. Ie. if you draw directly on the screen you then have to do hooks to handle the mouse events...
Good luck to you. By the way, ASP WebMatrix did an ASP think like this. They have a VisualStudio like UI, with with the ASP webforms designer surface.
|
|
|
|
|
To answer your question directly, this is how you can draw on the screen:
System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(System.IntPtr.Zero);
-or, something like this-
IntPtr handle = System.IntPtr.Zero;
System.Drawing.Graphics g = System.Drawing.Graphics.FromHdc(handle);
--
Basicly you need to tell it you use null as the handle. This creates a graphics object that draw on top of everything. But, it can be very messy.
|
|
|
|