Hosting VisualStudio on a Winform and start it minimized - c#

I'm trying to embed visual studio as a user control (to enable the user editing a generated source file). Basically most details can be found in a nice CodeProject entry Hosting EXE Applications in a WinForm project.
What bothers me is that after launching VS as a new process it takes some time before it settles down on the form. During this period I'd like it to be hidden, so I tried:
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
Also tried to turn on "CreateNoWindow" of ProcessStrartInfo with no successes.
(As a side question, I'm using process.WaitForInputIdle() to wait for VS before capturing its window handle, but on some machines the calls just returns immediatly).
Any clues? other suggestions? thanx in advance.
Robi

If you just want your user to be able to edit a source file inside your app, I'd recommend using a text edit control with syntax highlighting instead of embedding Visual Studio in your project. One option is ICSharpCode.TextEditor.
You can find more info about it in this CodeProject article.

Related

What is Repeater Tasks process?

I was working on a ASP.NET web forms project and was trying to attach a data source to a repeater using wizard. My Visual Studio window suddenly hanged for some seconds and during that time I saw a popup minimized window:
.
Can someone please tell me what it is? And why its showing default icon of Windows Forms? Is it some internal process of Visual Studio?
It seems to be a background task that Visual Studio uses to Scaffold your code to ensure that the dots are connected when creating a data source.
The gist is that it runs through your code, checks objects for links to your data source, and sets up the settings you've added in the wizard.

Changing a buttons icon in with the visual studio SDK

I am using the Visual Studio SDK to add in some additional functionality to visual studio.
I have a button that when pressed will perform a potentially long running task (maybe 10-15 seconds) and I would like to change the button Icon to include some indication that the task is being performed, and then again change the icon to show that the task has been completed.
Reading through the MSDN articles has shown me how to customise my icon, but I am having trouble figuring out how to change it at run time. The MSDN article configures its icons in an xml config file.
Essentially my question is how do I control the button icon in code? I have provided the link to the MSDN article that I have been using below
http://msdn.microsoft.com/en-us/library/bb165158.aspx
Thanks in advance
James
It is not a good idea (it's non standard, you can use a progress dialog or the status bar of VS instead), but if you really want you can try the following approach:
1) Get the CommandBar that has the button
2) Get the CommandBarControl in the CommandBar.Controls collection
3) Cast the CommandBarControl to CommandBarButton
4) Use the CommandBarButton.Picture and CommandBarButton.Mask properties. See section #2 of my article:
HOWTO: Creating custom pictures for Visual Studio .NET add-ins commands, buttons and toolwindows.

Custom search tab in Windows start menu search with C#

I am interested to know how can I do the same thing that the apllication listed below does:
Start Menu Calculator
I want to know how can I create an custom tab in Start Menu Search and then handle it with my WPF application. It should only be enabled until my application is running.( Just like what The calculator does )
I read something about windows API Code Pack and I downloaded it but I don't know how can I use it. I searched through it but I didn't find anything.( If you know how I could do this using with Windows API Code Pack, please write an example that explains how to do it in C#)
The main exe "Start Menu Calculator.exe" installs a windows hook (using SetWindowsHookEx) into explorer.exe. The hook is implemented as usual in SBLib.dll which is then injected into Windows Explorer's memory space.
This hook searches for window handles belonging to the search box. See a discussion around this here:
How do I get a "handle" on the Windows Search textbox? and probably sub classes the search box windows (if you kill the "Start Menu Calculator.exe" process abruptly, it crashes Windows Explorer too... which kinda confirms this)
It then reacts to key presses, and I suppose it butchers up the result window. In the hierarchies of Windows, I think it's a Window named "Desktop Search Open View", you can get to it with SPY++ under "Start Menu", aside the windows mentioned in the msdn forum above.
So, no nice API behind this nice application. Massive hacks instead :-)
I think however, some level of integration is possible, using documented behavior, with the search box. I have not dug further, but there is the notion of federated search in Windows (Windows 7 Federated Search). I don't see if this would be capable of reacting instantaneously to what the user types in though...
As a side note, if you're also looking for a way to run javascript code from C#, there is a question here on SO that says it all: parse and execute JS by C#
When making Start Menu Calculator I initially tried to use federated search and Managed (.NET) code however you can't integrate into the start menu, only the shell search (for web service based search which lets you return custom results based on a search string). The problem is that the federated search is structured such that all the search data is pre-indexed so for the calculator to work I would have had to pre index every possible calculation! The reason it all works this way is to make sure that clicking the start menu is always fast and responsive (you don't want a web service call everytime you press start in the shell).
I ended up hiring someone to write a native windows app that places a IE control into the Start menu search area and passes the searched text in with the source. All the visual stuff is just css made to look like the start menu rendering and the calculations handled in javascript.
So yes, a bit of a hack but it seems to work and I havent had/heard of any crashing issues so far.

How can i add a button to all windows explorer instances?

I am trying to add a button to one of the existing tool bars in any windows explorer instance.
After much research i figured out that BHO (browser helper objects) are the best way to hook
to windows explorer.
My question is :
Is that the correct way to go about it ?
In the SetSite of the BHO i get the comObject that is the explorer window. What now ?
If i can get the hWnd of the explorer window can i use win API to add my button ?
Note i am developing in C# for XP.
Thanks.
1 In pre-XP you can add custom items in the default folder template because the folder window is actually a webpage. In XP and later that is no longer true. A Deskband is the supported way to extend the UI.
2 The site is the same. You can even sink DWebBrowserEvents2 to get notified when the folder view is ready.
3 using window functions on explorer is not supported. The supported way to customize the explorer is to create deskbands. it is theoretically possible if you have the resource to test your code against each and every version of Windows Explorer used by your client audience and continue to do compatibility testing when each new version (or new language) of explorer.exe is released.
BHO can not add deskband. If you want to start BHO and deskband programming, look at Paul DiLascia's article "My Band is Your Band" in the November 1999 issue of MSJ. There is another article "Building Browser Helper Objects with Visual Studio 2005" in MSDN for BHO. Basically you need to handle the DocumentComplete and BeforeNavigate events and be careful not to access the folder view when the document is not ready. You can use any communication method that you see fit between your BHO and your deskband, such as hidden window with special window class, static variable if the two are in the same dll, shared memory, named pipe, etc.
Microsoft does not support creating In-Process extensions in managed code until .Net 4.0

How do you display a message in web forms using .cs code in visual studio 2008?

In visual studio 2005, we can get message.show() to display the message.I required the method in visual studio 2008.
I don't believe that there is any change in the code from VS2005 to VS2008.
But accordnig to the title of your question ("diplay a message in web forms"), I assume that you are using ASP.NET (if you meant win forms, RichardOD has already answered your question).
You should use javascript function
alert('This is my message.');
to show the message.
Check this article - it contains a great implementation that you can use right as a MessageBox in winforms.
if it is webform, you could use
Response.Write("Your Message")
Method.. if you want the message box, you could use javascript
alert('your message')
if it is windows forms, use
Messagebox.Show("your message")
hope this helps u
This hasn't changed in 2008. Are you sure you mean Web forms, it sounds more like you mean Windows Forms- see here: http://msdn.microsoft.com/en-us/library/system.windows.forms.messagebox.show.aspx
If you need further help please elaborate your question.
You probably mean MessageBox.Show(). MessageBox is a class in the System.Windows.Forms namespace; this class contains the Show method which when called, should draw a window on a screen. Now this is all different with web! Web is not a one machine application like your windows form, web is a client/server architecture, where there are two major parts of your application: the server where you deploy your code, and the client (the browser responsible for rendering the output of your code). I will not digg in much details for now, I strongly recommend that you learn about the web and its Client/Server architecture first. Thanks

Categories

Resources