|
|
I'm afraid I still have the problem. I thought that the problem had been solved as clicking on the button caused the key commands to work. In actuality clicking the button was bringing the focus to the form. Here is the code with no button which loses focus.
public WMP(string filename)
{
InitializeComponent();
this.axWMP.KeyPressEvent += new AxWMPLib._WMPOCXEvents_KeyPressEventHandler(this.axWMP_KeyPressEvent);
fname = filename;
axWMP.settings.autoStart = false;
axWMP.URL = fname;
axWMP.Ctlcontrols.play();
axWMP.Focus();
}
private void axWMP_KeyPressEvent(object sender, AxWMPLib._WMPOCXEvents_KeyPressEvent e)
{
label1.Text = "key press = " + e.nKeyAscii.ToString();
}
|
|
|
|
|
I see what you want now, and no, the .Focus() won't do the trick.
My question is whether you are trying to capture keystrokes in a generic manner and then pass on the relevant ones to the child form?
The issues may lie with where the focus lies. The keypress arguments are going to be sent from whichever control has the focus, not the form itself, so you won't see the event using the hooks you have. What you need to do is capture the keypress event from whichever control happens to have the focus on the active form and then pass the keystroke event down to the sub form for it to use it. If you tell me which version of Studio you're using, I can package up a sample I just made to demonstrate this and send it to you. You can email me that at [edited out now that you've gotten it], if you like.
modified on Thursday, October 14, 2010 8:50 PM
|
|
|
|
|
If I click on the form all works as it should. I am writing a mediaplayer that functions from a IRremote so I dont want to have to click on the form with a mouse in order to read the key commands.
|
|
|
|
|
PogoboyMtK wrote: You can email me that at
If you want to do that again, there is an Email button at the bottom of your message which means you don't have to expose your email address to Googles' page cache at all.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Thanks. It's ok though, because I expose my "utility" email address and not my primary one.
|
|
|
|
|
Handling the problem by e-mail keeps other interested parties from seeing the solution to a problem. If it is too much for a forum post, you might consider writing a tip&trick or even an article about it.
|
|
|
|
|
Your right. I finally found the answer to the problem. The child form was not the problem. In the parent form I had done this:
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
Form2 dlg = new Form2(fname);
dlg.ShowDialog();
For some reason this causes Form2 to be inactive I know not why.
|
|
|
|
|
The main form represents the entire app (when it closes, the app exits). I'm surprised the dialog was even showing, if you had minimized the main form later on, the dialog would have disappeared too (try right-clicking minimize on the task bar on any app).
BTW: these special things you just showed should have been mentioned earlier...
Cheers.
|
|
|
|
|
Agreed. I didn't even think to ask that yesterday.
|
|
|
|
|
Hey Luc,
Rather than span the forum with numerous posts along the way, the idea was to figure out what was wrong and then post that, not the entire process of getting there.
Cheers
|
|
|
|
|
Have you considered using the ProcessCmdKey overload or event ??? instead of keypress event
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
Hello everybody,
I don't know if here is the right section, if not, please change.
I need some support with this questions.
I will present here my problem:
Suppose I want a software to give to someone to encrypt text, and to encrypt the program should use the privatekey ( that only I know, but the program will need to encrypt data, so it must be hidden there) and to decrypt it should use the public key, that I can give to anyone.
So, now:
I have a private key and a public key, generated by open ssl: privatekey.pem and publickey.pem
Now, I need to be able to use those keys to encrypt and decrypt data.
the thing is, how I load the .pem to the program?
As I readed I need to load it to rsaparameters, but how I do it?
The type of the keys are:
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKB...
and
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBA...
Any help would be very usefull, since I'm having a lot of troubles making it.
|
|
|
|
|
|
Alegria_Lee Thanks a lot!
I will study this example today, and try to solve my problem. But this seams really helpfull.
I'll post here if I get it working or not. If you dont mind, stay checking here.
|
|
|
|
|
Ok, It helped me a lot. Now I'm able to use my own private/public keys. Without any problem
Now, the thing is:
I need to encrypt the data using the private key.
And I need to decrypt it using the public key.
But RSA dont let me... I can encrypt with the private key, but them, I cant decript with the public one.
modified on Friday, October 15, 2010 9:46 AM
|
|
|
|
|
I'm glad it's helpfull for you.
Actually,I haven't used this before.
|
|
|
|
|
well, but is good and is working
thank you a lot.
|
|
|
|
|
You're welcome.
By the way,Have you find out a solution to solved your problem ?(" encrypt with private key and decrypt with public key ")
AS i know,RSA can not seem to do so .
|
|
|
|
|
yes, is not possible.
But I noticed that what I wanted it could be made with the method: signdata
It signs data with private key and unsign with public key =)
|
|
|
|
|
Hello!
I have a problem with getting the pixels from an image. I load a image, select a pixel from the image and retrieve it's color and then i generate a matrix indexMatrix[bitmap_height][bitmap_width] which contains 1 or 0 depending if the [x,y] color of the bitmap is the same as the color selected. The problem is that the program doesn't select all the pixels although it should. Here are some images of the bitmap and the bitmap generated from the matrix :
original:
http://img233.imageshack.us/i/hartap.jpg/
after matrix generation and the transform from the matrix to the new image
http://img826.imageshack.us/i/60079199.jpg
The wierd thing is that if i run my program for the new image ( the one constructed from the matrix ) it returns the same image( as it should ) but i can't figure out how to fix the problem.
Please Help!!!
Regards,
Alex Badescu
and some code from my project :
bitmap declaration:
m_Bitmap = (Bitmap)Bitmap.FromFile(openFileDialog.FileName, false);
Here i calculate the matrix:
int bitmapWidth = m_Bitmap.Width;
int bitmapHeight = m_Bitmap.Height;
indexMatrix = new int[bitmapHeight][];
if (imageIsLoaded && colorIsSelected)
{
for (int i = 0; i < bitmapHeight; i++)
{
indexMatrix[i] = new int[bitmapWidth];
for (int j = 0; j < bitmapWidth; j++)
{
Color temp = m_Bitmap.GetPixel(j, i);
if (temp == selectedColor)
indexMatrix[i][j] = 1;
else indexMatrix[i][j] = 0;
}
}
MessageBox.Show("matrix generated succesfully");
}
matrixIsCalculated = true;
}
|
|
|
|
|
Try using Color.ToArgb() method for the comparisons. ie,
if(temp.ToArgb() == selectedColor.ToArgb())<br /> The equality operator uses some state flags for the comparison in addition to the ARGB values.
|
|
|
|
|
|
I'm afraid there is a fundamental flaw in your approach: JPEG images tend to be highly compressed, which means every pixel is approximated in such a way that fewer bits are required. Applying an equal-test on jpegged images does not make much sense. What you should do is allow for some deviation, say:
deviation=deltaRed*deltaRed+deltaGreen*deltaGreen+deltaBlue*deltaBlue
or similar in another color space (e.g. HSB).
Only when the deviation is large enough you should call the pixel "not blue".
BTW: why don't you use a normal 2D matrix, as in int[bitmapWidth, bitmapHeight]?
|
|
|
|
|
I have custom windows user control. It is just a textbox puted on a panel. And panel is on User control. The panel OnPaint is overriden.
Everything looks fine except when some form comes on the control or menu open on it and I move or close the above form, the user control looks does not refresh completely extra lines from closed form remain on the panel. Should I call Invalidate() or Refresh() from specific event of user control?
Thanks
Mazy
"This chancy chancy chancy world."
|
|
|
|