|
|
--alright, the code below worked fine for a DirectX fullscreen app if I put ...SetForeGroundWindow(FindWindow("windowName"))...--
Hello all, I'm looking for a way to set the focus back to the last window that had it. For example I'm running a fullscreen app and I've got myForm always on top (topMost = true). But the window in the background shall have the focus back after I clicked once into myForm.
What I've already got is:
[DllImport("user32.dll")]
extern static Boolean SetForegroundWindow(IntPtr windowName);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
extern static IntPtr SetActiveWindow(IntPtr windowName);
private void btnDebugFocus_Click(object sender, EventArgs e)
{
String window =" aspecificname"; SetActiveWindow(FindWindow(window)); SetForegroundWindow(FindWindow(window));
}
First, how do I figure out a windows' name? (Edit: not needed as I know the name) - If I put the windows' name I want to have the focus instead of "aspecificname" I get a runtime error as soon as the method is run.
The name of the window I want to have focus will always remain the same. Maybe somebody could help out,
Cheers
Dennis
modified 3-Dec-12 8:50am.
|
|
|
|
|
Hi,
I'm having some issues with reading an AD directory,
Each time i request the directory from AD i get the following catastrophic failure
Later in the program i'm using a impersonation class.
When i disable this the code works otherwise it returns the catastrophic failure.
string OU = "DC=medewerkers,DC=ad,DC=hvu,DC=nl";
DirectoryEntry dirEntry = new DirectoryEntry("LDAP://" + OU);
DirectorySearcher dirSearcher = new DirectorySearcher(dirEntry);
dirSearcher.SearchScope = SearchScope.Subtree;
dirSearcher.Filter = "mail=" + user;
dirSearcher.PropertiesToLoad.Add("profilePath");
SearchResult sResult = dirSearcher.FindOne();
This is my impersonation, when i disable this my code works but only for local users.
using (new Impersonator(txtGebruiker.Text, txtDomein.Text, txtPw.Text))
{
string profile = GetProfilePath(txtProfiel.Text);
Directory.Move(@"C:\Test", @"C:\Test.old");
txtLog.Text = "Profiel locatie\n" + profile + "is omgezet naar .old ";
}
Any help / suggestions or hints on what i did wrong are
appriciated.
Thanks in advance
|
|
|
|
|
WHAT "catastrophic failure"?? A copy of the exception message would be nice if you wanted any help with this.
|
|
|
|
|
It is a little tough to read the code because it seems there is a big chunk missing. However, when I ran into this once before, the account that I was impersonating with had to have to ability to read the section of the Active Directory I was trying to get information from. In my case, I was originally trying to use a local service account, which won't work, because it does not have rights on AD. I had to create a service account in AD, give it read permissions (and deny lots of other stuff) then use it.
As I recall there are some API calls you can make to test if these protected calls are available to your application... basically testing if you have the proper rights. That might give you a graceful way to handle the situation.
|
|
|
|
|
As you suggested i'm going to start testing with a service account.
I've also created a function that now reads the Directory i'm requesting,
wich no longer results in the catastrophic failure,
Seems that was the problem tough now i get nullreference error.
But i'm moving in the right direction.
The impersanation does not work however, but i'm working on it.
One step forward to steps back
Thanks for the suggestion
|
|
|
|
|
I think this is not the right place to post this issue here. else, please help me to fix this issue
The issue is:
I'm using smtp4dev to send email alerts from TFS. I'm using Windows VIsta. In TFS administration Console->Email Alert Settings, I set SMTP server as localhost and Email from Address is my mail id. In Visual Studio 2010, Team->Project Alerts, I enabled "Anything is checked in" and gave another email id in Send to field. After my checkins, I didn't receive any email. smtp4Dev is visible in system tray.
In Event Viewer, I found the below Error,
TF53010: The following error has occurred in a Team Foundation component or extension: Date (UTC): 12/3/2012 6:07:33 AM Machine: MACHINE112 Application Domain: TfsJobAgent.exe Assembly: Microsoft.TeamFoundation.Framework.Server, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a; v2.0.50727 Service Host: Process Details: Process Name: TFSJobAgent Process Id: 2804 Thread Id: 6996 Account name: NT AUTHORITY\LOCAL SERVICE
Detailed Message: TF271001: An error occurred while attempting to send an e-mail notification to the following address: yyyy@example.com. Further e-mail notification errors that occur within the next five minutes might not be logged. Verify that the e-mail notification settings are correct in the Team Foundation Administration Console. Exception Message: Failure sending mail. (type SmtpException)
|
|
|
|
|
This has nothing to do with C#; try the Quick Answers forum[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
|
If you think this isn't the right place, why post here? Try Q and A instead.
|
|
|
|
|
how can we attach our system to the wifi connection?
|
|
|
|
|
I have no idea what your question means. Could you please explain exactly what it id that you are trying to achieve and what you currently have in place?
|
|
|
|
|
The PhysicalAddress class[^] might help you.
|
|
|
|
|
I'm checking this articlehttp://blogs.msdn.com/b/eric_carter/archive/2004/12/01/writing-user-defined-functions-for-excel-in-net.aspx?Redirected=true[^]
I create a simply UDF of the article. In 32bit system, it is all right. In a 64bit, a simply function works only if I directly insert argument in the function. If I link the argument to a cell it doesn't work. Apparently it doesn't recognized that the number coming from excel cell (64bit) is a correct double for my function (which accept double)
Any idea?
Later note: really my Excel 2010 it is 32bit too.
So: the same project:
on windows xp, excel 2010 32bit, single processor works
on windows 7, excel 2010 32bit, 4 processors : excel udf works only if I directly use numbers in formulas, but it doesn't works if my UDF arguments refers to cells containing nmbers
Later note:
I found the same problem here http://social.msdn.microsoft.com/Forums/en-SG/exceldev/thread/8168c603-a7c8-4c01-98d2-3c0385294325[^]
it is more clear: from "Wolfgang"
"
I also used Eric's blog to create an automation add-in: http://blogs.msdn.com/b/eric_carter/archive/2004/12/01/writing-user-defined-functions-for-excel-in-net.aspx.
"
I created this Automation add-in with Office 2010, Visual Studio 2010 and .NET Framework 4.0 on Windows 7 (it should be the same configuration as Bessie's). But it does not work for me. I get #VALUE! as error. As soon as I replace the call "=MultiplyNTimes(B1,B2,C2)" with "=MultiplyNTimes(VALUE(B1),VALUE(B2),VALUE(C2))" it works.
I created this add-in with Office 2003, Visual Studio 2010 and .NET Framework 4.0 on Windows XP and it worked ("=MultiplyNTimes(B1,B2,C2)")
Does anybody has an idea what's the problem?
"
modified 2-Dec-12 17:19pm.
|
|
|
|
|
Sorry no help but the whole issues justifies my stand NEVER to use Office products in a solution to a clients problems. Office is a great productivity tool, IT IS NOT A DEVELOPMENT PLATFORM.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: NEVER to use Office products in a solution to a clients problems. Sage advice.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
I'm working on an application of which requires me to have one list-box to hold data.
I'm having a little issue when deleting an object from a list-box. The issue comes into play when I fill the list-box with items from TWO separate lists.
Normally to delete the object I would get it's index and then remove it from the list in a separate class then reload the list-box to reflect the changes but in certain instances I need to fill the list-box with objects from two different lists and determining the origin of the object to delete from one of the two lists, well I'm not entirely sure how to do this.
this code is populating the list-box control.
ViewListBox.Items.Clear();
List listOfPickups = visits.listPickups();
List listOfdeliveries = visits.listDeliveries();
ViewListBox.Items.AddRange(listOfPickups.ToArray());
ViewListBox.Items.AddRange(listOfdeliveries.ToArray());
this is how i delete when i am only loading the listbox from one list.
if (ViewListBox.SelectedIndex < 0)
{
EditSelectBtn.Enabled = false;
DeleteSelectBtn.Enabled = false;
}
else
{
if (MessageBox.Show("are you sure you want to delete the selected item?", "Are You Sure?", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
visits.removePickup(this.ViewListBox.SelectedIndex);
updateList("pickups");
}
else
{
ViewListBox.ClearSelected();
}
}
Any help would be greatly appretiated.
modified 11-Mar-21 21:01pm.
|
|
|
|
|
I don't work with winforms anymore but I believe there will be a tag property on the listboxitem, I would put an identifier in there. OR add a hidden column (width = 0) with the identifier.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If the list box doesn't sort (so always displays the items from the first list first and items from the second list below that), the easiest solution would be to compare the index to delete with the size of the first list. If the index is too large, just subtract firstList.Count to get the index to remove from the second list.
|
|
|
|
|
Thank you i tried this and it works perfectly!
modified 11-Mar-21 21:01pm.
|
|
|
|
|
hi men
I have a listView called lw1.
When I use lw1.selectedItem, I can check which item is selected.
But, how I can know which item is alone highlighted by mouse cursor?
note:http://dl.dropbox.com/u/45898865/Immagine.jpg[^]
in picture 1
gimppoi is selected with one click of mouse cursor
in picture 2
gimppoi is selected with one click of mouse cursor
poweooooooooo has alone mouse cursor over the line
modified 3-Dec-12 16:01pm.
|
|
|
|
|
Some grids (not sure about listviews) allow you to select the item on mouseover. Otherwise you need to handle the mouseover event, use hittest to identify the record and decide what to do with it!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
good idea
I had tried it yesterday without success.
private void buttonGV_Click(object sender, RoutedEventArgs e)
{
Attivita attivita = null;
for (int i = 0; i < listViewAttivita.Items.Count; i++ )
if ( listViewAttivita.IsMouseOver )
attivita = listViewAttivita.Items[i] as Attivita;
if ( listViewAttivita.IsMouseOver )
this test is needless, because I want know which row is selected. That test told me if the mouse is over one of all ListView rows.
Can you tell me what I should search to understand which row has the mouse over?
this is the XAML part. Does it help?
<ListView ItemsSource= "{Binding AttivitaCollection, UpdateSourceTrigger=PropertyChanged}" Height="206" HorizontalAlignment="Left" Margin="12,33,0,0" Name="listViewAttivita" VerticalAlignment="Top" Width="auto" SelectionChanged="listViewAttivita_SelectionChanged">
<ListView.Resources>
<med:ImageConverter x:Key="imageConverter"/>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Header="Azioni registrate" Width="150" DisplayMemberBinding="{Binding nome, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<GridViewColumn Header="Stato" Width="auto" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Width="24" Name="buttonGV" Click="buttonGV_Click" Height="24" Background="Transparent" BorderBrush="Transparent">
<Image Source="{Binding Path=imgStato, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource imageConverter}}" />
</Button>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
|
|
|
|
|
I would post this in the WPF/Silverlight forum, there are some guys there who have a very deep knowledge. At a guess you probably need a trigger on the listview servicing the mouseover event.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I would like to ask which way you prefer t store variable which could be available for read/write? do you prefer to store in App.Config or Windows Registry is still best to use?
Thanks,
Jassim[^]
Technology News @ www.JassimRahma.com
|
|
|
|