|
Hi,
How can I count the total number of WinWord that is running in my C# application?
Thanks in advance.
|
|
|
|
|
hi see the article of windowhiding
this will get u all open windows then search for (winword) in the windows.Title u will have the count
|
|
|
|
|
yyf wrote:
How can I count the total number of WinWord that is running in my C# application?
The follow will work:
using System.Diagnostics;
Process[] pa = Process.GetProcessesByName("WINWORD");
if(pa != null)
{
int count = pa.Length;
}
- Nick Parker My Blog
|
|
|
|
|
I would just use the tools available in System.Diagnostics.
Example:
System.Diagnostics.Process[] runningProcess = System.Diagnostics.Process.GetProcessesByName("WinWord");<br />
<br />
foreach(System.Diagnostics.Process proc in runningProcess)<br />
Console.WriteLine(proc.Id);
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Thank all of you. This is very helpful!
Here is what I did using Win32API(I import the user32.dll and put it into my Win32API class), but it doesn't work as I except.
public int CheckWord<br />
{<br />
int num;<br />
string lpText = new string((char) 0, 100);<br />
IntPtr hWnd = Win32API.GetWindow(Win32API.GetDesktopWindow(), Win32API.GW_CHILD);<br />
<br />
int UStnNumber = 0;<br />
while ( !hWnd.Equals(IntPtr.Zero) ) <br />
{<br />
num = Win32API.RealGetWindowClass(hWnd, lpText, lpText.Length);<br />
if ( num > 0 ) <br />
{<br />
if ( lpText.Equals("OpusApp") ) <br />
{<br />
UStnNumber ++;<br />
}<br />
}<br />
hWnd = Win32API.GetWindow( hWnd, Win32API.GW_HWNDNEXT );<br />
}<br />
return UStnNumber;<br />
}
Do you know why?
|
|
|
|
|
yyf wrote:
but it doesn't work as I except. Do you know why?
Did you try the code I showed as an example?
- Nick Parker My Blog
|
|
|
|
|
Yes, I did. It works very well. But I just wonder why my way doesn't work.
|
|
|
|
|
I'd like to create a ToolTip in my TreeView that acts just like the ToolTip in Visual Studio Text/Code Editor:
1. Show tooltips for each Node in the TreeView without having to move the mouse out of the TreeView and back in.
2 Show the tool tip until the mouse moves again...
Any ideas ?
|
|
|
|
|
The ToolTip component in the .NET base class can be used if used correctly. Try the following search[^] and find the articles by Nish and ramshri. They suggest one way of doing it.
Since the tool tip control is really just a popup window, you could always create a popup window with no border and perform a lot of the functionality yourself, like resizing it appropriately, etc. For an excellent article that takes this approach for a Balloon Window.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I know that it is possible to view checkboxes at each treenode, but it is possible to hint some of them? For instance my Root-Node should doesn't contain one, but all others.
Any solutions?
|
|
|
|
|
Not with the TreeView in .NET. The Tree-View common control - which is encapsulated by the TreeView control in .NET - doesn't support this either. There are many third-party controls out there like UltraWinTree from http://www.infragistics.com[^], and one from http://www.devexpress.com[^], though I haven't had a chance to use that one yet. We do use the Infragistics control in our application for this and many other reasons because it was far cheaper to use a third-party control rather than spend the time overriding behavior of the existing TreeView or making our own from scratch.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Actually, I just remember something that worked for a ListView (encapsulates the List-View common control) and that there was something similar in the Tree-View. It isn't easy, though, and you should have some experience with Win32 programming.
Using image lists, there is a way to hide a check box for a tree node, though it can be a bit tricky. See the documentation for the TVS_CHECKBOXES style in the Tree-View Windows Styles[^] reference on MSDN Online in the Platform SDK. It provides some basic intructions along with links to more resources. This is more of a trick with an Image List rather than the Tree-View itself.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
it is possible to defined a separated contextmenu for some TreeNodes? Or it is possible to enable a contextmenu for some nodes and for other nodes not? I hope I can do that, how?
Thanks for reply.
|
|
|
|
|
One easy way would be to have a ContextMenu assigned to TreeView.ContextMenu (inherited from Control ). Handle the Popup event and customize your MenuItem s in the handler. Another way - although consuming more memory - would be to have separate ContextMenu instances and not assign anything to TreeView.ContextMenu . Handle the TreeView.MouseDown or TreeView.MouseUp events (whichever you prefer) and call ContextMenu.Show , passing the TreeView as the first parameter and the X and Y coordinates in a Point (from the MouseEventArgs ) as the second parameter to Show . This calls the TrackPopupMenu native function internally.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am trying to call Oracle store procedures from MSSQL via linked server connection.
For every kind of oracle store procedure, I am receiving several error messages coming from oracle OLEDB or ODBC provider telling that there are syntax errors.
I am looking for a solution.
Thanks.
|
|
|
|
|
|
Hiii
i have a combo Box with a list like this
Aman
Anant
Arun
Ajay
Vijay
Vikaas
Now i want whenever i press 'a' the first name starting from a should be selected and if i press an then automatically 'anant' is choosen.
Please help me
Thanx
|
|
|
|
|
Check this article out: C# does Shell, Part 4, especially section 5 on how to inject your own list for the autocomplete.
|
|
|
|
|
|
I'm trying this code, but I get the error :" Object reference not set to an instance of an object".
The code:
// Create new Table Style
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "Employees";
this.dataGrid1.TableStyles.Clear();
this.dataGrid1.TableStyles.Add(ts);
// Assign New Width to DataGrid column
this.dataGrid1.TableStyles["Employees"].GridColumnStyles["EmployeeName"].Width = newwidth;
I set the DataSource for the Datagrid to dataset.Employees on the DataGrid Properties.
Does anyone know what I'm doing wrong or what I could try??
|
|
|
|
|
You actually have to add a new DataGridColumnStyle before you can refer to it. If you step through your code in the debugger, you'll notice that .GridColumnStyles["EmployeeName"] name is null - you never created such a column. You have to create all the DataGridColumnStyle s you want mapped, the DataGridTableStyle , add the columns to the table style's GridColumnStyles collection property, then add the table to the DataGrid 's TableStyles collection property.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have simular code like below
the type object in dr.ItemArray[0] is Int16
but I can not assigne the dr.ItemArray[0] to i (int)
i = dr.ItemArray[0]; throws exception
Is there a method of assigning DataRow fields of number types to integer variables;
To achieve my goal I'm converting the object to string and then back to integer
i = int.Parse(n.ToString());
I think that this can not be the correct way.
Thank you in advance,
Seval YILMAZ
object n;
int i;
foreach (DataRow dr in clGlobal.ds.Tables["login1"].Rows)
{
n = dr.ItemArray[0];
i = int.Parse(n.ToString());
}
|
|
|
|
|
n = Convert.ToInt32(dr[0]);
|
|
|
|
|
How do I disable the child form control box, maximized box and minimized box.
I have codes like
childFrm.ControlBox = false;
childFrm.MaximizeBox = false;
childFrm.MinimizeBox = false;
childFrm.MdiParent = this;
childFrm.Show();
but it will still showing the grayed control box right below the parent control box.
Anyway of totally making it disappear?
thanx in advance
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
It will all disappear with:
childFrm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
|
|
|