|
not sure, i would've just thought you set it transparent like you've done. :s
-------------------------------------------------------
looking for hosting? ithium is good.
|
|
|
|
|
If your goal is display a message while the progress bar increments (like the percentage, which was common with older controls), you might be better off just extending the existing ProgressBar and provide your own painting by overridding OnPaint (do your drawing after calling base.OnPaint to make sure that the progress bar itself is draw first and your code gets drawn on top of it).
Getting the label to be transparent actually has to do with the parent forum in which it's contained. This only works in Win2K and newer (i.e., XP, 2003) since it uses layered Windows, "Windows" (or forms, dialogs) being the optimal word. A transparent color or alpha value is specified for the form an any control that uses the same color (ambience) down the chain of child controls is transparent/translucent as well. Since the ProgressBar is not a form and would paint in different colors anyway, that's one problem (the reasons go deeper, but I won't get into that).
Your painting method could be as simple as:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int value = (int)(Value / Maximum);
string s = value + "%";
StringFormat format = StringFormat.GenericTypographic;
format.Alignment = StringAlignment.Center;
e.Graphics.DrawString(value + "%", Font, SystemBrushes.ControlText,
(RectangleF)Bounds, format);
} This is untested, but should work and at least give you some ideas.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you.
I already considered this solution, but still hoped for a Label-based solution.
Again, thanks for your help.
Regards,
Dennis
|
|
|
|
|
I have just joined a company that develops its own in house apps for call centre use but does not like using mice on the call centre floor. Has anyone got experience of developing .NET apps that do not use a mouse , but still use a winform based environment . If so , are there any big pitfalls to look out for ?
|
|
|
|
|
can't think of any pitfalls.
use tab orders, key press events and suchlike. it isn't too hard to do.
surgeproof
-------------------------------------------------------
looking for hosting? ithium is good.
|
|
|
|
|
Make sure that the tab order of the controls is logical. i.e. the tabs move through the controls in one logical group before jumping to the next.
.
. +--------+ +--------+ +--------+ +--------+
. | Ctrl1A | | Ctrl1B | | Ctrl2A | | Ctrl2B |
. +--------+ +--------+ +--------+ +--------+
.
. +--------+ +--------+ +--------+ +--------+
. | Ctrl1C | | Ctrl1D | | Ctrl2C | | Ctrl2D |
. +--------+ +--------+ +--------+ +--------+
So, in this example, you'd tab from 1A to 1B to 1C to 1D rather than go for a Left-To-Right-Top-To-Bottom reading order approach.
This is just the first thought that popped in my head. There was a thread in the lounge today on bad-design (Some of it was quite funny) so the second thought is: As you test the system with your nice handy mouse beside you - resist the temptation to use it!
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Also, assigning shortcut keys to menu items is easy enough. To handle function keys or even simple key strokes you can handle the various Mouse* events (or override the various OnMouse* handlers in derived classes for more efficient and controllable code). If you need to respond to keys pressed at any time while any window is open, see the Application.AddMessageFilter method and the corresponding IMessageFilter interface which you'd implement and handle the keys trokes you want (in which case the values match up with the Keys enumeration to make things easier) by handling the various keyboard notification messages (see the Platform SDK for values).
Finally, to have a form handle key strokes while any control has the focus, see the Form.KeyPreview property documentation.
Using all that, who needs a mouse?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, everyone
I am using a dll developped in VC6. There are some functions I don't know how to wrap it in C#.
1. one function's parameter use self defined type, type definition is like this:
#ifndef LPLONG
typedef long far *LPLONG; /* 32 bit */
#endif
2. one function's parameter use 'BOOL *'
3. one function's parameter use 'char *'
4. one function's return value use 'char *'
5. one function's parameter use a structure
6. one function's parameter use a structure *
How shall I deal with these?
Thanks in advance.
|
|
|
|
|
1. ref int
2. ref bool
3. [MarshalAs(UnmanagedType.LPStr)]string
4. [return: MarshalAs(UnmanagedType.LPStr)]string
5. Just pass the struct, but see the docs for the StructLayoutAttribute
6. ref YourStruct
All these - escept for 3 and 4 - are value types so you use ref or out (the latter if you don't need to pass any initial value to your functions). Don't use ref or out with a string because it is already a reference type. Both char* and char[] are strings since a string is only an array of characters. Since you're using char and not wchar_t (or TCHAR ), you must marshal them as ANSI strings.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How about void *? Thanks.
|
|
|
|
|
|
Hello,
I'm trying to create a property sheet in C#. My idea is:
Create several user controls (derived from UserControl class) that represents my property pages.
Create a windows form that contains one Panel object to use like a placeholder for the pages created above.
The problem is that I don't know how to add a UserControl to a Panel object. (perhaps it's not possible...)
If someone has any idea on how to do this please reply
Thanks in advance
Pedro
|
|
|
|
|
Add a TabControl to a form with a few Button s under it. Add your UserControl s to each tab. After compiling your project, the UserControl s should be available in the Toolbox. If not, add them manually by adding a private field for each Type and instantiate them and initialize them in the InitializeComponent method that the Windows Forms designers use. It's not difficult and the designers aren't magic. Knowing how to add this stuff without a designer is essential in good development skills.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
Thanks for your post!
The solution you gave works well, but I was looking for something like CPropertySheet and CProperyPage in MFC.
Is there any control that we can use as placeholder for other controls?
Thanks again.
By the way, I like programming with the keyboard, not with the mouse 
|
|
|
|
|
That's not really what you asked for, though.
If you want a good implementation, see the IPropertySheet documentation in the Platform SDK on http://msdn.microsoft.com[^]. For example, I use a implementation similar to the following in our application:
public interface IPropertyPage
{
string Title { get; }
void Save();
void Cancel();
event PropertyChangedEventHandler PropertyChanged;
} Implement this type of interface on your control. Then create a PropertySheet class that allows you to add IPropertyPage implementations to it. When you call ShowDialog on your PropertySheet (should derive from Form ) it has all the pages in a TabControl . When the event is fired, enable the Apply button. When Apply or Save is clicked, call Save on each IPropertyPage in your collection and close the dialog if Save was clicked (it annoys me to no end when people click Apply then OK since OK is supposed to apply changes and close and - with all Microsoft implementations - does).
This is very similar to how MFC and the Windows Shell interfaces do it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello again!
That's exactly what I was looking for!
Thanks for your time
Pedro
|
|
|
|
|
Hi All,
I have a Windows Forms app with a treeview control. I'm trying to add a 'Rename' command to the context menu. The event handler for the context menu looks like the following:
private void cmMTRename_Click(object sender, System.EventArgs e)
{
if (tvModelTree.SelectedNode != null)
tvModelTree.SelectedNode.BeginEdit();
}
The node goes into edit mode but the context menu stays visible. Is there a way to hide the context menu prior to putting the node into edit mode?
Thanks,
Chris
|
|
|
|
|
I was outsmarted by the tree control.
I was handling the MouseUp event to display the context menu. It seems the treeview already does this for me so I was displaying it a second time.
Thanks.
Chris
|
|
|
|
|
I've created an MSI installer with VS.NET 2003 which runs great. I've created two file type associations. The association is made, but when I right click on the associated file and view the proerites I notice something strange. The "File Type" information is correct = "My Prog File"
but the "Opens with:" data is not correct, it just shows the program icon and not the name. I've tracked it down to a registry entry:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\MUICache]
There is a registry string in there called:
"C:\Program Files\MyCompany\MyProgram Folder\MyProgram.exe"
the value for this string is blank. When I assign the value of "MyProgram.exe" to the entry, the associated file property page now reflect both the program icon and name in the "Opens with:" area.
Does anyone how this getts filled in ? Am I missing some kind of description property in my assemby ?
Any thoughts on how to fix this would be very much appreciated.
|
|
|
|
|
I figured it out...I was filling inthe AssembyInfo.cs attribute sections.
|
|
|
|
|
glad you sorted it! :p
-------------------------------------------------------
looking for hosting? ithium is good.
|
|
|
|
|
Absolutely *love* the name
You should see my office at home...I've got damn near the whole collection of the old-style Guinness posters up.
|
|
|
|
|
Everyone loves a Guinness, or should.
|
|
|
|
|
Hi'
i'm using a graphical list view name 'GlacialList' and its realy very good.
i need to put an image on my scroll bar, does anyone know how can i do it?
did someone take care the scroll bar events by itself?
|
|
|
|
|