Click here to Skip to main content
15,884,388 members
Home / Discussions / C#
   

C#

 
GeneralRe: issues concerning c# object reference not set to an instance of an object error Pin
Hervend24-Nov-17 4:24
Hervend24-Nov-17 4:24 
GeneralRe: issues concerning c# object reference not set to an instance of an object error Pin
Hervend24-Nov-17 4:35
Hervend24-Nov-17 4:35 
GeneralRe: issues concerning c# object reference not set to an instance of an object error Pin
Eddy Vluggen24-Nov-17 5:15
professionalEddy Vluggen24-Nov-17 5:15 
AnswerRe: issues concerning c# object reference not set to an instance of an object error Pin
OriginalGriff24-Nov-17 3:11
mveOriginalGriff24-Nov-17 3:11 
GeneralRe: issues concerning c# object reference not set to an instance of an object error Pin
Hervend24-Nov-17 4:34
Hervend24-Nov-17 4:34 
GeneralRe: issues concerning c# object reference not set to an instance of an object error Pin
OriginalGriff24-Nov-17 4:50
mveOriginalGriff24-Nov-17 4:50 
QuestionDisable Update of xmlns into Report Viewer C# Pin
rikidev23-Nov-17 23:37
rikidev23-Nov-17 23:37 
QuestionHow to locate a window by title Pin
Leif Simon Goodwin23-Nov-17 20:53
Leif Simon Goodwin23-Nov-17 20:53 
Bit of a long winded question I'm afraid.

I have an app which sends data to an open document displayed by an app such as Word, using a simple paste operation. This requires that I locate the handle of the window associated with the document. The user configures the file location of the application that displays the document, and the file location of the document.

Obtaining the window handle is usually quite easy using something like this:

using (var searcher = new System.Management.ManagementObjectSearcher("SELECT ProcessId, ExecutablePath FROM Win32_Process"))
{
  using (var results = searcher.Get())
  {
    foreach (System.Management.ManagementObject item in results)
    {
      string ExecutablePath = (string)item["ExecutablePath"];
      if (!string.IsNullOrEmpty(ExecutablePath) && (ExecutablePath == _destinationApplication.DestinationApplicationPath))
      {
        int processID = (int)(uint)item["ProcessId"];
        System.Diagnostics.Process process = System.Diagnostics.Process.GetProcessById(processID);

        if ((process != null) && process.MainWindowTitle.Contains(documentTitle))
        {
          return process.MainWindowHandle;
        }
      }
    }
  }
}


Unfortunately Microsoft Word is a pain as one instance manages multiple open documents. Calling GetWindowText() on the main window handle gets the name of one document. Using Spy to look at the window tree for Word shows that none of the child windows store the name of the other document as the window text, even though I can see the name of the document displayed by a window.

So, how do I locate the handle of the window in which the second document is displayed?
AnswerRe: How to locate a window by title Pin
Eddy Vluggen24-Nov-17 2:48
professionalEddy Vluggen24-Nov-17 2:48 
GeneralRe: How to locate a window by title Pin
Leif Simon Goodwin24-Nov-17 3:32
Leif Simon Goodwin24-Nov-17 3:32 
QuestionDelete only the rows that has a particular Column value using C# code Pin
Member 1245769023-Nov-17 14:43
Member 1245769023-Nov-17 14:43 
AnswerRe: Delete only the rows that has a particular Column value using C# code Pin
Eddy Vluggen24-Nov-17 2:46
professionalEddy Vluggen24-Nov-17 2:46 
QuestionHow to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201823-Nov-17 14:29
C Sharp coder 201823-Nov-17 14:29 
AnswerRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 2:44
professionalEddy Vluggen24-Nov-17 2:44 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201824-Nov-17 2:56
C Sharp coder 201824-Nov-17 2:56 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 3:06
professionalEddy Vluggen24-Nov-17 3:06 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201824-Nov-17 3:20
C Sharp coder 201824-Nov-17 3:20 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 3:24
professionalEddy Vluggen24-Nov-17 3:24 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201824-Nov-17 3:39
C Sharp coder 201824-Nov-17 3:39 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 3:42
professionalEddy Vluggen24-Nov-17 3:42 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201824-Nov-17 3:52
C Sharp coder 201824-Nov-17 3:52 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 5:10
professionalEddy Vluggen24-Nov-17 5:10 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201828-Nov-17 17:48
C Sharp coder 201828-Nov-17 17:48 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201828-Nov-17 17:56
C Sharp coder 201828-Nov-17 17:56 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen29-Nov-17 0:27
professionalEddy Vluggen29-Nov-17 0:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.