|
Hi,
the id parameter in RegisterHotkey must be unique (your _Mod is not good); it is used
internally to discriminate the different hotkeys; I once used the following code:
int chr=(int)name[0];
if (chr>=(int)'a' && chr<=(int)'z') chr+=(int)'A'-(int)'a';
int ident=GetType().GetHashCode()+(modifiers<<16)+chr;
but that is just one attempt to get unique numbers for some command based on its
name (some textual description) and the modifier keys (similar to Control.ModifierKeys)
all inside a form.
|
|
|
|
|
Hi
I am using Visual Studio 2005 and C# to develop a Windows application. I am trying to trigger a keypress or keydown event on the form.
When there are no other controls on the form it works well. Testing with the following:
private void Form1_KeyDown(object sender, KeyEventArgs e)<br />
{<br />
if (e.KeyCode == Keys.C)<br />
{<br />
<br />
}<br />
}
The moment I add another control onto the form, for example a Button, the KeyDown event does not fire anymore.
What am I missing here?
Thanks.
Kobus
|
|
|
|
|
Hi,
part of the GUI job is to dispatch events to the appropriate Control.
If you want your Form to also get keyboard events even when one of its Controls has focus,
look at Form.KeyPreview property.
|
|
|
|
|
Hi!
Is there a way to check a string in all the variations that it can be, i mean that if i will set a string:
string temp_s = "This is the one";
and i will search for "this" and "thiS" then i will get true.
is there a way to configure the string object to do so??
Thanks for your help
|
|
|
|
|
If you are concerned about case, you should change both things you are check to be a certain case. So your code:
temp_s.ToLower() = "this is the one" should always match no matter what the begining case of temp_s is.
Hope that helps.
Ben
|
|
|
|
|
Hi,
as Kubben said, or use String.Compare (String, String, Boolean)
which internally does the same, hence costs more if you must compare one string variable
against several string literals.
|
|
|
|
|
Rotation
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
You forgot to ask a question.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi Guffa I posted the Rotation matrix link of which I wanted to use to rotate a rectangle drawn using the graphics abstract class and wanted to implement that in C# but I dont have a clue how to do it
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi,
all this inside a Form:
declare class members "float angle=0.0f", "int w=300" and "int h=300";
put a Control (say Panel) with size=new Size(2*w, 2*h);
wire a Paint handler for it, which includes:
Graphics g=e.Graphics;
g.TranslateTransform(w,h);
g.RotateTransform(angle);
... now draw whatever you like in the x-range (-w,+w) and y-range (-h,+h)
now add a Forms.Timer that takes care of animantion; in its Tick handler vary angle,
e.g. angle+=10.0f; // add 10 degrees
[Edit: dont forget to also invalidate the panel]
That's all.
-- modified at 5:57 Wednesday 18th July, 2007
|
|
|
|
|
Thanks Luc, I should give it a try tonight, sorry for the late replay as I'm out of my town lately.. Thanks again my friend
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi
What is the possibility to Build my C# Windows application by using another C# application. If so how to do it,
http://www.codeproject.com/csharp/cscompiler.asp[^]
This one says how to comiple few lines of code, the same way i have to excute and create EXE for whole application, by setting up path.
Thanks
|
|
|
|
|
Hello everyone,
I am a developer from C++ COM to C# COM. I feel confused about the entry point function for a C# COM object.
In C++, we always initialize object through GetClassObject or DLLGetClassObject, but it seems C# does not need these functions?
Here is a sample from MSDN.
http://msdn2.microsoft.com/en-us/library/aa645738(VS.71).aspx
So, in C# do we need to implement the required functions like GetClassObject? If no need, which function is the entry point for C# COM object -- I want to find the entry point function so that I can verify that my C# COM object can begin to talk with other COM clients.
thanks in advance,
George
|
|
|
|
|
The framework implements the class factory object itself, inside the COM Callable Wrapper. It also implements DllGetClassObject itself. In fact, if you look at the registry for your object, you will see that your DLL isn't actually recorded in the InprocServer32 key; instead, mscoree.dll is registered. To run your object, COM runs mscoree.dll 's DllGetClassObject function, which in turn loads the appropriate version of the CLR (the highest installed that is listed in supportedRuntime elements in the application's .exe.config file, if present, or if none are present, the highest version installed), then uses the Assembly and Class registry values (with the assistance of Codebase , if present) to locate the assembly containing your class and the appropriate class to load.
If you want to influence construction, you can do so only using the class's static constructor or instance constructor.
Be aware that all public classes with no constructors, or a constructor that takes no arguments, are registered when you use the regasm tool, except where marked [ComVisible(false)] . Consider using the ComVisible attribute at assembly level to hide all types except those you explicitly mark as being visible.
|
|
|
|
|
Thanks Mike,
I have made some practices using regasm and following your comments. C# COM development is really defferent from C++ development from entry point.
I am using MSDN sample COM server,
http://msdn2.microsoft.com/en-us/library/t9yw5271(VS.80).aspx[^]
Then regasm will generate the following statements,
REGEDIT4<br />
<br />
[HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation]<br />
@="CSharpServer.InterfaceImplementation"<br />
<br />
[HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation\CLSID]<br />
@="{C6659361-1625-4746-931C-36014B146679}"<br />
<br />
[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}]<br />
@="CSharpServer.InterfaceImplementation"<br />
<br />
[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32]<br />
@="mscoree.dll"<br />
"ThreadingModel"="Both"<br />
"Class"="CSharpServer.InterfaceImplementation"<br />
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"<br />
"RuntimeVersion"="v2.0.50727"<br />
<br />
[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32\0.0.0.0]<br />
"Class"="CSharpServer.InterfaceImplementation"<br />
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"<br />
"RuntimeVersion"="v2.0.50727"<br />
<br />
[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\ProgId]<br />
@="CSharpServer.InterfaceImplementation"<br />
<br />
[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\Implemented Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]<br />
I find only public class InterfaceImplementation is in the reg file, but public interface IManagedInterface is not in reg file. I think the reason is -- just as you mentioned -- only public public classes with no constructors, or a constructor that takes no arguments are in reg file. Is it correct?
I do not know why regasm only cares about public classes with no constructors, or a constructor that takes no arguments -- why interface is not in reg file?
regards,
George
|
|
|
|
|
Are there any Free Libraries available with C# binding for Playing Audio Video Content? As of now my options are Windows MCI and Direct X which I dont really want to use. Besides being able to play the multimedia content I'd like to have some control on the Audio Stream so that I can modify it (Equalizer Settings).
Thanks...
|
|
|
|
|
.NET 3.0 has capabilities for Audio/Video/3D
.NET 2.0 has capabilities for Audio/Less Video Capability than .NET 3.0
DirectX a video/audio standard for Windows
Windows Media Player ActiveX control has capabilities of both video/audio
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi
I have a problem working with MS Word interop.I create an instance of Word Application and I want to use it as a singleton object ( so I don't have to create another word application as long as a user is working with my application)
But if user opens a word document it will be opened using the word app instance that I've created and when he/she quits the word the word instance is gone thus I have a reference to a rpc server that is not available anymore and if i try to do somthing with it a RPC server is unavalilable exception will be thrown.
How can I check to see if a particular RPC server is still available?
Thanks alot
-- modified at 4:01 Saturday 14th July, 2007
|
|
|
|
|
The only way to check whether a cross-process object still works is to make a call to that object.
I'm not sure if Word offers a way for you to request that it should keep running even if the user closes the last frame window. I actually thought applications were supposed to keep running while there were still outstanding references - ensure you're not calling Marshal.ReleaseComObject anywhere.
|
|
|
|
|
Thank you.
I don't use Marshal.ReleaseComObject and I don't release the app reference that I've got either but It happens.
|
|
|
|
|
hi,
i have to play sound when user enter the mouse on toolstrip button,i have written followin code but it is not working.plzz help me out where is the problem
private void button5_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new SoundPlayer();
b=1
if (a == 1)
{
player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav";
player.Play();
}
}
private void tsbutton_MouseEnter(object sender,EventArgs e)
{
System.Media.SoundPlayer player = new SoundPlayer();
a = 1;
if (b == 1)
{
player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav";
player.Play();
}
}
thanks
-- modified at 4:33 Saturday 14th July, 2007
|
|
|
|
|
<br />
private void tsbutton_MouseEnter(object sender,EventArgs e)<br />
{<br />
System.Media.SoundPlayer player = new SoundPlayer();<br />
a = 1;<br />
if (b == 1)<br />
{<br />
player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav";<br />
player.Play();<br />
}<br />
}<br />
<br />
<br />
In this
<br />
a = 1;<br />
if (b == 1)<br />
{<br />
When your b will become 1 ? Is this is hiccup?
|
|
|
|
|
now plz check this out
private void button5_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new SoundPlayer();
b=1
if (a == 1)
{
player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav";
player.Play();
}
}
private void tsbutton_MouseEnter(object sender,EventArgs e)
{
System.Media.SoundPlayer player = new SoundPlayer();
a = 1;
if (b == 1)
{
player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav";
player.Play();
}
}
|
|
|
|
|
Hi,
some suggestions:
1. have only one SoundPlayer, make it a class member
2. dont use variable names such as a and b, no one understands them (including yourself)
3. have a bool "soundEnabled" which gets set/cleared by button5 and ...
4. have a bool "alreadyPlaying" to prevent multiple concurrent sounds
5. is MouseEnter handler first check soundEnabled, if false, dont do anything;
check alreadyPlaying, if false, set it true and start sound asynchronously
6. biggest problem will be how to clear alreadyPlaying since there is no event for end of
sound. Maybe a Forms.Timer is the way to go.
|
|
|
|
|
Hey,
I want to bring up multiple layout for my windows application. That is same application need have multiple view as same like our IDE, Center of the page we have text editor, bottom side compiler result, right side solution view etc., the same look and feel is possible in C# windows application? I have plyed around lot in VC++, now i would like to get the same in C#.
Can you please help out to me?
Thanks !
|
|
|
|