|
WinForms have a Main form which you called in Application.Run(new MainForm()); this form must be active while your application is running. Beside your Child forms in MDIParent need their parent to be activate even if your parent form is not your Main form.
Hope can help you
Life is 5: 3 me, 1 you.
|
|
|
|
|
|
|
Sorry...I didn't know where this belonged.
|
|
|
|
|
My .Net 3.5 WinForm app won't display menu item tooltips. I did all of the following using the designer in the IDE:
0) Added a MenuStrip control to my form.
1) Created some image-only menu items.
2) Set both the Text and the TooltipText properties to the desired text.
3) Set the AutoToolTip property to true (and I tried false to see if it would pick up the actual menu item text).
When I hover the mouse over a menu item, no tooltip shows up. What am I missing?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: When I hover the mouse over a menu item, no tooltip shows up.
Cannot reproduce
Visual Studio 2008 - 9.0.30729.1 SP
.NET Framework 3.5 SP1
XP Pro
5.1.2600 SP2
Last modified: after originally posted -- forgot system info
led mike
|
|
|
|
|
What classes did you use for menu items, ToolStripMenuItem?
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
I used whatever the designer provided. I just checked it, and yes, it used ToolStripMenuItem .
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Odd, I tried with the following (just a fresh, single form application) and it worked fine. If you try this code do you still experience the same problem.
namespace WindowsFormsApplication4 {
partial class Form1 {
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent() {
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(284, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
this.toolStripMenuItem1.AutoToolTip = true;
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem2});
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(125, 20);
this.toolStripMenuItem1.Text = "toolStripMenuItem1";
this.toolStripMenuItem2.AutoToolTip = true;
this.toolStripMenuItem2.Image = global::WindowsFormsApplication4.Properties.Resources._3_5_Disk_Drive;
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(152, 22);
this.toolStripMenuItem2.ToolTipText = "I\'m tooltip";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 264);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "Form1";
this.Text = "Form1";
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
}
}
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
No tooltips, and only one of the menu items showed up. I've already tried the "basic form" approach, and I didn't have any luck.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The closest thing I found was this: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=115597[^], but it's old and for beta.
Since for example led mike couldn't reproduce, the code that worked for me didn't behave as expected for you, could this be an installation issue
I used (plus several hotfixes):
Microsoft Visual Studio 2008
Version 9.0.30729.1 SP
Microsoft .NET Framework
Version 3.5 SP1
Edition: Professional
on Windows Vista SP1
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
As near as I can tell, I don't have VS2008/SP1 nor DotNet 3.5/SP1 installed on this system...
I'll try the same code at home and see what happens...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
What is you code just tried work fine.
Learning to Code
|
|
|
|
|
lets say you set an initial byte[] size to 30 and the message that you receive has a size of 50. How would you handle that with Socket.BeginReceive
With Socket.Receive this would work:
byte[] buffer = new byte[30];
int size = Socket.Receive(buffer);
String msg = Encoding.ASCII.GetString(buffer, 0, size);
while(size > 0)
{
buffer = new byte[30];
size = Socket.Receive(buffer);
msg = msg + Encoding.ASCII.GetString(buffer, 0, size);
}
How would you do the same thing with Socket.BeginReceive?
Thank you,
Prateek
|
|
|
|
|
use the overloaded receive method that takes in an offset, and a length to read. Also, don't redeclare the buffer as it is unnecessary.
int read = 0;
byte[] buffer = new byte[255];
while( ( read = socket.Receive(buffer, 0, buffer.Length)) != 0){
... Encoding.ASCII.GetString(buffer, 0, read);
}
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Thank you for your suggestion... i know how to do it with Socket.Receive. I wanted to do this with Socket.BeginReceive. The problem is in order to get the first part of the msg, you'll have to use Socket.EndReceive and then how will you get the rest of the msg?
|
|
|
|
|
Begin Receive contains a similar overload as receive. The logic is the exact same, except in the callback method you must call BeginRecieve again after reading all of the bytes.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
so just for clearification the code would be something like this:
int size = socket.EndReceive(iasyncresult);
while(size > 0)
socket.BeginReceive(...);
|
|
|
|
|
no. read the MSDN.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
ok. Thanks for your help
|
|
|
|
|
If anybody is looking for the answer, do check this link [^] out.
Also, be careful with the ReceiveTimeouts. ReceiveTimeout is for synchrounous receive only. So, if you don't want your loop to get stuck, make sure you include some way of identifying the end of message.
Good Luck,
Prateek
|
|
|
|
|
I am currently writing UDP socket class to control a device. I created a class that has a UDP socket. I have blocking function that I uses the socket to transmit a packet to the device. The function than needs receieve the response packet/packets from devices. However, if no valid response is not recieved in x period of millisecond the function needs to timeout. I am having difficulties creating a way to calculate millisecond periods. In the past i use to use GetTickCount(); How do i accomplish this i C#
Scott
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
|
Create a timer and use the following event:
int tickCount = 0;
void timer1_Tick(object sender, EventArgs e) {
tickCount = tickCount + 1;
}
I haven't tested the code out, but it should work. Hope this helps
Prateek
|
|
|
|
|
The .net timers are not all equal and do not all perform as you might expect, especially in terms of resolution. Luc Pattyn has a great article on timers here[^] that may help - if not, it's a good read anyway
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|