|
tooltip just appear when we move mouse over it parent, can we display notifyicon's tooltip when we click mouse on a button ?
thanks...
|
|
|
|
|
can we insert image to treeview's background ? and how ?
thanks...
|
|
|
|
|
The TreeView control doesn't support a background image. You'll have to write your own version of the TreeView control, supplying the code to draw the background image, or use a third party component.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I have this very strange problem:
When I set the propery FormBorderStyle.Sizable of a Form and when I set the size to be less than 122 in width the width is set to 122 by default.
It seems that there is a default width to a Form when I set FormBorderStyle.Sizable.
But when I set FormBorderStyle to any other value, than I can change the size to what ever I like.
Does anyone familiour with this problem? Is it a bug? How can I change this default width?
Please help me,
Anna.
|
|
|
|
|
I'm just guessing here, maybe you need space for the icons (maximize, minimize, close) on the title bar. Try removing them to see if this changes...
Yes, even I am blogging now!
|
|
|
|
|
This isn't the default size, but the minimum size a form can be while the ControlBox (Minimize, Maximize, and Close buttons) is enabled. Turning off the control box will enable you to shrink the form down further.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I hit this article which i was looking for.
Iam currently stuck in writing a Simple Multicast application. I would appreciate if any of you could trace out the exact problem.
I would like to know is there any problem with code, or we need to check some external settings. please also let me know how to do that.
I have pasted the code below:
Sender Code:
------------
#define DESTINATION_MCAST "235.6.7.8"
//#define DESTINATION_MCAST "224.0.0.2"
#define DESTINATION_PORT 2345
#define BUFSIZE 2000
void sendMulticast()
{
int nRet = 0, nSize = 0, nOptVal = 0;
SOCKET hSock;
char achInBuf[BUFSIZE];
struct sockaddr_in destAddr, socketLocalAddress;
u_short nSourcePort = 0;
struct ip_mreq stIpMreq;
/* create a datagram (UDP) socket */
hSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
int error = WSAGetLastError();
if (hSock == INVALID_SOCKET)
{
printf ("Socket creation failed \n");
return;
}
// Bind the socket
// NOTE: Normally, we wouldn't need to call bind unless we were
// assigning a local port number explicitly (naming the socket),
// however Microsoft requires that a socket be bound before it
// can join a multicast group with setsockopt() IP_ADD_MEMBERSHIP
// (or fails w/ WSAEINVAL).
socketLocalAddress.sin_family = AF_INET;
socketLocalAddress.sin_addr.s_addr = htonl(INADDR_ANY); // any interface
socketLocalAddress.sin_port = 0; // any port
nRet = bind(hSock, (struct sockaddr*) &socketLocalAddress,
sizeof(socketLocalAddress));
if (nRet == SOCKET_ERROR)
{
printf ("Bind call failed \n");
}
// Join the multicast group
stIpMreq.imr_multiaddr.s_addr = inet_addr(DESTINATION_MCAST); /* group addr */
stIpMreq.imr_interface.s_addr = htonl(INADDR_ANY); /* use default */
nRet = setsockopt (hSock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char FAR *)&stIpMreq, sizeof (stIpMreq));
if (nRet == SOCKET_ERROR)
{
printf ("Add membership option failed \n");
}
nOptVal = 32;
nRet = setsockopt (hSock, IPPROTO_IP, IP_MULTICAST_TTL,
(char FAR *)&nOptVal, sizeof(int));
error = WSAGetLastError();
if (nRet == SOCKET_ERROR)
{
printf (" set Sock Opt failed \n");
return;
}
/* disable loopback of multicast datagrams we send, since the
* default--according to Steve Deering--is to loopback all
* datagrams sent on any interface which is a member of the
* destination group address of that datagram.
*/
//By disabling this option we avoid getting the multicast packet back.
nOptVal = FALSE;
nRet = setsockopt(hSock, IPPROTO_IP, IP_MULTICAST_LOOP,
(char FAR *)&nOptVal, sizeof(int));
if (nRet == SOCKET_ERROR)
{
printf ("multicast loop option not supported ");
}
/* increase the IP TTL from the default of one to 64, so our
multicast datagrams can get off of the local network
*/
/*
Initialize the Destination Address structure
this is the address we send the multicast packet to.
*/
destAddr.sin_family = AF_INET;
destAddr.sin_addr.s_addr = inet_addr (DESTINATION_MCAST);
destAddr.sin_port = htons (DESTINATION_PORT);
//Init the buffer we send
memset (achInBuf,'\0',sizeof(achInBuf));
strcpy(achInBuf,"Saying Hi To You");
/*
We don't have to register for sending,, any host can send a multicast
packet, expect that the receiver one who registers only will get it.
*/
for (int nIndex = 1; nIndex <= 5; nIndex++)
{
nRet = sendto (hSock, (char FAR *)achInBuf,
strlen(achInBuf), 0,
(struct sockaddr FAR *) &destAddr,
sizeof(destAddr));
Sleep(2000);
if (nRet == SOCKET_ERROR)
{
printf (" Failed in send to \n");
return;
}
printf ("Sent the %d multicast packet %s\n",nIndex, achInBuf);
}
closesocket(hSock);
}
RECEIVER CODE
-------------
#define DESTINATION_MCAST "235.6.7.8"
//#define DESTINATION_MCAST "224.0.0.2"
#define DESTINATION_PORT 2345
#define BUFSIZE 2000
void receiveMultiCast()
{
int nRet = 0, nSize = 0, nOptVal = 0;
SOCKET hSock;
char achInBuf[BUFSIZE];
struct sockaddr_in srcAddr, destAddr;
u_short nSourcePort = 0;
struct ip_mreq stIpMreq;
/* get a datagram (UDP) socket */
hSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
int error = WSAGetLastError();
if (hSock == INVALID_SOCKET)
{
printf ("Socket creation failed \n");
return;
}
#if 0
hostent* remoteHost;
unsigned int addr;
int namelen = sizeof(destAddr);
addr = inet_addr("172.21.37.109");
remoteHost = gethostbyaddr((char *) &destAddr.sin_addr.s_addr, 4, AF_INET);
// printf("host name %s",remoteHost->h_name);
int ret = getsockname(
hSock,
(struct sockaddr FAR *)&destAddr,
&namelen
);
error = WSAGetLastError();
remoteHost = gethostbyaddr((char *) &destAddr.sin_addr.s_addr, 4, AF_INET);
printf("host name %s",remoteHost->h_name);
#endif
//Winsock requires us to bind/name the socket before we become a member of group.
srcAddr.sin_family = AF_INET;
srcAddr.sin_port = htons (DESTINATION_PORT);
srcAddr.sin_addr.s_addr = htonl (INADDR_ANY);
nRet = bind (hSock,
(struct sockaddr FAR *)&srcAddr,
sizeof(srcAddr));
error = WSAGetLastError();
if (nRet == SOCKET_ERROR)
{
printf ("Bind call failed \n");
}
/* join the multicast group we want to receive datagrams from */
//Here initialize the group which we wish to join..
stIpMreq.imr_multiaddr.s_addr = inet_addr (DESTINATION_MCAST); /* group addr */
stIpMreq.imr_interface.s_addr = htonl (INADDR_ANY); /* use default */
//This calls creates and adds us as a member.
nRet = setsockopt (hSock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char FAR *)&stIpMreq, sizeof (stIpMreq));
error = WSAGetLastError();
if (nRet == SOCKET_ERROR)
{
printf ("Set socket option failed \n");
return;
}
printf("\n Waiting for data \n");
for (int nIndex = 1; nIndex <= 5; nIndex++)
{
/* Recv the available data */
nSize = sizeof(destAddr);
nRet = recvfrom (hSock, (char FAR *)achInBuf,
BUFSIZE, 0,
(struct sockaddr *) &destAddr, &nSize );
if (nRet == SOCKET_ERROR)
{
printf ("receive from failure \n");
}
printf ("Received the %d Packet \n",nIndex);
achInBuf[nSize] = '\0';
char *recvIpAddressPtr = NULL;
recvIpAddressPtr = inet_ntoa(destAddr.sin_addr);
printf(" Received message::%s from IP:: %s \n",achInBuf,recvIpAddressPtr);
//drop the membership
} // for (int nIndex = 1; nIndex <= 5; nIndex++)
nRet = setsockopt (hSock, IPPROTO_IP, IP_DROP_MEMBERSHIP,
(char FAR *)&stIpMreq, sizeof (struct ip_mreq));
error = WSAGetLastError();
if (nRet == SOCKET_ERROR)
{
printf ("Drop membership socket option failed \n");
return;
}
closesocket(hSock);
}
|
|
|
|
|
Ingoring the fact that you've got the wrong forum, do you really not see a problem with posting a couple hundred lines of code along with the instuctions, "Please dubug my code"?
Charlie
if(!curlies){ return; }
|
|
|
|
|
Sorry for the trouble, but the fact is i needed some help in figuring out the problem in using multicast, as it does not seem to work in my network here.
I have put the code just for reference with comments.
|
|
|
|
|
You are definately in the wrong Forum. This is the C# Forum and you posed C++ code. Good Luck getting a response.
On top of that, you didn't mention ANYTHING about what kind of problem your having, any error messages, nothing. I would suggest you include such information when you repost your question in the C++ Forum.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
can someone help me with this little problem. Im trying to send a few bytes at a time over the connected network. I call socket.BeginSend() to send it async-ly. the problem is when i send my data the server is recieving to much or two little information. im positive the server is working find and im pretty sure the problem lies in the IAsyncResult method called by socket.BeginSend(). Here ill include as little code as possible (since theres alot to make this work)
//i read the data here, i only want to send the ammount that //i read of by, sybolized by the variable(read)
while((read=st.Read(by,0,by.Length))!= 0)
{
StateObject ss = new StateObject(s);
ss.buffer = by;
ss.Available=read;
//send by,offset 0 so it reads from begining
//followed by only read length incase we are //near the end of the file.
s.BeginSend(by,0,read,SocketFlags.None,new AsyncCallback(sen.MainSent),ss);
//Thread.Sleep(1);
by = new byte[12];
Application.DoEvents();
}
//now for the AsyncCallback MainSent
public void MainSent(IAsyncResult e)
{
try
{
StateObject j = (StateObject)e.AsyncState;
int i = j.socket.EndSend(e);
if(i>0)
{
//if i isnt zero there is still data left to be sent.
//here is the problem, how do i tell it to only send
//the remaining bytes of j.buffer
j.socket.BeginSend(j.buffer,i,j.buffer.Length-i,0,new AsyncCallback(MainSent),j);
}catch{}
}
thnx for your time, i hope i can find help so i can just move on from this stupid issue.
p.s: the MainSent callback was wrote with the fact in mind that i would send a entire files bytes at once. but now its wrote to only send pieces at a time (in this case 12kb at a time)
~jesse
The Code Project Is Your Friend...
|
|
|
|
|
I take it english isnt your 1st language, so your question is a little hard to understand.
A good place to start trying to locate your problem is to put some actual error handling into that catch block, so that we can see any error that occurs,
if(i>0)
{
j.socket.BeginSend(j.buffer,i,j.buffer.Length-i,0,new AsyncCallback(MainSent),j);
}
catch(Exception e)
{
Console.WriteLine(e);
}
|
|
|
|
|
English is my first language actually even if it is cryptic at times.And,Dont worry about the issue, i fixed it myself.
The Code Project Is Your Friend...
|
|
|
|
|
Hi!
I'm trying to open a file with a serialized (binary) arraylist. The problem is that the application in which I save the data saves the assemblyname in the file, so when I try to open the file in another application whith another name, it throws an exception. System.Runtime.Serialization.SerializationException. There's probably an easy way to solve this but I'm rather new at this so...
Thanx
Andreas Färnstrand
|
|
|
|
|
throw in some of your code you used to save the serialized arraylist. i have my serialize class wrote with this code.. among others. this will fill the memorystream and return its byte[]
MemoryStream memstr = new MemoryStream();
BinaryFormatter formatter =new BinaryFormatter();
formatter.Serialize(memstr,MyObjectHere);
return memstr.ToArray();
to save it i call this.
Stream fs= File.Create(path);
byte[] tmp = \*(The Byte Array From Above here)*\ memstr.ToArray();
fs.Write(tmp,0,tmp.Length);
//the serialized object is wrote now. to open it
stream= File.Open(path,FileMode.Open);
//
BinaryFormatter bf = new BinaryFormatter();
Object =(CastingObjectHere)bf.Deserialize(stream);
hope this helps, if not. someone older and wiser will help u =)
The Code Project Is Your Friend...
|
|
|
|
|
What you need is a SerializationBinder for the new assembly. See the sample code on MSDN for System.Runtime.Serialization.SerializationBinder for something similar to what you want...
Yes, even I am blogging now!
|
|
|
|
|
Hi
I use the ProcessController Sample from Microsoft to
learn and practice in C#. It's a realy good Sample
Code. I would like to write a Programm that shows the
Processes from Windows in black Color and all other
in a different Color. Anyone who knows how??
Greetings from Germany!
|
|
|
|
|
|
I mean Processes from the OS. SystemProcesses.
When I look
to the Task Manager I can not say wich from the
Processes are from Windows. I think it can be usefull
when you search for a Virus. A virus left a Process. When
those from Windows are in a different Color, to me they are
excluded cause they are friendly..
Hope you understand what I mean.
|
|
|
|
|
Hi,
I'd like to put all my strings in a single file, even the error or warning messages that i show to the user, so i can translate my program safelly. How can i do it? Should i use resource files? If so, how do i use them in C#?
Thank u very much,
Dirso
|
|
|
|
|
I recommend you to search MSDN for
"Localizing resources" topic. Especially, take a look at this article:
"LocalizedHelloWorld Sample: Demonstrates Satellite Assemblies for Console Applications"
Robin Panther
|
|
|
|
|
Can there be different JIT compilers for different machines like
applemac etc.
ihtesham
|
|
|
|
|
|
Hi there ,
I have a question on message loops when you create a windows application in c#. Basically after you have created the windows application project , you would notice that there is a Application.Run(new Form1()) line in the main() method of the Form1 class.
I understant that the above line starts a message loop for the form.
My questions are :
1. Is this needed so that the form can continue to receive keyboard and mouse events ?
2. Can only certain classed be used as arguments in the Application.Run(param) method ?
3. If its a message loop doesn't it block the thread ?
Any references to how it was done in the older days for windows programming is welcome.
Thanks,
Alok.
|
|
|
|
|
akarwa wrote:
1. Is this needed so that the form can continue to receive keyboard and mouse events ?
Yes: actually, any window message, as WM_SETTEXT or WM_PAINT, too.
akarwa wrote:
2. Can only certain classed be used as arguments in the Application.Run(param) method ?
The "param" you're mentioning, is just the form the Application.Run method will keep monitoring while it runs the message loop. As soon as the form "param" closes, the Application.Run call will return. You can have as many Application.Run() calls you may want (only one at a time, sure), and can even not pass any form to it, and the message loop will run until Application.ExitThread is called.
akarwa wrote:
3. If its a message loop doesn't it block the thread ?
Yes - aynthing that needs to be run on this thread will only be processed in a response to a window message, e.g., a button click.
Yes, even I am blogging now!
|
|
|
|
|