|
Martin
I believe that the reference should look like this:
[DllImport("user32.dll")]
public static extern int GetKeyboardLayoutList(int nBuff, ref int lpList);
Then, in your code, you would work with it like this:
int[] layouts = new int[1];
int length = GetKeyboardLayoutList(0, ref layouts[0]);
layouts = new int[length];
GetKeyboardLayoutList(layouts.Length, ref layouts[0]);
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello Pete,
It works!!!!
Thanks a lot.
Actually I made the mistake to define it as an array.
like this:
[DllImport("user32.dll")]
public static extern int GetKeyboardLayoutList(int nBuff, ref int[] lpList);
int[] layouts = new int[1];
int length = GetKeyboardLayoutList(0, ref layouts);
layouts = new int[length];
GetKeyboardLayoutList(layouts.Length, ref layouts);
This was strange because the first call of GetKeyboardLayoutList returned the write value (Lenght of 3).
But the second call, brought back a lenght of 1 with a value 0.
But with your help everything is fine now. (And it was not the first time of corse!)
So thank you very much again.
All the best,
Martin
|
|
|
|
|
When you create .NET UI objects on the fly, how do you handle the events that come to them?
Lets say that in code, I create any number of new buttons and put them on my form. How do I code a handler for the click event on those buttons? I won't know their names until they exist (Button1, Button2, Button3, etc), and I can't just have a huge list of
private void Button1(), private void button()
handlers sitting around in my code.
So, how do I code a handler for Button[x]? I'm sure there is something basic I'm missing here.
Thanks,
Joe
PS. I posted a much more specific version of this question in the .NET framework forum, before I realized that I had a much more general lack of understanding here.
|
|
|
|
|
In continuation with my answer in the .Net Framework forum
You could create a single event
Private void Button_Click(object sender, System.EventArgs e)
For each of the buttons you can assign the event handler as
Button1.Click += new System.EventHandler(Button_Click);<br />
Button2.Click += new System.EventHandler(Button_Click);<br />
Button3.Click += new System.EventHandler(Button_Click);<br />
.<br />
.<br />
ButtonN.Click += new System.EventHandler(Button_Click);
Based on the sender you can define what needs to be executed inside the Button_Click Event
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
|
|
|
|
|
Please see the following link:-
http://www.codeproject.com/useritems/DynamicServerControls.asp
It will help you.
Amit
|
|
|
|
|
Thanks everybody, for the fast and educated responses. I think I'm on my way.
Why is it that .NET, since it implemented a
toolstripmenuitem_DropDownItemClicked event, didn't also provide a
toolstripmenuitem_DropDownItemCheckedStateChanged ? This would have made this process much easier. I realize that not every DropDownItem will support CheckedStateChanged, but even giving me a general
toolstripmenuitem_DropDownItemTheresBeenAnEvent event, and telling me which event in the args, would have been better than nothing...
Thanks again! I'll be back... now that I know where you guys are.
|
|
|
|
|
Hi i am look for a Transparent control with Magnifier functionality just like a windows Magnifier component .i mean how i can make magnifying glass in c#.Net
thanks
-- modified at 4:45 Thursday 21st December, 2006
|
|
|
|
|
Hi All,
Its urgent
I am creating a word template Addinn. I am using "Word Template" project for that. My problem is how can create the set up for "Word Template" project. If any body knows then please help me.
Thanks in advance.
Amit
|
|
|
|
|
Hi,
can any body please help me regarding changing the fonts of any custom string placed any where in the custom control.
Thanks in advance,
regards.
|
|
|
|
|
You can place a string in a control. Either you assign the string to the Text or Caption property of the control, or of a Label that you add as a child control. To set the font of the text displayed, you change the Font property of the control where you put the string.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
hi,
can any body provide me with some help regarding the addition of a horizontal seperator in the context menu for .NET 1.1.
thanks in advance,
regards.
|
|
|
|
|
In the context menu designer, put a hyphen (-) in as the caption. This will be displayed as a separator.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello frenz,
In my application, I need to recreate & save an xml file frequently in a thread.
I use the Save() of the XmlDocument class to do this.
But at times, when I try to save the file, I get an WIn32IOError exception saying that the file is being used by another process..
Is it possible to check whether the file is being used by another program before saving?
If it is being used by another process, I need my application to wait until the resource is released to rewrite it.
Advance thanks for the help.
|
|
|
|
|
Try this..
File.GetLastAccessTime(@"C:\time.txt"); It will give last access time of the given file. If it is say within some given time limit, you can check it and then wait using Thread.Sleep().. and then continue..
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
u can use this logic as well
DateTime StartTime = DateTime.Now;<br />
while(true)<br />
{<br />
try<br />
{<br />
}<br />
catch<br />
{<br />
if(StartTime.AddSeconds(timeouttime) > DateTime.Now)<br />
{<br />
break;<br />
}<br />
System.Threading.Thread.Sleep(sleeptime);<br />
continue;<br />
}<br />
break;<br />
}
Regards
Shajeel
|
|
|
|
|
|
Hi all
Any good book about Xml Begenner
SAS
|
|
|
|
|
Xml for C#, or are you in the wrong forum ? What do you need to know ? Have you read the w3 schools site, or done a general google ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
... A 100KB file in a 1-dimensional array, byte by byte?
|
|
|
|
|
There should be no problem at all
Luc Pattyn
|
|
|
|
|
Why do it byte by byte? There is a method that creates the array for you and reads the file into it. Check out the File.ReadAllBytes method.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
I have a form that picks a color and then returns it to the main form. it is then supposed to fade to that color. I have tried using a loop and have tried:
Form1 ReplacementForm = new Form1();
ReplacementForm.Opacity = 0;
ReplacementForm.splitContainer1.BackColor = Properties.Settings.Default.BackGroundColor;
...
ReplacementForm.splitContainer1.Panel2.BackColor = Properties.Settings.Default.BackGroundColor;
ReplacementForm.Opacity = .5;
Thread.Sleep(50);
ReplacementForm.Opacity = .10;
Thread.Sleep(50);
ReplacementForm.Opacity = .15;
Thread.Sleep(50);
...
ReplacementForm.Opacity = .90;
Thread.Sleep(50);
ReplacementForm.Opacity = .95;
Thread.Sleep(50);
ReplacementForm.Opacity = 1;
Thread.Sleep(50);
splitContainer1.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer2.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer3.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer4.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer1.Panel1.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer1.Panel2.BackColor = Properties.Settings.Default.BackGroundColor;
ReplacementForm.Close();
Neither have worked. Why? what do i have to do to get it to fade from one color to the other? I don't care if it doesn't literally fade colors, as long as it looks like it does.
Thanks in advance.
|
|
|
|
|
Thread.Sleep should always be a last resort. Instead, work out a smooth path from the old color to the new, and set the color incrementally using a timer.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
You had asked the same question some time back. Did you try the suggestions given by the users? Link[^]
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
|
|
|
|
|
Oops. I'm sorry. I have short-term memory loss.
|
|
|
|