Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
QuestionBinding combo-box to Entity Data Model Pin
pmcm6-Mar-12 4:44
pmcm6-Mar-12 4:44 
AnswerRe: Binding combo-box to Entity Data Model Pin
RobCroll6-Mar-12 10:48
RobCroll6-Mar-12 10:48 
GeneralRe: Binding combo-box to Entity Data Model Pin
pmcm6-Mar-12 22:37
pmcm6-Mar-12 22:37 
QuestionGetting information about a process's handles. Pin
Septimus Hedgehog6-Mar-12 2:09
Septimus Hedgehog6-Mar-12 2:09 
AnswerRe: Getting information about a process's handles. Pin
Eddy Vluggen6-Mar-12 5:20
professionalEddy Vluggen6-Mar-12 5:20 
AnswerRe: Getting information about a process's handles. Pin
Dave Kreskowiak6-Mar-12 5:35
mveDave Kreskowiak6-Mar-12 5:35 
GeneralRe: Getting information about a process's handles. Pin
Septimus Hedgehog6-Mar-12 6:50
Septimus Hedgehog6-Mar-12 6:50 
GeneralRe: Getting information about a process's handles. Pin
Septimus Hedgehog6-Mar-12 23:51
Septimus Hedgehog6-Mar-12 23:51 
If anyone's interested here is what we did, first the issue:

We have an engineering package (off the shelf) that runs fine on XP but under some conditions hangs on 7. We isolated the problem to the open and save dialogs. We wrote an exe containing the open and save dialog controls. That worked fine, but it wasn't modal. After some research, the calling app now shells the exe and passes its window title into it. We get the handle of the form containing the title we're looking for and that gets passed into the open and save dialog controls. This establishes a modal link between caller and called exe. Without this, the exe would be launched fine but if you clicked somewhere else you lose the exe's form (it doesn't appear on the taskbar) and that puzzles the users. What we've achieved works around the 7 problem. As I alluded, it might not be ultra efficient but it works okay for us on 7 so take it or leave it! No, I cannot post the complete code but the following snippets should get you started. Smile | :)

1. Define the api function to get a window title:

[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr zeroOnly, string windowName);

2. Use it to get the handle of a window containing the title you're looking for. Note, IntPtr.Zero forces the search by title alone.

IntPtr ip = FindWindowByCaption(IntPtr.Zero, windowTitle);

3. Define a class deriving from IWin32Window.

internal class WindowWrapper : IWin32Window
{
private readonly IntPtr _hwnd;
public WindowWrapper(IntPtr handle)
{
_hwnd = handle;
}
public IntPtr Handle
{
get {return _hwnd;}
}
}

4. Assign the handle (IntPtr) from 2 above into an instance of WindowWrapper (3).

WindowWrapper ww = new WindowWrapper(ip)

5. Finally, use the wrapper in the constructor of the file dialog to establish a modal link between calling form and the executable.

OpenFileDialog ofd = new OpenFileDialog();
if(ofd.ShowDialog(ww) == DialogResult.Cancel) blah blah blah.

Obviously, you don't need to do this if you're using the dialogs in your own forms but it's a possible get-out-of-jail card if you need to connect disparate processes.
QuestionHow do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 0:07
GParkings6-Mar-12 0:07 
AnswerRe: How do you enforce use of dedicated factories? Pin
BobJanova6-Mar-12 0:40
BobJanova6-Mar-12 0:40 
GeneralRe: How do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 1:01
GParkings6-Mar-12 1:01 
GeneralRe: How do you enforce use of dedicated factories? Pin
BobJanova6-Mar-12 1:58
BobJanova6-Mar-12 1:58 
GeneralRe: How do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 2:30
GParkings6-Mar-12 2:30 
GeneralRe: How do you enforce use of dedicated factories? Pin
jschell6-Mar-12 8:54
jschell6-Mar-12 8:54 
AnswerRe: How do you enforce use of dedicated factories? Pin
Eddy Vluggen6-Mar-12 0:46
professionalEddy Vluggen6-Mar-12 0:46 
GeneralRe: How do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 1:03
GParkings6-Mar-12 1:03 
AnswerRe: How do you enforce use of dedicated factories? Pin
Eddy Vluggen6-Mar-12 5:19
professionalEddy Vluggen6-Mar-12 5:19 
GeneralRe: How do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 5:51
GParkings6-Mar-12 5:51 
GeneralRe: How do you enforce use of dedicated factories? Pin
Eddy Vluggen6-Mar-12 6:55
professionalEddy Vluggen6-Mar-12 6:55 
AnswerRe: How do you enforce use of dedicated factories? Pin
PIEBALDconsult6-Mar-12 2:28
mvePIEBALDconsult6-Mar-12 2:28 
AnswerRe: How do you enforce use of dedicated factories? Pin
SledgeHammer016-Mar-12 6:30
SledgeHammer016-Mar-12 6:30 
GeneralRe: How do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 6:45
GParkings6-Mar-12 6:45 
GeneralRe: How do you enforce use of dedicated factories? Pin
SledgeHammer016-Mar-12 6:56
SledgeHammer016-Mar-12 6:56 
AnswerRe: How do you enforce use of dedicated factories? Pin
jschell6-Mar-12 8:48
jschell6-Mar-12 8:48 
AnswerRe: How do you enforce use of dedicated factories? Pin
jschell6-Mar-12 8:56
jschell6-Mar-12 8:56 

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.