|
I am creating dynamic tables from the C#.Net CodeBehind page and I need to set the alignment for that table.
How can i achieve?
Regards,
Jai Shankar
|
|
|
|
|
|
Hi,
I am creating a windows application that has a custom treeview/listview windows explorer.
How can I select the corresponding TreeNode of a selected ListView directory?
|
|
|
|
|
This is easy, the property SelectedNode (TreeView) can not only be read but also be written...
treeView1.SelectedNode = treeView1.Nodes[213];
//treeView1.Focus();
|
|
|
|
|
Hi,
I can follow that....but treeView1.Nodes[213] does not belong to the Selected ListView Item.
how can I find the Node that belongs to this ListView Item?
(ProjectTreeView.SelectedNode.FullPath + "\\" + ProjectListView.SelectedItems[0].Text);
|
|
|
|
|
I am creating dynamic tables from the C#.Net CodeBehind page and I need to set the alignment for that table.
How can i achieve?
Regards,
Jai Shankar
|
|
|
|
|
|
Hello *,
I would like to ask on the showing windows.
I am creating toolbar were will be two buttons which will shown gvim and notepad.
C# code is following:
[DllImport("User32")]
private static extern int ShowWindow(int hwnd, int nCmdShow);
private void btnGvim_Click(object sender, EventArgs e)
{
Process[] newProcesses = Process.GetProcesses();
foreach (Process newProcess in newProcesses)
{
if (newProcess.ProcessName.Equals("gvim"))
{
int number1 = (int)newProcess.MainWindowHandle;
ShowWindow(number1, SW_TEST);
}
}
}
private void btnNotepad_Click(object sender, EventArgs e)
{
Process[] newProcesses = Process.GetProcesses();
foreach (Process newProcess in newProcesses)
{
if (newProcess.ProcessName.Equals("notepad"))
{
int number1 = (int)newProcess.MainWindowHandle;
ShowWindow(number1, SW_TEST);
}
}
}
What should be inserted in value SW_TEST?
I would like to simulate behavior of ALT+TAB.
Thanks for your hints.
regards
Petr
|
|
|
|
|
|
Hello,
Here are the three main constants for this Method (you will also find them in the excellent link from Giorgi Dalakishvili, Thanks for that!)
private const int SW_SHOWNORMAL = 1;
private const int SW_SHOWMINIMIZED = 2;
private const int SW_SHOWMAXIMIZED = 3;
Apart from that,
You should use the GetProcessByName method of the Process class instead of iterating over all processes,
and do a
if(newProcess.MainWindowHandle!=IntPtr.Zero)
before pathing the Handle to the method!
And also dispose the returned processes!
Hope it helps!
All the best,
Martin
|
|
|
|
|
What do you mean with the sentence
<br />
And also dispose the returned processes!<br />
What shall I do?
|
|
|
|
|
Hello,
foreach (Process newProcess in newProcesses)<br />
{<br />
newProcess.Dispose();
}
All the best,
Martin
|
|
|
|
|
I rewrote action on the button to this:
Notepad button has the same functionality.
<br />
private void btnGvim_Click(object sender, EventArgs e)<br />
{<br />
Process[] p = Process.GetProcessesByName("gvim");<br />
int number1 = (int)p[0].MainWindowHandle;<br />
if (p[0].MainWindowHandle != IntPtr.Zero)<br />
{<br />
ShowWindow(number1, SW_SHOWNORMAL);<br />
}<br />
p = Process.GetProcessesByName("notepad");<br />
number1 = (int)p[0].MainWindowHandle;<br />
if (p[0].MainWindowHandle != IntPtr.Zero)<br />
{<br />
ShowWindow(number1, SW_SHOWMINIMIZED);<br />
}<br />
}<br />
Unfortunatelly it is not the same or similar behavior as ALT+TAB.
Do you know where I have been made mistake?
regards
Petr
|
|
|
|
|
Hello,
I would do something like this:
private void btnGvim_Click(object sender, EventArgs e)
{
Process[] allProcesses= Process.GetProcessesByName("gvim");
if(allProcesses.Length>0)
{
if (allProcesses[0].MainWindowHandle != IntPtr.Zero)
{
ShowWindow(allProcesses[0].MainWindowHandle, SW_SHOWNORMAL);
}
}
DisposeProcesses(allProcesses);
allProcesses= Process.GetProcessesByName("notepad");
if(allProcesses.Length>0)
{
if (allProcesses[0].MainWindowHandle != IntPtr.Zero)
{
ShowWindow(allProcesses[0].MainWindowHandle, SW_SHOWMINIMIZED);
}
}
DisposeProcesses(allProcesses);
}
public static void DisposeProcesses(Process[] processes)
{
if(processes!=null)
{
if(processes.Length>0)
{
foreach(Process p in processes)
{
p.Dispose();
}
}
}
}
If you later want to get the actual status of a process, look at the "IsIconic" method.
[System.Runtime.InteropServices.DllImport("user32.dll")]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
private static extern bool IsIconic(IntPtr hWnd);
All the best,
Martin
|
|
|
|
|
|
Hello Giorgi,
thanks for the additional information!
All the best,
Martin
|
|
|
|
|
You are welcome
|
|
|
|
|
public delegate int AddDelegate(int a, int b);
Private int AddMe(int a, int b);
AddDelegate add = new Add(AddMe);
Now I can call the AddMe() method by just doing
add(1, 2);
shouldn't i simply call the
AddMe(1,2);
what's the need to use the delegate.
i thnk it is merely a incease in line of code.
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
I guess that's because you didn't bother to read the explanation you got the other times you asked this, nor did you bother to google it. Like many constructs, you can write useless delegate code, and there are times when you can't get by without delegates.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
?????
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Search The F**** Web.
Very similar to JFGI[^]
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Never seen it before, but it's not hard to figure out...
Search The F-ing Webb
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
string message = "Hello world.";
Console.WriteLine(message);
can just as well be written:
Console.WriteLine("Hello world.");
Therefore, variables are useless and only increase the code volume.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
before my environment vs2005 C#.net and make web project now.
while i was mad my code, i need to take some arraylist array.
for example...
defind arraylist array under the partial class
------------------------------------------------
public ArrayList[,] arFood = new ArrayList[4, 2];
and i use my button click event
------------------------------------------------
arFood[iMeal, 0].Add(CommonLib.IsNullString(myListItem.Value));
but while i was compiled source printed out error message.
"System.NullReferenceException" ..
so i was debug trace but myListItem.Value was not empty ..
so my opinion, that's not initialize arraylist array.
how can i initalize my arraylist array? or it's wrong code ?
thanks for read my question...
.. knodark
|
|
|
|