|
SendMessage SB_GETRECT on StatusBarPanel will give you the width of the SattusBar.
private const int WM_USER = 0x0400;
private const int SB_GETRECT = WM_USER + 10;
[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public int left;
public int top;
public int right;
public int bottom;
}
RECT Rectangle;
SendMessage(this.StatusBar1.Handle.ToInt32, SB_GETRECT, Panel, Rectangle)
Graphics.MeasureString() will compute the pixel length.
Compare the lengths and if the text is clipped display the ToolTip.
|
|
|
|
|
"...Graphics.MeasureString() will compute the pixel length..."
Does it mean that I have to take over the drawing of the statusbar and catch a painting event in order to use this?
Thanx for all the help.
|
|
|
|
|
|
Thanx for your time. I was looking for something like 'DrawMode' in order to take over the painting, but nothing like this exists for this control. How and what event am I looking for to catch?
Thank you
|
|
|
|
|
In the StatusBarPanel you can
this.Parent.DrawItem += new StatusBarDrawItemEventHandler(Parent_DrawItem);
private void Parent_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent)
{
//Do the measure String
}
Anyway I will also make a demo app.
|
|
|
|
|
Here is a part of my code. I'm using e.Panel.Width to get the width of the panel. Is there a difference between this and what you suggested?
...this.statusBar1.Panels[0].Style = StatusBarPanelStyle.OwnerDraw;
this.statusBar1.DrawItem += new StatusBarDrawItemEventHandler(Parent_DrawItem);
...
private void Parent_DrawItem(object sender, StatusBarDrawItemEventArgs e)
{
SizeF stringSize = e.Graphics.MeasureString(e.Panel.Text, e.Font);
...
From here on I'm using stringSize.Width and e.Panel.Width, but when visually panel ends where the text ends their actual widths are very different, eventhough visually they are the same.
Why such difference?
Thank you for all the help
|
|
|
|
|
is there any way i can use a font in a form with out installing it on the machine may be as an embedded resource or like that...
|
|
|
|
|
How would I declare an array of pens and how would I access their attriblutes after I've declared?
Pen [] penArray = new ??.....
|
|
|
|
|
Pen[] penArray = new Pen[] { new Pen( Color.Blue ), new Pen( Color.Black ) };
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
|
There seems to be no direct way to databind to a StatusBarPanel; I've run across some incomplete code samples that advises using a method to create a property for the statusBarPanel and then use the new property to databind to the dataset. The problem is I don't know how to proceed from there. Any help greatly appreciated.
Code Snippet ==========================================================
public string StatusBarPanel1Text
{
get
{
return statusBarPanel1.Text;
}
set
{
statusBarPanel1.Text = value;
}
}
|
|
|
|
|
In you Form do the following
StatusText st = new StatusText();
st.StatusBarPanel1Text = "HELLO";
this.statusBar1.DataBindings.Clear();
this.statusBar1.DataBindings.Add( new Binding("Text", st, "StatusBarPanel1Text"));
Declare the class
public class StatusText
{
private string str;
public string StatusBarPanel1Text
{
get
{
return str;
}
set
{
str = value;
}
}
}
|
|
|
|
|
Hi,
Thanks for responding to my issue; I tried your suggestion and it doesn't seem to work for me. I get no errors but the statusBarPanel remains unaffected.
|
|
|
|
|
I'm trying to modify one of my company's deployment projects. I've added a dialog to prompt the user to enter a server name. But I don't know how to get this value and do anything with it. Also, I'm trying to find any way to actually change the design of the dialog, is there a way to do this? Any help or links to good tutorials would be appreciated. Thanks in advance.
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
BlackDice wrote:
I've added a dialog to prompt the user to enter a server name.
Have you done this via adding a "Textboxes" user interface window to the User Interface screen? If so, go to the properties window and you will see, in addition to BannerBitmap, BannerText, and BodyText, 4 possible edit values.
Each of the 4 edit values have a label, a property name (use this to then retrieve the input at a later time), and a boolean visible. You can make 3 of them invisible if you only need the first one. You will notice in Edit1Property, the default value is "EDITA1"
So for instance, if you are wanting to do something with the server name during the "Install" phase, you would do the following:
(1) Add a class library to your setup project's solution;
(2) Mark that class as an installer project through an attribute (MSFT[^])
(3) Open the Custom Actions editor window, and right-click on Install
(4) Add your output for your class library
(5) Get the Properties for that new entry under Install, and look at the CustomActionData field.
(6) Add a string to pass in such as /f1=[EDITA1]
Back in the class...
(7) Override the Install method
(7a) Call base.Install()
(7b) Call Context.Parameters["f1"] to get the value
That may not be completely accurate, but may give you more stuff to search for on google.
|
|
|
|
|
thanks for your reply. I got most of that accomplished Friday right before I left work. I did finally find some stuff after Googling enough. Now the only problem I'm having is finding out how to disable the 'next' button if the textbox is empty. according to one page I found online, there should be a 'condition' property for the dialog, but I don't see one. and I don't want to do it as a custom action in the overridden 'Install' method, because that's too late in the process. any other suggestions or help will be greatly appreciated. thanks !
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Well, I have 2 thoughts.
The first would be using ORCA, which is a free tool from Microsoft. What this is, is this allows a compiled msi file to be opened up and edited. It's like a database tool.
I was poking around and I saw 2 tables that might be useful: Control, and ControlCondition. My theory is to add 2 rows to ControlCondition. The values would be as follows:
(1)
Dialog: CustomTextA
Control: NextButton
Action: Disable
Condition: CustomTextA_EDITA1="" or EDITA1=""
(2)
Dialog: CustomTextA
Control: NextButton
Action: Enable
Condition: CustomTextA_EDITA1<>"" or EDITA1<>""
I tried to test this theory, but I couldn't get it to work. Maybe you can play around with this.
My second theory was to use custom actions. During Install, you can actually pop up a modal dialog custom form. You can do anything you want at that point, including cancelling installation. You just use it like a regular windows form. You mentioned that may be "too late" in the process, so I'm not sure what it is that you "need" beforehand that would force you to know before the install method initializes.
Hope this helps at all.
Oh, and you can get ORCA here[^].
|
|
|
|
|
I also downloaded the sdk the other day to get orca. I can view all that stuff and I already tried to change two rows that were in there (that didn't help). But I didn't try to add my own two rows. I will try that and see if I can get it to work. BTW, this dialog asks for the name of the server where the user's SQL Server db is located. If it's empty, I don't want them to be able to go to another dialog, then click 'Install' before telling them they need to enter a server name. I'll try your suggestion and see what happens. Thanks again!
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
OK, your theory worked!!! (I had to use EDITA1 instead of using the dialog name also). But the only problem now is that if the user puts in a space, it still accepts it as being filled. But what are the chances of the user putting in a space?.....yeah, right! gotta see if I can find a way to trim what they have. You've been a great help. thanks!
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Excellent! And I think you can use relatively complex conditional statements. Give this MSDN link out a try: Contitional Statement Syntax[^].
Good luck, and glad I could help.
|
|
|
|
|
Do i have to set an ArrayList declaration to null in the deconstructor? If not why? Please help.
Nana
|
|
|
|
|
|
Deconstructor in c# ???? I think Managed code in .NET as Garbage Collector. And ArrayList is part of managed Code but i dont know if that garbage is collected. You can try something like doing a loop in that you declare a new ArrayList with some elements. Run it. Then go to Windows Task Manager and if the memory of your program doesn't stop climbing then its because that garbage isnt collected. Put some "big" elements in Array List.
If not try to set ArrayList to null as you say and try again.
Bye.
pharaoh
|
|
|
|
|
If you create a lot of ArrayList objects in a loop, they will not be garbage collected unless you run out of memory. The garbage collector will run when other programs are idle, it will not run while your loop is running, unless absolutely neccesary. Also, the garbage collector collects the oldest objects first, the objects that you just created will be collected last.
---
b { font-weight: normal; }
|
|
|
|
|
Also destructors do exists in C# .NET. They are compiled into Finalizer method in the IL.
If one thinks that by the timeGC to start its next collection, the application runs out of memory, GC.Collect() could be handy. But I would always try to avoid it. As a matter of fact I have never used it.
|
|
|
|