|
Thanks guys.
// Steve McLenithan
Cluelessnes: There are no stupid questions, but there are a lot of inquisitive idots.
|
|
|
|
|
I am importing Icons into my program to display in my list view.
While the Icons work, and the whole program mechanism is fine, I have a problem with background "noise".
Almost all of the images I import come with messy background colour around the edges that does not show up in any external bitmap or icon viewer.
The colour is not limited to black, and covers a number of shades of brown and dark grey.
This occurs both from importing icons to internal resources, and when openend from file, and persists in both Icon and Bitmap formats.
This is VERY frustrating, as it is ruining my application.
Does anyone know what causes it? And What can I do about it?
20-17 to England!
What a game...
GO JONNIE! Drop goal 20 seconds from end of extra time...
|
|
|
|
|
On XP or 2003, right? The problem is that the icon functions get the best icon to display in Windows. Since XP introduced alpha channels on icons, you're getting the icon with the alpha channel. Unfortunately, unless you bind to common controls 6 (.NET's System.Widnows.Forms controls are just wrappers around these), alpha blending isn't performed and you see the alpha channel as a solid color.
There's a couple different things you can do:- Enable theming in your app (which binds to comctl32 version 6).
- Read the icons and remove the alpha pixels. It's not as simple as it sounds, though. You have to also use an unsafe context for optimal performance. Christian Graus here on CP has several good articles about image manipulation.
As far as enabling theming in your app, if you are using .NET 1.1 call Application.EnableVisualStyles() before calling Application.Run() in your app's entry point (Main ). If you aren't using .NET 1.1 or your app could run on either 1.0 or 1.1, see my article, Windows XP Visual Styles for Windows Forms[^]. You can either embed the manifest file as a Win32 resource (not a .NET embedded resource) or keep it as a separate file that is named myappname.exe.manifest (same convention as .conf files but with a different extension).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Yes, XP.
Hmmm, I understand the cause, but unfortunately, I have only been programming for around a year (any serious ammount).
I'm basicaly using an arraylist to hold icons that I pull from a OpenFileDialog() to an icon list. These icons are pooled, and linked with file extentions in my archive viewer. The viewer uses the file extentions to lookup the Icon index from the list and sets the ImageIndex to that.
I don't know what Theming is, or how to remove the alpha pixels once the icons are read.
I've been deleting the alpha manualy on imported icons, but those that I pull from the dialogbox.
For now, I shall have a look at theming.
Thanks
Tris
|
|
|
|
|
The_Catalyst wrote:
I'm basicaly using an arraylist to hold icons that I pull from a OpenFileDialog() to an icon list.
Use an ImageList - that's what it's for and is much more suited for holding images.
The_Catalyst wrote:
I don't know what Theming is, or how to remove the alpha pixels once the icons are read.
That's why I gave you a link to my article. You type a simple text (XML) file (I give you a complete example) and give it a certain name. This isn't considered "programming" at all. You don't have to write a single line of code.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I am using an image list, but it doesn't offer the functionality I need for editing the images and moving them around that I need, so i store them in an arrayList and port them to an imagelist when i construct the object.
Had a look at the page, and a tinker, but too tired to do the whole thing today.
I have .NET 1.1, but how do i set it to build only in that?
Thanks
Cata
|
|
|
|
|
It already only builds for a particular CLR version, but it can often run on multiple versions of the CLR because of backward and forward compatibility (not always gauranteed - take note of the class library documentation when you're looking through to see what's new and what's obsolete).
To make sure it only runs on a particular version, use a .config file with the <startup> section that lists required and supported runtimes.
In any case, if you want the user to be allowed to run this with .NET 1.0 and it does work regardless of the pixel problem, use the .manifest file because it works in all cases (and with native Windows applications, too).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hi all,
just wondering if anyone has managed to work out how to list ODBC sources in a drop-down-listbox in C#?
have been able to do it in BCB 5.x and 6.x, but there doesn't seem to be a way to do it in C#...
any help would be greatly apprecitated...
cheers and thanks
nik
Nik Vogiatzis
PhD Candidate: University of South Australia
|
|
|
|
|
It all comes down to APIs. BCB might have APIs or library to help you do this while C# (actually, the .NET Framework base class library) currently does not. If you need this functionality, you need to P/Invoke the right native functions, like SQLDrivers and SQLDataSources . There also could be some .NET assemblies (the source language doesn't matter, remember, since all languages targeting the CLR compile to IL) out there. I haven't seen any, but googling might uncover something.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hi heath,
thanks for the response...
it don't necessarily believe is has anything to do specifically with BCB's libraries/API's...
more so, my gut feel is that it has something to do with the Win32 API, as the VCL (Visual Component Library) encapsulates much of the Win32API, in the same way that the MFC handles lower level API calls...
there is nothing necessarily problematic with me building a class in C++.NET to do the same thing, but i would have preferred keeping it all in the one language...
i concur with your sentiment that at the end of the day, in .NET everything targets the CLR compile to IL (something this old man needs to start getting used to), but my problem remains, i am used to the VCL which is implemented in BCB (Borland C++ Builder) and don't know the equivalent in Microsoft World...
i tried googling before coming to the forum, i like to do my homework first before bothering anyone... )
cheers and thanks for the suggestions though...
nik
Nik Vogiatzis
PhD Candidate: University of South Australia
|
|
|
|
|
Yes, it has everything to do with APIs. Application programming interfaces are provided by libraries that contain distinct functionality. The .NET BCL does not have these where something in VCL does. This functionality does exist in the ODBC APIs and all VCL is doing is wrapping it. Again, this hasn't been done in .NET (at least in an assembly that Microsoft produces). You would have to do it and you can do it in C#. See the DllImportAttribute for more information on P/Invoke. You're not rewriting anything - just importing a native function into managed code. This is oft-done in many larger applications because of APIs that don't exist in the BCL or other third-party libraries that do exist in various Windows APIs.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Nik, ODBC data sources are stored within the Windows registry. Here[^] is even an article in VB.NET explaining how to read these, it should prove trivial to convert this to C#. HTH
-Nick Parker
DeveloperNotes.com
|
|
|
|
|
hi nick...
greatly appreciated!!
cheers
nik
Nik Vogiatzis
PhD Candidate: University of South Australia
+++++++++++++++++++++++++++
Developing new generation Traffic Micro-simulation Tools for Traffic Engineers
|
|
|
|
|
Hi,
This may be a trivial question, but I'm a newbie to GUI's and c#.
I would like to use the functionality of radiobuttons but they should look like normal buttons. More specifically I want a number of buttons where only one of them is clicked active at a time. Somehow the active button should look like it's pushed down. I could use normal radio buttons but I their layout does not fit into my application and I think normal buttons (with a Text field on them) can be presented more compactly.
Any suggestions on how to approach this in greatly appreaciated.
|
|
|
|
|
Use simply labels and change their borders after click on them (create Your own inherited "RadioLabel" control). May be, You can use another control instead all "radiolabels" ... combobox etc.
Hi,
AW
|
|
|
|
|
On top of what A.Wegierski said above, you could get the effect of having only one selected by adding a property, say Group that is a string or a collection object. If it's a string, and when one of these controls is clicked, enumerate the Parent.Controls property like so:
protected override OnClick(EventArgs e)
{
if (this.Parent == null) return;
foreach (Control c in this.Parent.Controls)
if (c is RadioLabel && ((RadioLabel)c).Group == this.Group)
((RadioLabel)c).Selected = c == this;
} If you used a collection object (tip, implement IComponent as well to use it easily in the designer (or create a nifty designer to do this)), the object could add itself to the collection when the collection was assigned. When clicked, you run a similar routine as above but you don't have to worry about getting the parent's Controls collection or checking the group name - your collection already has the right controls:
public GroupCollection Group
{
get { return this.group; }
set
{
if (this.group != null) this.group.Remove(this);
this.group = value;
if (this.group != null) this.group.Add(this);
}
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I need to know how to gain access to items in the command prompt using c#. What I want to do is send a message on XP using system32\net send blah blah. I know how to do it in c++
system("net send blah blah");
but Im not sure on C#. Any help would be greatly appreciated.
Confused and Waiting
Pumpkin Knight
|
|
|
|
|
What you could do is instantiate the Cmd Window and pass in your arguments as such.
public void sendThread()
{
Process p = new Process();
p.StartInfo.CreateNoWindow=true;
p.StartInfo.FileName = "cmd";
p.StartInfo.Arguments = "net send COMPUTER Hello there.";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
p.Close();
}
|
|
|
|
|
Hi all,
Please some response!
I have an applıcation and when it's running , Windows can not shut down!
It says nothing but goes back to desktop when I click shut down.
I really dont know why , maybe one knows.
Key features about my application:
- Uses OleDbConnection and OleDbDataAdapter for an Access2000 database.
- Has a notify icon on task bar and starts from there (not with a window form)
- Starts when Windows starts by using HKLM/..../CurrentVersion/Run
All left are ordinary and what I have experience a lot.
Any help will be appreciated.
Thanks.
Utku KAYA
|
|
|
|
|
Do you have some kind of loop or strangeness in your exit condition?
|
|
|
|
|
Your Problem is that you override the close function. So if Win tries to shutdown your app still wants to go to trayicon and prevents Win from Shutdown.
Use this code to fetch the Win Shutdown Command:
protected override void WndProc(ref Message m)
{
base.WndProc (ref m);
if (m.Msg == 0x11)
{
boolAlowClose = true;
this.Close();
}
}
So i think you have a bool where you set true if you want realy to leave the application (where you check the bool on app close event and set e.cancel)
Hope this helps!
Greets
Matthias
|
|
|
|
|
I have written a c# service that uses a process timer to perform tasks on a regular basis.
Under certain conditions, I want this timer thread to be able to kill the service but I cannot figure out how to do it.
Can anyone help me?
Thanks in advance for your help!
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
I have figured it out - I can create a servicecontroller component and issue a stop from there.
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
Hello All,
If i have a tab control with several tab pages, and I drag and drop an item on the tab portion of any of these pages, is there an easy way to get that tab page object from the x y values given to me during the dragdrop event? I fired the ondragdrop event from the tab control because I was not able to get the tab portion of a tab page to fire a drag drop event.
Thanks,
Ryan
|
|
|
|
|
If you mean the actual tab of the tab page using the coordinates, there's really only about one way. You can't get the tab portion directly, but you get the bounding rect for an individual tab. You could wrap it all in a simple method like so (I use Point to make the example code easier, but you can either create a Point from X and Y or pass them in and make a Point ):
private TabPage GetTabPageFromPoint(Point p)
{
p = this.tabControl1.PointToClient(p);
for (int i=0; i<this.tabControl1.TabPages; i++)
{
Rectangle rect = this.tabControl1.GetTabRect(i);
if (rect.Contains(p)) return this.tabControl1.TabPages[i];
}
return null;
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|