|
Throw a simple program together and discover what key data is used:
using System;
using System.Windows.Forms
public class Test : Form
{
static void Main()
{
Application.Run(new Test());
}
protected override void OnKeyDown(KeyEventArgs e)
{
Console.WriteLine(e.KeyValue);
base.OnKeyDown(e);
}
} The left Windows key turns out to be 91, while the right is 92. As I mentioned in the previous post, you can P/Invoke PostMessage and send WM_KEYDOWN (0x0100) to send this key code. See the Platform SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how i use postmessage in c# to turn on|of the windows left key,give me sample code
mughalali
|
|
|
|
|
Hi,
I am trying to lokalize the "Start Up Folder", in which I need to place/delete files. So that a program will start when Windows starts...
I already tried:
System.Environment.SpecialFolder
..But that didnt exist :S ?
Please help me out - Thanks!
- Up The Irons, Morten Kristensen
|
|
|
|
|
It does exist. I'm not sure what you mean by trying to localize it, but all you need to do to get the Startup folder path is:
string path = Environment.GetFolderPath(
Environment.SpecialFolder.Startup); This will not, however, start when Windows boots. The startup folder is only "used" when a user logs into a Windows session. If you want something to happen when Windows itself starts (i.e., before a user logs in), then you need to write a Windows Service. See the documentation for the ServiceBase class in the .NET Framework SDK for more information and an example. This documentation also contains information about installing Windows Services using the ServiceInstaller and ServiceProcessInstaller classes.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank You!
- Up The Irons, Morten Kristensen
|
|
|
|
|
Hello,
I enabled autoscroll on my tabpage.
Is there a way for me to be notified when the tabpage is scrolled? Which event should I be watching out for?
Also, I am using an animated cursor. It works fine everywhere on my form except when I am over the autoscroll scrollbars of my tabpage. Is there a way for me to change that?
Thanx a lot
-Flack
|
|
|
|
|
The scrollbar is a different control so the cursor you set on your control won't be used for the scrollbar.
To know when scrolling occures, extend TabPage with your own control (you can still add these to a TabControl ) and override WndProc like so:
private const int WM_HSCROLL = 0x0114;
private const int WM_VSCROLL = 0x0115;
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_HSCROLL) OnHScroll();
else if (m.Msg == WM_VSCROLL) OnVScroll();
}
protected virtual void OnHScroll()
{
}
protected virtual void OnVScroll()
{
} If you want, add a couple of events that the On* methods fire, and use the Message.WParam and Message.LParam fields to get the relative or absolute positions (which would be handy to pass as EventArgs -derivatives to the event handlers).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanx for the help
Is it possible for me to access the autoscrollbar whenit appears and set its cursor to the one I want?
-Flack
|
|
|
|
|
It's not the "autoscrollbar". It's a normal scroll bar. "Auto" implies a particular behavior. Like any other control, you can encapsulate it and in the .NET 2.0 Framework they will do a better job handling scroll bars. For now, you have to handle all the notification messages using WndProc of the parent control (or using an IMessageFilter for the application, but that can seriously degrade performance if you're not careful). When the mouse moves over the scroll bar control, you can P/Invoke SendMessage to send the WM_SETCURSOR message to the scroll bar. Experience with Windows programming with messages will be very helpful.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Right, I have enabled windows styles on my control. It's taken a bit of time, and it's slightly complicated, but it works.
However, the effects are problematic from the nature of the control, and I can't think of a better way to do it.
Firstly, my control is composed of a number of sub pannels used for mouse over events to detect move and resize actions. This means that for each of those panels I have to run the drawTheme method on their individual device context. And this causes flickering.
I've enabled double buffering, but it's not helping. So i assume that each panel is drawing it's element to the screen.
Is it a speed problem? And is there a way about this?
Secondly.
I have enabled transparency in my theme, but i still can't view the components underneath the corners where the transparency goes straight through to the background image. So i get the corners that are kind of... X-Ray.
Cheers
Cata
Note: the problem with displaying it all came down to the clipping rectangle. If i use anything other than a null pointer, i get nothing.
|
|
|
|
|
The Catalyst wrote:
I've enabled double buffering, but it's not helping. So i assume that each panel is drawing it's element to the screen.
Enabling double buffering isn't enough. You actually have to implement it yourself. Override the Paint event, create an additional Bitmap object to paint to (i.e.; off screen) and then when you are done use the Graphics object to draw your off-screen Bitmap object.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi Nick.
Thanks, but i don't think that's the problem. YOu see my control has 8 panels that are each drawn seperately. I can't draw the bitmap all at once, because each component has a different device context. And this is what is causing the flickering.
Additionaly, i'm drawing using the GDI drawTheme methods. It's drawn straight to screen.
However, If I create a device context on a new, hidden bitmap, and then set the new bitmap to the background image, while enabling transparency on the other components.
Not sure if that's a viable solution.
Any other ideas?
Cata
|
|
|
|
|
i see applications and even Longhorn using more and more of what i would call images with a "washed out" effect (not sure what the real term is for this effect) - like the girl with the video camera in this screen shot from Longhorn. How do you load a "normal" image into a picture box for example, and give it this "washed effect"?
http://www.zolknetwork.com/contentimages/longhorn/screenshots/3683/mypictures.jpg
Thanks!!!
|
|
|
|
|
I'm guessing here, but if you put an image on a white back ground, and set it's transparency level, then you should get the washed out effect.
Cata
|
|
|
|
|
|
that is very helpful - thanks Nick!
|
|
|
|
|
How exactly would i be able to send data to the parallel port with in XP using C#.
Thanks Zane
|
|
|
|
|
You can't do it directly because of the NT Kernel Hardware Abstraction Layer. You need a helper .DLL, running in Ring 0, to get at the port for you and expose an interface you can use. Check out the stuff at Logix4U[^].
RageInTheMachine9532
|
|
|
|
|
Dear zaarzzz
I think that you have to use windows API to do that so you have refeare to CreateFile, API then you can deal with parallel port as a file where you can write and read data
Regards
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Hi,
I have been searching for weeks for a way to put a progress-bar or other custom control on the Office CommandBar of my Outlook addin. Does anyone know how to do this?
Please refer me to any resources available...
Thanks,
Shmarya
|
|
|
|
|
Hiya, how do I write double quotes to a file?? So in the file, it writes "today is fine". I tried this:
sw.Write( ""today is fine"" );
But it like it.
|
|
|
|
|
sw.Write( @"""today is fine""" );
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
|
Also, as with most other languages, use \" . Only use "" within a literal string (i.e., prefixed with the literal string character, @ ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have noticed that when I put code in, lets say a Button click event that when I click it once it will execute the code acouple of times in that click event. Any ideas what might cause that to happen?
Thanks,
JJ
|
|
|
|