|
Oh, Thanks Nish. It was stupid question,Wasn't it?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Mazdak wrote:
Oh, Thanks Nish. It was stupid question,Wasn't it?
Not at all Mazy, not at all.
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
How can I add something like "default" attribute to button? When I press the ENTER key I simply want to activate specific button, but where is the "default" attribute? It was in Visual C++, but in C# I don't see it...
|
|
|
|
|
The behavior you are looking for is the AcceptButton property of a Windows Form class.
Example:
this.AcceptButton = this.myButton;
Andy Gaskell, MCSD MCDBA
|
|
|
|
|
Which, after all, is a more elegant modeling...
Crivo
Automated Credit Assessment
|
|
|
|
|
I need to receive an event whenever the mouse moves, anywhere on the screen (so I can test if the mouse has moved out of/into a target rectangle). The Screen object, however, has no mousemove event as far as I can tell.
My current solution involves a fullscreen semitransparent window. This is a hassle and a kludge, however.
|
|
|
|
|
try
<code>
protected override void OnMouseMove(MouseEventArgs mea)
{
}
</code>
Nick Parker
|
|
|
|
|
i don't know how to do this in c#, but in my c++-times i wrote a mouse-system-hook-dll to handle system-wide mousemoves. there was no other (easier) way half a year ago.
:wq
|
|
|
|
|
another idea: maybe you can use the MouseEnter and MouseLeave messages each control (and so each form) provides.
but if that still isn't your applications clientarea, this helps you only to make the transparent window smaller (so that its client-size fits the rectangle you need to observe), i.e. not the whole screen anymore.
:wq
|
|
|
|
|
Hi.
I have a problem to implement a WNetEnumResource API32 function in C#. Does anyone have a example.
|
|
|
|
|
Hi
can u explain me what wsdl exactly is and where actually u are going ot use it ....
Any links for this topics will be very helpful...
Thanks
Atul
|
|
|
|
|
|
Hi,
I'm trying (only trying) to write a C# wrapper for the WinPcap library. Of course I started with the simplest function: Get the version of the lib. This works fine
Second thing: I tried to wrap the PacketGetAdapterNames() function (also pretty simple). Here's the source code:
//----------------------------------------------------------------------------
//WinPcap API Source code:
BOOLEAN PacketGetAdapterNames(PTSTR pStr,PULONG BufferSize)
{
HKEY LinkageKey,AdapKey;
UINT RegKeySize=0;
LONG Status;
ULONG Result;
PTSTR BpStr;
char *TTpStr,*DpStr,*DescBuf;
LPADAPTER adapter;
PPACKET_OID_DATA OidData;
int i=0,k,rewind,dim;
TCHAR AdapName[256];
ODSEx("PacketGetAdapterNames: BufferSize=%d\n",*BufferSize);
OidData=GlobalAllocPtr(GMEM_MOVEABLE | GMEM_ZEROINIT,512);
if (OidData == NULL) {
...
//----------------------------------------------------------------------------
//C#wrapper code I wrote:
[DllImport("packet.dll")]
extern static bool PacketGetAdapterNames(ref string pStr, ref ulong BufferSize);
//----------------------------------------------------------------------------
The function always returns false and the ref param variables are never updated (.
I have got a sample C app with source code, that uses the same API. This app works fine...
//----------------------------------------------------------------------------
WCHAR AdapterName[8192]; // string that contains a list of the network adapters
AdapterLength=4096;
if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE)
{
printf("Unable to retrieve the list of the adapters!\n");
return -1;
}
temp=AdapterName;
temp1=AdapterName;
while ((*temp!='\0')||(*(temp-1)!='\0'))
{...
-----------------------------------------------------------------------------------------
Has anybody got an idea?? I'm not very familiar with these kind of API calls.
G
|
|
|
|
|
A long in Win32 API is 32-bits, a long in .NET is 64 bits while an int is 32 bits.
If the string being passed in is a buffer (looks like it is) you should also be using StringBuilder instead of string.
With those two changes I come up with
[DllImport("packet.dll")]<br />
extern static bool PacketGetAdapterNames(StringBuilder pStr, ref uint BufferSize);
void GetAdapterNames() <br />
{<br />
System.Text.StringBuilder AdapterNames = new System.Text.StringBuilder(bufferSize);<br />
uint bufSize = (uint) bufferSize;<br />
<br />
PacketGetAdapterNames(AdapterNames, ref bufSize);<br />
}
I don't think ref is needed on the buffer because it will be passed like a char array to the function by the marshaler, putting ref on the buffer would be equivelant to WCHAR** in C/C++.
HTH,
James
Simplicity Rules!
|
|
|
|
|
You're the man! Thanks, it worked.
G
|
|
|
|
|
James,
Thanks again. I've got another question. Any idea how I can make a struct in C# that is the equivalent of: ??
typedef struct ADAPTER {
HANDLE hFile;
TCHAR SymbolicLink[MAX_LINK_NAME_LENGTH];
int NumWrites;
HANDLE ReadEvent;
UINT ReadTimeOut;
};
typedef struct PACKET {
PVOID Buffer;
UINT Length;
UINT ulBytesReceived;
BOOLEAN bIoComplete;
};
Thanks, G
|
|
|
|
|
Untested, but might work
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]<br />
public struct ADAPTER<br />
{<br />
public IntPtr hFile;<br />
public StringBuilder SymbolicLink;<br />
public int NumWrites;<br />
public IntPtr ReadEvent;<br />
public uint ReadTimeOut;<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public struct PACKET<br />
{<br />
public byte [] Buffer;<br />
public uint Length;<br />
public uint ulBytesReceived;<br />
public bool bIoComplete;<br />
}
Good Luck
James
Simplicity Rules!
|
|
|
|
|
James,
(Not knowing anything about the WinPcap Library)
Explain to me why using a StringBuilder in place of the TCHAR SymbolicLink[MAX_LINK_NAME_LENGTH] array would work here?
Wouldn't a variation of something like the following be the right choice?
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=MAX_LINK_NAME_LENGTH )]
public String SymbolicLink;
Thanks,
Neil
|
|
|
|
|
I don't know :-P
I originally had written what you had, then switched it to StringBuilder.
James
Simplicity Rules!
|
|
|
|
|
I am confident that the attributed string as I presented, is the right choice.
The StringBuilder reference is the size of a pointer, in contrast to the TCHAR array being n TCHAR(s) in length (+ alignment padding if necessary), directly affecting the size of the overall structure and the offsets of its members.
Regards
|
|
|
|
|
does .net framework support font's weight(in pounds)? i only can set bold in Font class.
And i see a method called FromLogFont may help me.
But how can i get reach to the stucture defined in former GDI?
|
|
|
|
|
hi!
I thing I found a bug in TreeView AfterCheck event but
I´m not 100 % sure.
this is my event (C#):
private void displaySaleContractTreeView_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
e.Node.Nodes[1].Checked = true;
e.Node.Nodes[2].Checked = true;
e.Node.Nodes[2].Nodes[0].Checked = true;
e.Node.Nodes[2].Nodes[1].Checked = true;
e.Node.Nodes[2].Nodes[2].Checked = true;
e.Node.Nodes[2].Nodes[3].Checked = true;
e.Node.Nodes[2].Nodes[4].Checked = true;
e.Node.Nodes[2].Nodes[5].Checked = true;
e.Node.Nodes[2].Nodes[6].Checked = true;
e.Node.Nodes[2].Nodes[7].Checked = true;
e.Node.Nodes[3].Checked = true;
MessageBox.Show("TEST");
}
what VS.NEt make:
at first it go to e.Node.Nodes[1].Checked = true;
then VS.NET go not to e.Node.Nodes[2].Checked = true;
VS.NET go again to e.Node.Nodes[1].Checked = true;
after this i become a message:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values.
why that doesn´t work?
but it work something like this:
private void displaySaleContractTreeView_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
e.Node.Nodes[1].ForeColor = Color.Red;
e.Node.Nodes[2].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[0].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[1].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[2].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[3].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[4].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[5].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[6].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[7].ForeColor = Color.Red;
e.Node.Nodes[3].ForeColor = Color.Red;
MessageBox.Show("TEST");
}
is it ahain a bug in VS.NET???
Pawel
|
|
|
|
|
I was working on a sample in Jesse Liberty's "Programming C#" book today and had the same problem. For some reason the code killed the application without an exception. Basically, it looked as though setting the Checked property fires the AfterCheck event. This causes a recursion that kills the program.
This seems to be different that the behavior I am used to (in say VB).
Also, remember that arrays start at zero. Nodes[0], Nodes[1], and Nodex[2] for a node with three child nodes.
You may also want to protect your code to prevent multiple firing of the AfterCheck event.
Boy. How ya gonna keep 'em down on the farm once they seen Karl Hungus.
<p style="text-align: right; margin: 0px;">- The Dude :cool:</p>
|
|
|
|
|
hi!
I have get a replay for me message on an other message board with the solution for this problem. and here is the replay message:
Re: A bug in TreeView AfterCheck event? Posted on: April 12 2002 12:10
Pawel,
By setting e.Node.Nodes[1].Checked = true;
you are firing a new event (because the checked was changed) and displaySaleContractTreeView_AfterCheck will be invoked again even before you come to the second line. I believe you are coming into an infinite loop here.
Anyhow, try to disable the AfterCheck event and enable it again at the end of your handler like this:
private void displaySaleContractTreeView_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
displaySaleContractTreeView.AfterCheck -= new System.Windows.Forms.AfterCheckEventHandler(this.displaySaleContractTreeView_AfterCheck);
e.Node.Nodes[1].Checked = true;
//..
//... do your stuff here
// ..
displaySaleContractTreeView.AfterCheck += new System.Windows.Forms.AfterCheckEventHandler(this.displaySaleContractTreeView_AfterCheck);
}
Hope this works,
Viel Spass,
Minh.
----------------------------------------------------
wow!!
thx!!
for every bug has enderminh a solution!!
IT´s WORK!!!!!!!!!!!!!!!
but some events that you used doesn´t exist.
this is the 100% correct code:
private void displaySaleContractTreeView_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
displaySaleContractTreeView.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.displaySaleContractTreeView_AfterCheck);
e.Node.Nodes[1].Checked = true;
e.Node.Nodes[2].Checked = true;
e.Node.Nodes[2].Nodes[0].Checked = true;
e.Node.Nodes[2].Nodes[1].Checked = true;
e.Node.Nodes[2].Nodes[2].Checked = true;
e.Node.Nodes[2].Nodes[3].Checked = true;
e.Node.Nodes[2].Nodes[4].Checked = true;
e.Node.Nodes[2].Nodes[5].Checked = true;
e.Node.Nodes[2].Nodes[6].Checked = true;
e.Node.Nodes[2].Nodes[7].Checked = true;
e.Node.Nodes[3].Checked = true;
displaySaleContractTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.displaySaleContractTreeView_AfterCheck);
}
thx again!!
DANKE!!
Pawel
-------------------------------------------
Pawel,
No, it's not a bug. It supposed to happen. You have said that "ey, if anyone changes this checkbox, please let me know and run this method". But since you are changing the checkbox inside this own method, it will recursively call this method again. It is supposed to happen. You are still registered to this event. It's like putting the microphone in front of your speaker, I guess.
Minh.
-----------------------------------------------
Pawel
|
|
|
|
|
I have an ImageList that I created using Icon (*.ico) files. I would like
to extract an image as an Icon, but casting doesn't work:
Icon test = (Icon)imgList.Images[1];
I know I can access the original .ico file from disk or resource, but since
it was already loaded in an ImageList, I thought this would be an easier
method. Does anyone know if this is possible?
Thanks!
|
|
|
|