|
I am working on a project in which I have to Log Off the locked computer. I use SessionSwitch to listen the windows locked event, and I used ExitWindows(0,0) to Log Off.
But this API function is not working on the Locked computer.
Another stratagy is to first unlock the computer and then use ExitWindows(0,0) to Log Off.But unfortunatly I am unable to Unlock the windows. Kindly help me to solve my problem.
|
|
|
|
|
I m using a status bar in the form.
In one of the panels of the status bar, I just want set the status of the CAPSLOCK & NUMLOCK, the same way it can be done in VB. But in VB the panel properties has different display value, so it was easy.
How this can be achieved in C#???
Thanks in advance...
Regards
SG (sgg245@yahoo.co.in)
|
|
|
|
|
The properties Console.CapsLock and Console.NumberLock provide the necessary information.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks so much. Its working.
But stil a prob.
This is when the application start it detects if the CAPSLOCK is ON then I can display certain msg or so...
But I want whenever CAPSLOCK button is pressed then it should update the status of the panel in the status bar.
If CAPSLOCK is ON then status bar panel should show ON.
If CAPSLOCK is toggled i.e. OFF then status bar panel should show OFF.
Something like this...
Thanks in Advance...;) ;)
Regards
SG (sgg245@yahoo.co.in)
|
|
|
|
|
Hi,
there are at least two ways to keep your status bar up-to-date:
1. on your form, set KeyPreview true; then add an event handler for KeyDown;
the handler now will fire for every key moving down; in the handler check for Keys.CapsLock;
if it is, use Keyboard.CapsLock and update the status bar; don't try to count the toggles
yourself !
2. on your form, add a Windows.Forms.Timer and let it fire say every second;
in its Tick handler read Keyboard.CapsLock and update status bar.
The choice is yours, it depends a bit on which of those handlers you may already have
for some other reason.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks very much.
I anticipated something like we used to do in VB status bar panels...
Anyways, again thanks for ur help... so kind of u...
Regards
SG (sgg245@yahoo.co.in)
|
|
|
|
|
You're welcome.
Come to think of it, I would prefer the timer approach; with key events, if your app
looses focus, capslock gets toggles, app gets focus back, you will not know about the
change (unless you add code to some other events too, such as Activate).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hello
Im writing a Word application that shall be used on machines with Office 2003 or later versions. On the developer machine I have Office 2007.
Im having trouble creating the application so that it works on the test PC witch is using Office 2003. Can anybody help me with a solution on how to use a assembly from Office 2003 in my project... C#
Thanx
Spaz
|
|
|
|
|
Hi
.Net framework itself provided you with Word library (In reference COM Tab you can see Microsoft Word Object Library) this should help out you to work around Word applications.
Thanks
|
|
|
|
|
Thanks for the reply
The Word Library only contain version 12, witch is Office 2007. If I compile my application with that library and deploy it on a machine with Office 2003 I get this error:
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
So I need a way to compile my application with Microsoft.Office.Interop.Word, Version=11.0.0.0
Thanx
Spaz
|
|
|
|
|
OK., when you add the reference into your project you will see some DLLs like
WORD
VBIDE
MICROSOFT.Office.Core
While you create setup you need add that library as part your setup and there you will see one DLL called MSO.DDL go to the properties and in Register Property select "vsdrfCOM" and build your setup.
This you no need to have any MS Office at your deployment PC. Please let me know if you havve any hiccup.
Thanks
Siva
|
|
|
|
|
Hello
Thanx for the help, im a bit in the blue here...
I did what you sad, importet the reference, created a new setup project. Changed the setting under register property to "vsdrfCOM". But when I try to run it on the deplyment PC I get this error:
"Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))"
Any ide what could be wrong?
Thanx
Spaz
|
|
|
|
|
Hi All,
i m trying to take a printout using msExcel a printer is Dmp i want to set the page size width = 3 inches length= 10 inches i had code
<br />
ExlWorkSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlPortrait;<br />
ExlWorkSheet.PageSetup.PaperSize = Excel.XlPaperSize.xlPaperEnvelope9;
where ExlWorkSheet is object of Excel Worksheet.
please suggest me something to produce the right output
Nikesh Kr. Yadav
CSS Infotech
Sec- 31
Gurgaon,
Haryana(India)
|
|
|
|
|
Is it possible to set a network adapter to promiscuous mode within a C# application?
Will this also work with WiFi?
Regards
dotman1
|
|
|
|
|
For specifying a file type we use Response.ContentType in a webapplication.
But it wont work on a windows application..What we shoul use instead??
|
|
|
|
|
Response is a object of ASP.Net, you cannot use that in window application. If you want to open some document use shell command
cheers
asithangae
|
|
|
|
|
Hello,
This will be a pretty long message so please bear with me, and thank you in advance for your help.
For the DataGridView , we needed to disable the ToolTip of the cells for all the columns EXCEPT for one column. And we wanted the ToolTip for that specific column to always show (and not hide after a certain amount of time).
My understanding is that the ToolTip of the DataGridView cannot be exposed, and therefore we had to do a work around. What we did was to create a class that extends the ToolTip and also a class that extends the DataGridView . The new tooltip class, named ManualToolTip , is then instantiated in our extended DataGridView class. (Note: there are other reasons for extending the DataGridView, but extending the ToolTip was done solely for this purpose.) Now, doing this created a lot of problems, I will not copy paste some code snippets and the error that we are getting.
ManualToolTip.cs
using System;<br />
using System.ComponentModel;<br />
using System.Drawing;<br />
using System.Windows.Forms;<br />
<br />
namespace UIControls<br />
{<br />
public class ManualControlToolTip : ToolTip<br />
{<br />
private bool _toolTipDisplayed = false;<br />
private Timer _toolTipTimer = new Timer();<br />
private Control _control;<br />
private Point _mousePoint = new Point();<br />
private string _toolTipText = string.Empty;<br />
private bool _hideOnMouseMove = true;<br />
private int _movePixelThreshold = 3;<br />
private bool _useTimer = true;<br />
<br />
public ManualControlToolTip()<br />
: base()<br />
{<br />
Init();<br />
}<br />
<br />
public ManualControlToolTip(IContainer container)<br />
: base(container)<br />
{<br />
Init();<br />
}<br />
<br />
private void Init()<br />
{<br />
this.StopTimer();<br />
<br />
_toolTipTimer.Interval = this.InitialDelay;<br />
_toolTipTimer.Tick += new EventHandler(ToolTipTimer_Pop);<br />
}<br />
<br />
public void StartTimers()<br />
{<br />
_toolTipTimer.Start();<br />
_useTimer = true;<br />
}<br />
<br />
public void StopTimers()<br />
{<br />
_toolTipTimer.Stop();<br />
_useTimer = false;<br />
}<br />
<br />
[DefaultValue(true)]<br />
public bool HideOnMouseMove<br />
{<br />
get { return _hideOnMouseMove; }<br />
set { _hideOnMouseMove = value; }<br />
}<br />
<br />
[DefaultValue(3)]<br />
public int MovePixelThreshold<br />
{<br />
get { return _movePixelThreshold; }<br />
set { _movePixelThreshold = value; }<br />
}<br />
<br />
[DefaultValue(null)]<br />
public Control Control<br />
{<br />
get { return _control; }<br />
set<br />
{<br />
if (_control != null)<br />
{<br />
if (_control is DataGridView)<br />
{<br />
DataGridView grid = (DataGridView)_control;<br />
<br />
grid.CellMouseEnter -= new DataGridViewCellEventHandler(grid_CellMouseEnter);<br />
grid.CellMouseLeave -= new DataGridViewCellEventHandler(grid_CellMouseLeave);<br />
}<br />
else<br />
{<br />
_control.MouseEnter -= new EventHandler(_control_MouseEnter);<br />
_control.MouseLeave -= new EventHandler(_control_MouseLeave);<br />
_control.MouseMove -= new MouseEventHandler(_control_MouseMove);<br />
}<br />
}<br />
<br />
_control = value;<br />
<br />
if (_control is DataGridView)<br />
{<br />
DataGridView grid = (DataGridView) _control;<br />
<br />
grid.CellMouseEnter += new DataGridViewCellEventHandler(grid_CellMouseEnter);<br />
grid.CellMouseLeave += new DataGridViewCellEventHandler(grid_CellMouseLeave);<br />
}<br />
else<br />
{<br />
_control.MouseEnter += new EventHandler(_control_MouseEnter);<br />
_control.MouseLeave += new EventHandler(_control_MouseLeave);<br />
_control.MouseMove += new MouseEventHandler(_control_MouseMove);<br />
}<br />
}<br />
}<br />
<br />
private void grid_CellMouseLeave(object sender, DataGridViewCellEventArgs e)<br />
{<br />
HideToolTip();<br />
_toolTipTimer.Stop();<br />
}<br />
<br />
private void grid_CellMouseEnter(object sender, DataGridViewCellEventArgs e)<br />
{<br />
DataGridView grid = sender as DataGridView;<br />
<br />
if (grid != null && e.RowIndex != -1)<br />
{<br />
DataGridViewCell cell = grid.Rows[e.RowIndex].Cells[e.ColumnIndex];<br />
ToolTipText = cell.ToolTipText;<br />
}<br />
_toolTipTimer.Start();<br />
}<br />
<br />
[DefaultValue("")]<br />
public string ToolTipText<br />
{<br />
get { return _toolTipText; }<br />
set { _toolTipText = value; }<br />
}<br />
<br />
private void _control_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
HandleMouseMove(e.Location);<br />
}<br />
<br />
private void HandleMouseMove(Point location)<br />
{<br />
int pixelMovements = Math.Abs(_mousePoint.X - location.X) +<br />
Math.Abs(_mousePoint.Y - location.Y);<br />
if (pixelMovements >= MovePixelThreshold)<br />
{<br />
if (HideOnMouseMove &&<br />
_toolTipDisplayed &&<br />
!_mousePoint.Equals(location))<br />
{<br />
HideToolTip();<br />
}<br />
else if (_useTimer)<br />
{<br />
_toolTipTimer.Stop();<br />
_toolTipTimer.Start();<br />
}<br />
}<br />
}<br />
<br />
public bool IsDisplayed<br />
{<br />
get { return _toolTipDisplayed; }<br />
}<br />
<br />
private void _control_MouseLeave(object sender, EventArgs e)<br />
{<br />
HideToolTip();<br />
_toolTipTimer.Stop();<br />
}<br />
<br />
private void _control_MouseEnter(object sender, EventArgs e)<br />
{<br />
_toolTipTimer.Start();<br />
}<br />
<br />
private void ToolTipTimer_Pop(object sender, EventArgs e)<br />
{<br />
if (_toolTipDisplayed)<br />
{<br />
HideToolTip();<br />
}<br />
else<br />
{<br />
ShowToolTip();<br />
}<br />
}<br />
<br />
public void ShowToolTip()<br />
{<br />
if ( Control != null && !Control.Disposing )<br />
{<br />
this.Show(ToolTipText, Control,<br />
Control.PointToClient(new Point(Cursor.Position.X + Cursor.Current.Size.Width, Cursor.Position.Y)),<br />
Int32.MaxValue);<br />
_toolTipDisplayed = true;<br />
_mousePoint = Control.PointToClient(Cursor.Position);<br />
<br />
if (_useTimer)<br />
{<br />
_toolTipTimer.Stop();<br />
_toolTipTimer.Interval = this.AutoPopDelay;<br />
_toolTipTimer.Start();<br />
}<br />
}<br />
}<br />
<br />
public void HideToolTip()<br />
{<br />
if ( Control != null && !Control.Disposing )<br />
{<br />
this.Hide(Control);<br />
_toolTipDisplayed = false;<br />
<br />
if (_useTimer)<br />
{<br />
_toolTipTimer.Stop();<br />
_toolTipTimer.Interval = this.ReshowDelay;<br />
_toolTipTimer.Start();<br />
}<br />
}<br />
}<br />
}<br />
}
Error Message 1:
See the end of this message for details on invoking <br />
just-in-time (JIT) debugging instead of this dialog box.<br />
<br />
************** Exception Text **************<br />
System.ObjectDisposedException: Cannot access a disposed object.<br />
Object name: 'ViewSolutionForm'.<br />
at System.Windows.Forms.Control.CreateHandle()<br />
at System.Windows.Forms.Form.CreateHandle()<br />
at System.Windows.Forms.Control.get_Handle()<br />
at System.Windows.Forms.ToolTip.get_CreateParams()<br />
at System.Windows.Forms.ToolTip.CreateHandle()<br />
at System.Windows.Forms.ToolTip.Hide(IWin32Window win)<br />
at UiControls.ManualControlToolTip.HideToolTip()<br />
at UiControls.ManualControlToolTip.ToolTipTimer_Pop(Object sender, EventArgs e)<br />
at System.Windows.Forms.Timer.OnTick(EventArgs e)<br />
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)<br />
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Error Message 2:
See the end of this message for details on invoking <br />
just-in-time (JIT) debugging instead of this dialog box.<br />
<br />
************** Exception Text **************<br />
System.NullReferenceException: Object reference not set to an instance of an object.<br />
at UiControls.ManualControlToolTip.ShowToolTip()<br />
at System.Windows.Forms.Timer.OnTick(EventArgs e)<br />
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)<br />
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
My guess is that I am not understanding the ToolTip correctly. It could be that it is creating and disposing differently than I thought. Could it be that a separate ToolTip instance is created per cell in the table? And does it Dispose when you do a Hide? Well, I'm really just guessing. I need help! Or, at the very least, direction.
Thanks in advance!
Rafferty
-- modified at 10:18 Wednesday 8th August, 2007
|
|
|
|
|
Help anyone?
|
|
|
|
|
i just started to use c#..
how can i do division using for loop or while loop?
i should,,
output dividend and divisor:
input answer:
input dividend:
input divisor:
quotient:
remainder:
im confused...sorry..
-- modified at 4:32 Wednesday 8th August, 2007
|
|
|
|
|
do You need this?
<br />
<br />
int[] Divide(int divisor, int dividend)<br />
{<br />
int remainder = dividend;<br />
int quotient = 0;<br />
<br />
while (remainder >= divisor)<br />
{<br />
remainder -= divisor;<br />
quotient++;<br />
}<br />
<br />
return new int[] { quotient, remainder };<br />
}<br />
<br />
|
|
|
|
|
how can i insert the numbers i want to be the dividend and divisor?
|
|
|
|
|
what do you mean insert the numbers?
you are writing base on Console or Windows ?
here is just a hint because I don't know what you are doing!!!
for Console
use Convert.ToInt32(Console.ReadLine());
and I suggest you to get a C# book!
|
|
|
|
|
console... okay... thanks for your time and effort...
|
|
|
|
|
thankyou Hessam Jalali...
|
|
|
|
|
you should ask your teacher if you have trouble with the homework
|
|
|
|