|
Why don't you try MDI container form with multiple child forms.
|
|
|
|
|
This article [^]may be of some interest
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi all I am facing a problem in my application some times it appears to user that system/ application get hanged and he is unable to do ANY THING, the only option left to him that to kill the application using Task Manager. I found the reason that actually my message box is went to back of the current window due to which focus gets lost from the front.
I searched on the net and found that in my application overriding of a windows method cause such problem
this method is used to draw and display a timer/click on the MDI form rest i dont know about the functionality.
I am attaching the code if any body can help please reply as it's really confusing for me and i am not getting any solution for the same
protected override void WndProc(ref System.Windows.Forms.Message m)
{
try
{
base.WndProc(ref m);
switch (m.Msg)
{
case (int)WM_TIMER:
if (PreferencesController.IsAutoLockStart)
{
if (PreferencesController.IsSetAutoLock)
{
actHook.Start();
PreferencesController.EndTimeAutoLock = DateTime.Now.AddMinutes(PreferencesController.LockWorkStationTimeInMinute);
PreferencesController.IsSetAutoLock = false;
}
AutoLockWS();
}
if (PreferencesController.IsShowDateTime)
Main_OnNcPaint(ref m);
if (DateTime.Now.ToLocalTime().ToShortTimeString().Equals(
ConfigurationService.GetExcelMacroExecutionTime()))
ExcelFile.RunMacro();
break;
case (int)WM_NCPAINT:
if (PreferencesController.IsShowDateTime)
Main_OnNcPaint(ref m);
break;
}
}
catch (Exception ex)
{
ex.Message.ToString();
}
method called in above code is
private void Main_OnNcPaint(ref Message m)
{
paintTitleBar = m;
IntPtr hdc = GetWindowDC(m.HWnd);
Graphics g = Graphics.FromHdc(hdc);
RectangleF titleBarRectF = g.VisibleClipBounds;
int formWidth = (int)titleBarRectF.Width;
int CaptionHeight = Bounds.Height - ClientRectangle.Height;
Size CloseButtonSize = SystemInformation.CaptionButtonSize;
int X = formWidth - (CloseButtonSize.Width * 4) - 200;
int Y = 4;
int width = 200;
int height = CaptionHeight - 10;
string dateText;
if (PreferencesController.IsShowDateTimeWithSeconds)
{
dateText = DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt");
}
else
{
dateText = DateTime.Now.ToString("dd MMM yyyy hh:mm tt");
}
RectangleF timeDisplayRectF = new RectangleF(X, Y, width, height);
g.FillRectangle(new SolidBrush(Color.DarkBlue), timeDisplayRectF);
Font font = new Font(Font.FontFamily, Font.Size + 2, FontStyle.Bold);
g.DrawString(dateText, font, new SolidBrush(Color.White), timeDisplayRectF);
g.Dispose();
ReleaseDC(m.HWnd, hdc);
m.Result = IntPtr.Zero;
}
modified on Saturday, August 8, 2009 6:43 AM
|
|
|
|
|
please edit your message and put all code inside PRE tags, no one is going to read it as it is now.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks... any view regarding problem???
|
|
|
|
|
Hi,
that code is mysterious to me. I do have two suggestions:
1.
add a font.Dispose() to clean up the font you created. Gives better memory handling.
2.
if you don't do it already, modify MessageBox.Show(someString,...) to MessageBox.Show(this, someString,...) that might solve the problem.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I already did that... no luck so far
|
|
|
|
|
Hi,
How can we display a web page with an embedded flash object in a webbrowser control?? Take a youtube video page as an example..
Thank you.
|
|
|
|
|
Just needed a higher macromedia flash version on my IE!
|
|
|
|
|
I am storing card displays (eg J♣) in a list box through a list <KeyValuePair<string, int> and I want to order the cards numerically from greatest value to smallest value in the list box. When I change the sorting property on the properties box to "descending", the list is sorted inverse-alphabetically (ie Q is at top and 10 is at the bottom). I want to sort the list descending numerically, by value, so that A is at the top and 2 is at the bottom. How can I do this?
|
|
|
|
|
Here is one way MSDN - ListBox.Sort Method[^].
Alternatively you can put your string and int into a class and implement the IComparable interface. Then, possibly, put them into a collection to add via the ListBox.DataSource property
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
You can implement a custom type for Card s and override the CompareTo() method to implement custom sorting. Something like:
internal enum CardSuits
{
Spades = 0,
Hearts,
Diamonds,
Clubs
}
internal enum CardValues
{
Two = 0,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Jack,
Queen,
King,
Ace
}
internal class Card : IComparable
{
internal CardSuits Suit;
internal CardValues Value;
internal Card(CardSuits Suit, CardValues Value)
{
this.Suit = Suit;
this.Value = Value;
}
public int CompareTo(object obj)
{
int MyValue = (int)Value;
Card OtherCard = (Card)obj;
int OtherValue = (int)OtherCard.Value;
return MyValue.CompareTo(OtherValue);
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
switch (Value)
{
case CardValues.Two:
sb.Append("Two");
break;
case CardValues.Three:
sb.Append("Three");
break;
case CardValues.Four:
sb.Append("Four");
break;
case CardValues.Five:
sb.Append("Five");
break;
case CardValues.Six:
sb.Append("Six");
break;
case CardValues.Seven:
sb.Append("Seven");
break;
case CardValues.Eight:
sb.Append("Eight");
break;
case CardValues.Nine:
sb.Append("Nine");
break;
case CardValues.Ten:
sb.Append("Ten");
break;
case CardValues.Jack:
sb.Append("Jack");
break;
case CardValues.Queen:
sb.Append("Queen");
break;
case CardValues.King:
sb.Append("King");
break;
case CardValues.Ace:
sb.Append("Ace");
break;
default:
sb.Append("???");
break;
}
sb.Append(" of ");
switch (Suit)
{
case CardSuits.Spades:
sb.Append("Spades");
break;
case CardSuits.Hearts:
sb.Append("Hearts");
break;
case CardSuits.Diamonds:
sb.Append("Diamonds");
break;
case CardSuits.Clubs:
sb.Append("Clubs");
break;
default:
sb.Append("???");
break;
}
return sb.ToString();
}
}
...
List<Card>CardList = new List<Card>();
CardList.Add(new Card(CardSuits.Hearts, CardValues.Three));
CardList.Add(new Card(CardSuits.Clubs, CardValues.Queen));
CardList.Add(new Card(CardSuits.Diamonds, CardValues.Nine));
CardList.Add(new Card(CardSuits.Spades, CardValues.Ace));
CardList.Sort();
listBox1.DataSource = CardList;
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
Hi,
if your ListBox (or any other collection) contains items of type T , then you could provide an object implementing IComparer<T> and pass that to the Sort method.
All that interface takes is providing a simple method int Compare(T x, T y) in which you can implement any sorting order you like.
------------------------------------------------------------------------------
FWIW: you can edit and delete your own messages if you need to.
[EDIT]
Sorry, the above is insufficient, ListBox.Sort() does not take any parameters.
There are basically two ways of doing it:
1.
implement your own sort method; e.g. a bubble sort where you compare two items (in any way you see fit) and swap them if necessary.
2. better way:
use an intermediate collection, e.g. an array. This means:
- ListBox.Items.CopyTo(array,0) copies the items into an array
- ListBox.Items.Clear() removes the items
- Array.Sort(array, IComparer) sorts the items
- ListBox.Items.AddRange(array) adds them again, in the right order.
[/EDIT]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Saturday, August 8, 2009 3:46 PM
|
|
|
|
|
I am storing card displays (eg J♣) in a list box through a list<keyvaluepair<string, int=""> and I want to order the cards numerically from greatest value to smallest value in the list box. When I change the sorting property on the properties box to "descending", the list is sorted inverse-alphabetically (ie Q is at top and 10 is at the bottom). I want to sort the list descending numerically, by value, so that A is at the top and 2 is at the bottom. How can I do this?
|
|
|
|
|
Hi,
I have following text data and i want to split and store into Arry list and DataSet or DataTable.
"MR ABC","BLOCK 25","CITY","COUNTRY"
THANK YOU
RIAZ
|
|
|
|
|
M Riaz Bashir wrote: "MR ABC","BLOCK 25","CITY","COUNTRY"
String StrText="MR ABC","BLOCK 25","CITY","COUNTRY";
string [] SplitText= strText.Split(',');
Now, SplitText is an string array which contain 4 element
SplitText[0]="MR ABC";
.
.
SplitText[3]="COUNTRY";
Now, you can store it easily in ArrayList or DataTable .
|
|
|
|
|
Abhijit Jana wrote: String StrText="MR ABC","BLOCK 25","CITY","COUNTRY";
string [] SplitText= strText.Split(',');
Now, SplitText is an string array which contain 4 element
Not quite, you cannot allocate a string as
="ABC", "DEF" as there is not such C# syntax. Replace with:
string strText="\"MR ABC\",\"BLOCK 25\",\"CITY\",\"COUNTRY\"";
string [] SplitText= strText.Split(',');
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
OriginalGriff wrote: string strText="\"MR ABC\",\"BLOCK 25\",\"CITY\",\"COUNTRY\"";
Yeah. you are right. Actually I didn't concentrate on that part. It should like that you said. That was my silly mistake.
Thanks for correcting me
|
|
|
|
|
Bashir..I guess your question is your answer..You mentioned -
M Riaz Bashir wrote: text data and i want to split
So just check out the Split method of String.
|
|
|
|
|
This article [^]may be of use. You need to be careful of additional commas in the data and when to remove the double quotes.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I Just make a formula for....
sum({Invoice.Cost}
but it gives an error....
A Number filed or currency Amount field is required here.
|
|
|
|
|
Hi friends,
what is the best way to implement given requirement.
I need to open multiple forms in multiple tabpages control and save it on application exit and reload it on Application starts.
Thanking you,
modified on Saturday, August 8, 2009 2:42 AM
|
|
|
|
|
If your forms have a serializable model (a type that holds each form's state), serialize and persist it when application exits. This can be deserialized for restoring the state when application starts next time.
Other way is to manually persist all the information that needs to be restored. You can use any kind of persisting mechanisms.
|
|
|
|
|
In my application, I do the same thing. I save only the location and size of forms.
|
|
|
|
|
As you want to save the layout,create a base form and inherit all the forms.
Now for saving layout you can have a single utility class which would take the base form as parameter to serialize.So while eixiting the application pass your forms instance to serialize. Do the unserialization while application start.
I can suggest you a thrid party (if budget permits ) DevExprss [^]controls which might be helpful in this.
|
|
|
|
|