|
Sorry, left out a bit of information there: OnStart and OnStop executes when I start and stop the service manually. When I restart the computer OnStart is the only method that executes (when the service is automatically restarted); I expected at least OnShutdown to execute to.
/EnkelIk
|
|
|
|
|
I have a problem with keyboard hooks - every time i press hold the CTRL+SHIFT key for quite some time, my application will crash with the error message :
"An unhandled exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object."
I've searched high and low for a solution to this matter but to no avail. Here's the code that i am using, it is meant to disable keys like ALT+TAB, CTRL+ESC, etc:
protected delegate int LowLevelKeyboardProcDelegate(int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam);
[ DllImport( "user32.dll", EntryPoint="SetWindowsHookExA", CharSet=CharSet.Ansi )]
protected static extern int SetWindowsHookEx(int idHook , LowLevelKeyboardProcDelegate lpfn, int hMod , int dwThreadId);
[ DllImport( "user32.dll")]
protected static extern int CallNextHookEx(int hHook,int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam);
[ DllImport("user32.dll")]
protected static extern int UnhookWindowsHookEx(long hhook);
const int WH_KEYBOARD_LL = 13;
public struct KBDLLHOOKSTRUCT
{
public int vkCode;
int scanCode;
public int flags;
int time;
int dwExtraInfo;
}
protected int intLLKey = 0;
protected int LowLevelKeyboardProc(int nCode,int wParam,ref KBDLLHOOKSTRUCT lParam)
{
bool blnEat = false;
switch (wParam)
{
case 256:
case 257:
case 260:
case 261:
//Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key
if (((lParam.vkCode == 9) && (lParam.flags == 32))
|| ((lParam.vkCode == 27) && (lParam.flags == 32))
|| ((lParam.vkCode == 27) && (lParam.flags == 0))
|| ((lParam.vkCode == 91) && (lParam.flags == 1))
|| ((lParam.vkCode == 92) && (lParam.flags == 1))
|| ((true) && (lParam.flags == 32)))
{
blnEat = true;
}
break;
}
if (blnEat)
return 1;
else
{
return CallNextHookEx(0, nCode, wParam, ref lParam);
}
}
public void KeyboardHook()
{
intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, new LowLevelKeyboardProcDelegate(LowLevelKeyboardProc), System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]).ToInt32(),0);
}
|
|
|
|
|
Sir
i write a code in C#
char myChar='/u0634';
Console.WriteLine("Unicode Character is {0}",myChar);
but it not give the actual character of that unicode.
what's the problem pls any tell me.
Thanks in Advance.
|
|
|
|
|
Hi!
Console automaticaly convert string to OEM encoding and then type it in console window...
that is why not all unicode charecters can be converted and shown in console window.
try to do the same on WindowForm...
Good Luck
Alex Kucherenko
|
|
|
|
|
I have two ListViews, DataGrids whatever, and they both contain data from 2 seperate datasets. I'd like to have a scrollbar on one view that when scrolled would automatically adjust the other view so they both stay in sync. Both datasets would contain the same number of rows. Can this be done with C#.NET?
Fairly easily?
Any help/sample code would be greatly appriciated!
Thanks
|
|
|
|
|
C#, at least I think, is alot better than vc++6 since everything is soo easy to use and soo powerful.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
So, you're saying that VB is better than C++?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
I'm not saying that since I myself is a c++ proggrammer. It's just that it is said that C# combines the power of c++ with the ease of vb, though I know that C# has some issues, I think that this will probably erase mfc and visual c++ 6 though it will be alive, it won't be the preffered language anymore, just wait a couple of years and you'll see how it will progress.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Snyp wrote:
I think that this will probably erase mfc and visual c++ 6 though it will be alive, it won't be the preffered language anymore, just wait a couple of years and you'll see how it will progress.
It will do progress, but will not erase C++, ever!
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
GRR... I didn't say that it will KILL C++, I said that it won't be the preferred language...;)
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Whatever, dude!
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Ya ok
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Hi ,
I am trying to add a WindowsMediaPlayer Control in my app so that the user can play the audio file from my app page ! I have added the ref to WMPLib.dll.
My code is as follows:
AxWMPLib.AxWindowsMediaPlayer newMedia = new AxWMPLib.AxWindowsMediaPlayer();
ResourceManager resources = new ResourceManager(typeof(testControl));
newMedia.OcxState = ((AxHost.State)(resources.GetObject("newMedia.OcxState")));
newMedia.Enabled = true;
newMedia.Location = new Point(tX, tY);
newMedia.Name = tName;
newMedia.Size = new Size(tW, tH);
thisPanel.Controls.Add(newMedia);
if (tDefault != null) newMedia.URL = tDefault;
newMedia.URL = @"c:\myfile.mp3";
The last line newMedia.URL = @"c:\myfile.mp3" results in InvalidActiveXStateException. I know the filename is correct as I can play it from Explorer.
Any suggestions !?!
Thanks,
Paul
|
|
|
|
|
In ASP (Code behind module) I'm tring to so a simple assignment of a dropdownlist value to an int but it can't convert the string to int. So how would I cast this?
<br />
dgResult.PageSize = ddlPageResults.SelectedValue;<br />
I tried (INT) but that's C++ I couln't do the ToInt32 either it didn't look like. I know this is super simple but I couln't find an aswer.
|
|
|
|
|
Try converting the string to int with the Int32.Parse() method.
|
|
|
|
|
Hi,
you can try:
<br />
try {<br />
int MyInt = Convert.ToInt32(MyString);
}<br />
catch(Exception ex)<br />
{<br />
}<br />
Good Luck !
Braulio
|
|
|
|
|
I have Data in a typed DataSet and a Form to Edit it.
First Time I edit the Data with the form everything works fine. But if I want to reedit the Data, as I first changes something by the form everything freezes, means that I can't change data in any Control on the form. Even the OK, Cancel Buttons doesn't work anymore. I have to exit by the Close Button of the Form.
Any Ideas?
|
|
|
|
|
hi,Does anyone know how to spread text over columns in a listview in c#?
THIS is EASY IN C++ .you ONLY have TO SET the SetItemData Method of the CListCtrl to 0.
IF you WANT text TO BE DISPLAYED IN COLUMNS SET SetItemData to 1.
example:
m_ListCtrl.SetItemData(0,0); //this lines makes text spread over columns
m_ListCtrl.SetItemData(0,1); //text to be displayed column by column
how can this be accomplished in c#?
thanks
|
|
|
|
|
I personally haven't worked with ListView controls in C#, but I did a quick search in MSDN and found a property called "Tag" in the ListViewItem class which may serve your purpose.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Has anybody determined how to set the cursor to a wait cursor during a long operation where Application.DoEvents() is being called (and thus allowing .NET to reset the cursor to that set for the control the cursor is currently over).
The only solution I have found is to set the current cursor of every control to the wait cursor, but what a pain.
Thanks - Joel
VssConnect - Remote SourceSafe(r) Access http://www.voxcode.com[^]
|
|
|
|
|
Hi.
i have a few checkboxes on my form and i want to show a simple messagebox when one of those checkboxes are checked. how can i do this dynamically?
for instance, instead of writing an if statement per checkbox, like this:
if(checkbox1.checked = true)<br />
{<br />
MessageBox.Show("checked");<br />
}
write it dynamically, like this:
(the <selected checkbox=""> is the name of the selected checkbox)
if(<selected checkbox>.checked = true)<br />
{<br />
MessageBox.Show("checked");<br />
}
i know this is pretty easy for all you guru friends out there.
Thanks,
.gonad.
|
|
|
|
|
I'm not sure if I understand you, but you can maybe use first parameter of your event handler method (sender). You have to set same function as event handler for all checkboxes.
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
CheckBox checked=(CheckBox)sender;
}
i'm only pointer to myself
|
|
|
|
|
Hi.
Thanks for your help. this worked exactly as you said, but i do have a queston.
Can you explain what the
(CheckBox)sender
is specifying? also, can i use this for a textbox, or other controls, as well? for example,
TextBox tb = (TextBox)sender;
I'm new at this stuff, can't you tell?
Thanks again.
.gonad.
|
|
|
|
|
First parameter (sender ) of event handler is affected object.
it is passed as object so you need to cast it to correct type (Button / CheckBox etc..).
So when you have event handler for Button, sender is button user clicked on. If you have event handler for TextBox, sender is this TextBox.
i'm only pointer to myself
|
|
|
|
|
I create tables called "Employers", "Employees". One employer can have many Employees, but one employee can have only one employer.
In my code: I create EmployerClass
{
public Long EmployerID;
public EmployeeCollections Employees;
....
}
I want the EmployeeCollections can have a group of employees order by last name and first name. I can access it like Employees[i](int i) or Employees[name](string name = lastname+" "+firstname).
Can anyone please tell me how to do that?
Thanks in advance!
|
|
|
|