|
Received in private email (less attachment nogals):
"The attached file is my working project, if u have any time free, could u implement some grab handles in there? I really havent got time to do this, its due tommorrow.
I think i can get the co-ordinate task done.
Miles"
The answer is NO NO NO, do it yourself. If you cant do it, why the hell are you doing IT in the 1st place.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Dear code gurus,
i'm trying to create a non-rectangular window using a bitmap as background image and setting its transparency key. This works fine, however msdn claims that non-rectangular windows wont work on graphics cards currently displaying more than 24-bit colour, which is true.
My question is, how is MS Media Player doing it anyway if my card is displaying 32-bits?
cheers
|
|
|
|
|
Windows Layers. See SetLayeredWindowsAttributes in the Platform SDK at http://msdn.microsoft.com/library[^].
Odd. Both the Form.TransparencyKey and Form.Opacity use Windows Layers (see SetLayeredWindowsAttributes in the Platform SDK at http://msdn.microsoft.com/library[^]) with either the LWA_COLORKEY or LWA_ALPHA flag, respectively. For transparency keys, a COLORREF is used, which is a typedef for a DWORD , a 32-bit unsigned integer. The COLORREF documentation states that the high-order byte must be zero (the normal alpha byte) but as long as it is zero, I don't see why a graphics card in 32-bit mode would cause problems. Perhaps driver problems?
In any case, you can use the old way: window regions. You must override painting (override OnPaint in your form) and set the Graphic.Clip property to a region (use GraphicsPath to create an odd region) that determines which region is valid for painting. Everything else is not painted and, hence, shows what's behind it. This was really the only way to do it before Window Layers, which is only supported in Windows 2000 and higher.
The thing that puzzles me is that Windows Media Player skins use a color mask. Logically, that color would be the transparency color used with Windows Layers. Perhaps they are only using that color to designate a clipped region.
-----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-----
|
|
|
|
|
nibmike wrote:
This works fine, however msdn claims that non-rectangular windows wont work on graphics cards currently displaying more than 24-bit colour, which is true.
Isnt that 24-bit and less? True transparency only works on 32-bit ARGB and indexed palleted formats like GIF.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Folks,
For bizarre reasons, I need to be able to generate random strings that will be matched by a given regex.
i.e. given [a-z][a-z1-9][qrst]
I want an algorithm that will generate
abs
z9q
dvt
et cetera...
Anyone hear of anything similar? Or maybe you know a simple regex parser that I cannibalize?
(C# preferable, or a C related language)
Thanks,
Brett
DTrent
|
|
|
|
|
It's obviously pretty easy to code one for each individual regular expression by hand, but something that generates a random string for ANY given regular expression seems like it would be fairly complicated. I'm pretty sure there's nothing in the base classes for this. It would definitely have to understand the regular expression syntax you're using.
How would you handle something like:
[a-z]*
That means zero to "infinite" lower case letters basically. Would your random generator have an upper limit on cases like that? Would you want zero's to occur more often than other numbers?
I wish I could help more, but I've never heard of anyone doing this (haven't really searched or anything though). Let me know how it turns out.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
I have a simple C# Regex lib designed for a lexer, rather than normal RE. I'll send you the code and if you can use it, i would dearly love to have it Obviously you would be credited (just place a gpl on your source).
Reply to this message so I grab your email
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Thanks,
That might help a lot!
DTrent
|
|
|
|
|
I am using a the Microsft Animation Control to play a status animation and would like to know if there is a .NET version of this control or something like it that someone has made because COM is Butt-Slow.
Or if someone has a better way todo this using anything please tell me.
TIA
|
|
|
|
|
|
FYI, most controls in the .NET Base Class Library (BCL) are just wrappers for the Windows Common Controls or - in some cases (like with the WebBrowser control in .NET 2.0) - are just out-of-the-box COM interop classes. You could try searching CodeProject or google the 'net for examples, but most likely these will just encapsulate native functionality anyway. The beauty of .NET is that you don't have to create everything from scratch.
You might also check out the Managed DirectX class at http://msdn.microsoft.com/directx[^]. Implementing this is non-trivial so be sure to read the documentation. There's also a couple articles here on CP, though the ones I've seen don't deal with animation besides sprites (sequence of static images).
If you need the status animation to play immediately, one alternative might be to instantiate the control and load the animation when the class that uses it is initialized, making sure that the animation is in the stopped state. When you need to show it, make the control visible and start the animation. When finished, stop the animation and hide the control and don't dispose it if you'll need it again. You'll get a faster response this way and the user will see immediately that something is going on. Of course, don't forget to set the wait cursor for further affect (and to stop processing mouse messages) using Cursor.Current = Cursors.WaitCursor . Don't forget to set it to the default again when done. Just my $0.02 to add to the user experience.
-----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-----
|
|
|
|
|
Thanks for the hefty answer, I'll try all that
------------------
I'm naked under my clothes...
|
|
|
|
|
Hi,
I have inherited from the DirectX class to play audio files.
public class MyAudio : Microsoft.DirectX.AudioVideoPlayback.Audio
{
public string MyFile;
public MyAudio(string str) : base(str)
{ }
public MyAudio(string str, bool bln) : base(str, bln)
{ }
}
In my code:
MyAudio newAudio = (MyAudio) MyAudio.FromUrl("http://web.com/46.mp3", false);
When I run this app it gives an error on the above line:
"Specified cast is not valid" !
The declaration of FromUrl func is :
public static Microsoft.DirectX.AudioVideoPlayback.Audio FromUrl ( System.String address , System.Boolean autorun )
How can I fix this problem ? I need to inherit from this class as I want to save the name of the file this object is playing !
Thanks,
Paul
|
|
|
|
|
Why are you trying to cast a reference type of MyAudio to MyAudio.
That is in effect saying "This green cup is green"(Absolutely Pointless).
Or is there some specific reason it needs to be there.
If it doesn't that might be your problem.
|
|
|
|
|
If you see the definition of FromUrl:
public static Microsoft.DirectX.AudioVideoPlayback.Audio FromUrl ( System.String address , System.Boolean autorun )
it returns a Microsoft.DirectX.AudioVideoPlayback.Audio object. So if I don't typecast it to MyAudio, it gives a compilation error.
Paul
|
|
|
|
|
In this function:
public static Microsoft.DirectX.AudioVideoPlayback.Audio FromUrl ( System.String address , System.Boolean autorun )
the signature states it returns an instance of the "Audio" class. You can't convert "Audio" to "MyAudio" because "Audio" doesn't derive from "MyAudio" (the reverse is true). If the function returned a "MyAudio", you could convert it to "Audio", but the other way around would never work.
If I understand what you're trying to do, you should consider creating a constructor for your "MyAudio" class that takes an "Audio" instance as a parameter.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
IMO not providing an external accessible contructor , the class should be sealed, the only option is to encapsulate as .NET doesnt allow you to cast from the base type of a derived class.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Another alternative would be to implement an explicit cast operator in the MyAudio class. See "explicit keyword" in your VS.NET help for details.
Essentially, the CLR will use this explicit cast operator to cast from Audio to MyAudio but in the implementation of the cast operator, you'll have to take care of the details.
[edit]
Nevermind. I forgot and was quickly reminded that casting to/from a base class (or for that matter, casting to/from derived class) isn't allowed and throws a compiler error.
[/edit]
-----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-----
|
|
|
|
|
Sweet...
I've been doing C# for over two years now, and I don't remember seeing that keyword before . I immediately looked up "implicit keyword" and was happy with what I found there as well.
Both implicit and explicit keywords are pretty cool.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Exactly what I mention is not possible at all!
Compiler Error CS0553'conversion routine' : user defined conversion to/from base class
User-defined conversions to values of a base class are not allowed; you do not need such an operator.
The following sample generates CS0553:
namespace x
{
public class ii
{
}
public class a : ii
{
public static implicit operator ii(a aa)
{
return new ii();
}
public static void Main(){}
}
}
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
That error happens in a very few cases, I myself have only bumped into it once. There is NO way around it, unless you encapsulate the class, like a BufferedStream eg.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Can u give an example of what u mean by 'creating a constructor for your "MyAudio" class that takes an "Audio" instance as a parameter.'
How would I specify the file and how would i get the instance of Audio ?
|
|
|
|
|
My original advice isn't necessarily the best way to do it. I think I understand a little better now what you're trying to do.
I'm having a hard time figuring out exactly what you're doing, but I might be able to help a bit.
First, the most important thing for you to realize is why what you tried doesn't work. The FromUrl method is a static function that returns an instance of DirectX's Audio class. This type of function is sometimes called a "factory". It's creating a new instance of the Audio class. It's similar to a constructor, but you're not using the "new" operator to create a new instance. Audio is a base class of MyAudio. So an Audio instance can never be converted to a MyAudio (only the reverse can be done).
Now, from what I can tell, you created the "MyAudio" class to simply store a string that's the original file (is this correct?). Since you're dealing with static factory method's that you still want to use and they're not virtual (so you can't override them), my opinion to you would be don't derive from Audio, but contain an Audio instead. The limitation of this is you can't pass around a MyAudio instance anywhere you normally could pass an Audio instance, but it's still not too hard to make it easy to use. For instance, consider this:
public MyAudio
{
public MyAudio(string url, bool autoPlay)
{
audio = Audio.FromUrl(url, autoPlay);
file = "???";
}
public Audio
{
get
{
return audio;
}
}
private Audio audio;
private string file;
}
Then you could write code like:
MyAudio ma = new MyAudio(url, autoPlay);
and whenever you needed to do something you'd normally do with Audio, you could just call
ma.Audio
and have access to the contained DirectX Audio instance.
Does any of that help?
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
That worked, thankyou so much.
There is some data that I need to save with the MyAudio object. That's why I cannot directly use the Audio object.
Thanks,
Paul
|
|
|
|
|
I have a dataGrid and my reqirements is that i want to add data in the dataGrid form two tables.Both the tables are in the dataset.
How can i display data in the datagrid programatically.I think the
dataGrid.setDataBounding(ds,"Item")
would not work since it binds it to only one table.
Is there unbound method so that i can display data form two table in a single data grid.
Note that i dont want to use the DataRelation obj .
Any Idea.
Thanks
|
|
|
|