Could any one tell how can I open a form with an animation similar to the one used by Mac-OS launcher. I have seen a few other software doing the same thing. For eg: This youtube video also shows a demo of it (#Time: 20 sec and #Time: 28 sec).
I know of animateWindow API, but I think this is not possible with animateWindow.
Any idea on how to do this?
AnimateWindow won't fit the bill.
In my opinion these programs work by
Creating a transparent window when needed, while computing icons to display
Creating the animation and displaying it on the transparent window device context
Handling everything on the window via custom events.
What you need is
a comprehensive knowledge of GDI32
an equally comprehensive knowledge of those dirty tricks used to create animations programmatically.
I'm sorry, but I think that this is not the kind of topic that can briefly explained on a single answer :-(
Eventually, you need something that augments and extends Windows's native graphic capabilities. There are companies that did this before: IIRC Serif.com did write their own GDI replacement for their DTP programs, and I think that all of these companies that make desktop enhancements did the same (or at least, they know how to squeeze GDI32 capabilities)
You could try WPF or SilverLight or mixure of above to meet your requirements.
You can check Good WPF or silverlight windows gadget examples and let me know.
Related
Recently I’ve been working on a windows wallpaper manager. It will scan multiple directories for images and have a settings window to customize. In addition, I want to bypass the built-in wallpaper and instead use a windows form based off the ideas discussed here: Setting a Windows form to be bottommost to allow for greater control over image placement. I have built the file operations to find the wallpapers, and various other support operations.
However, I am stumped on how to implement a windows form properly. Not just the one in the Stack Overflow post above. So far none of my CompSci classes (7 so far) have discussed GUIs, and thus I have no knowledge to work from. I turned to the internet to learn how to work with GUIs. While I learned plenty to start a thread, or show a form, I was never able to find anything that described the proper way to engineer an application with a GUI. All I have learned in respect to engineering the application is to limit the number of threads, and try to separate the GUI from the non-GUI related code (if that makes sense).
Like I have said, I have no clue what I am doing. If someone would be willing to give me pointers or even a link to something on this subject, that would be amazing!
EDIT: I have been using this as a learning exercise, and I have mostly been learning from trial and error, probably mostly error
To draw on the true desktop, you need to get a handle to it: GetDesktopWindow is the function to use. But to change the wallpaper you do not draw on the desktop, but instead you use the dedicated API for handling the desktop wallpaper: SystemParametersInfo(SPI_SETDESKWALLPAPER, ...). There is also the legacy COM Shell interface, IActiveDesktop and IActiveDesktop::SetWallpaper.
As you can see, none of the APIs to manipulate the desktop and the wallpaper are managed (C#, .Net) so you will have to jump through some hoops to get this working from C#. If your goal is to learn C# style UI, I would recommend to stick to the 'blessed' way of doing this (winforms, WPF etc) and do not try to jump straight to p-Invoke and COM interop. Perhaps you can pick another project, eg. display the images/pictures in a carousel in a form.
If you're curious still, Google for C# and SystemParametersInfo or IActiveDesktop and you'll find examples of how to do this from managed C#, many examples right here on StackOverflow.
Bonus: of course Raymond Chen has a blog on this topic: How do I put a different wallpaper on each monitor?.
Is it possible to display an icon in the top left corner of a Windows Form that is a different shape than the standard 16X16 pixel icon?
It appears that Skype has an icon that is much wider than standard:
Is it possible in a Windows Forms app?
You can do this but it's probably more effort than it's worth just to have a larger icon.
Hans has posted an article that roughly points to the information needed to figure out an answer this question, but hasn't posted an answer itself and so I'll clarify.
The old (pre Vista) way to do this is to override the WndProc method on your form and handle the WM_NCPAINT message. Note that this means that you are now responsible for drawing the entire window frame (the window border, title, close / restore icons etc...), not just the icon - i.e. this is a lot of effort to do a relatively minor thing.
The newer (post Vista) way to do this is to use the DWM API - note that this API is not directly exposed through the .Net Framework and so you need to use P/Invoke for this in C#. The bit that you want to do is the section titled "Drawing in the Extended Frame Window", where you extend the area that you are responsible for drawing outside of the normal client area and into the window frame. This is less hassle than it used to be (you don't have to draw things like the close buttons), however still means that you take responsibility for a lot of things that you wouldn't normally, like hit-box testing for resizing and moving.
Basically its nowhere near as simple as providing a larger icon and for most applications its probably way more effort than its worth, however you can do this in C# and that article should get you started if you really want to give it a try.
I know your looking for a plain code way to do this, but I invite you to check out DevExpress manged (yes it's third party forgive me), just google it.. I seen this thread and I started asking questions at devexpress with support and got some impressive results that you might be interested in.
Here is the ticket I put in... http://www.devexpress.com/Support/Center/Issues/ViewIssue.aspx?issueid=Q399941
Here is the result... http://www.devexpress.com/Support/Center/GetSCAttachment.ashx?id=684270b5-faed-415e-9010-64338523f8cf
So Far I used this on Xp, Vista and Windows 7 without problems using winforms only.
I hope this helps or gives you another option if the windows API don't pan out like you want on different versions of windows.
Thanks,
David
Don't think it's an icon, if you mean precisely the ICO image format.
Considering the Skype window is definitely ownerdraw window, that image can potentially be whatever you want format.
The trick is, basically, render an image skipping the pixels of some color (background color) of the "icon", so render it in "transparency".
This article can give you a hint:
Drawing Transparent Images and Shapes using Alpha Blending
It's old, but always a good one.
Yes. Override WndProc and implement WM_NCPAINT.
I need to capture the visual output (like a screenshot) of a DirectX window.
Currently, I use this approach.
But, when the window is in background, it captures whatever is in front of it.
I see that DirectX windows render even when minimized or in background, so this should be possible.
But, how? (It also needs to be fast, and it needs to work on Windows XP too, unfortunately...)
Edit: I am very busy these days... Don't worry, I'll put the bounty back if it expires.
To capture Direct3D windows that are in the background (or moved off screen), I believe you have the following options:
Inject and hook Direct3D within the target application via the link you have already posted or this more up-to-date example (EasyHook can be difficult to get setup but it does work really well) - you can always ask for help about getting it working. I have used that technique for capturing in a number of games without issues (most recently for an ambilight-clone project). The problem with this approach is your concern about game protection causing bans, however FRAPs also uses hooking to achieve this, so perhaps your concerns are exaggerated? I guess gamers being banned for a screen shot is an expensive way of finding out.
For windowed applications on Vista/Win 7 - you could inject and hook the DWM and make your capture requests through its shared surface. I have had this working on Vista, but have not finished getting it working on Windows 7, here is an example of it working for Windows 7 http://www.youtube.com/watch?v=G75WKeXqXkc. The main problem with this approach is the use of undocumented API's which could mean your application breaks without any warning upon a windows patch release - also you would have to redo the technique for each new major Windows flavour. This also does not address your need to capture in Windows XP.
Also within the DWM, there is a thumbnail API. This has limitations depending on what your trying to do. There is some information on this API along with other DWM API's here http://blogs.msdn.com/b/greg_schechter/archive/2006/09/14/753605.aspx
There are other techniques for intercepting the Direct3D calls without using EasyHook, such as substituting the various DLL's with wrappers. You will find various other game hooking/interception techniques here: http://www.gamedeception.net/
Simply bring the Direct3D application to the foreground (which I guess is undesirable in your situation) - this wouldn't work for off-screen windows unless you also move the window.
Unfortunately the only solution for Windows XP that I can think of is intercepting the Direct3D API in some form.
Just a clarification on Direct3D rendering while minimised. During my fairly limited testing on this matter I have found this to be application dependant; it is generally not recommended that rendering take place while the application is minimized (also this reference), it does continue to render while in the background however.
UPDATED: provided additional link to more up-to-date injection example for point 1.
A quick google and i found this Code Project which relates to Windows XP. I dont know if you can apply this knowledge to Windows Vista and 7??
http://www.codeproject.com/Articles/5051/Various-methods-for-capturing-the-screen
EDIT:
I found this article as well:
http://www.codeproject.com/Articles/20651/Capturing-Minimized-Window-A-Kid-s-Trick
This links off from Justins blog post here from the comments. It seems he was working on this with someone (i see thats your link about).
http://spazzarama.com/2009/02/07/screencapture-with-direct3d/
The code that you linked to (from spazzarama), which you said you were using in your project, captures the front buffer of your DirectX device. Have you tried capturing the back buffer instead? Going from the code on your linked site, you would change line 90 from
device.GetFrontBufferData(0, surface);
to
Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
SurfaceLoader.Save("Screenshot.bmp", ImageFileFormat.Bmp, backbuffer);
This would also involve removing lines 96-98 in your linked example. The backbuffer might be generated without the obstructing window.
EDIT
Nevermind all of that. I just realized that your linked sample code is using the window handle to define a region of the screen, and not actually doing anything with the DirectX window. Your sample code won't work around the obstruction because your region is already drawn with the other window in front of it by the time you access it.
Your best bet to salvage the application is probably to bring the DirectX window to the top of the screen before running the code to capture the image. You can use the Wind32API BringWindowToTop function to do that (http://msdn.microsoft.com/en-us/library/ms632673%28VS.85%29.aspx).
I am about to write a front end app, which will be used as a media center app. It will plug directly into a high definition TV. Essentially transforming my laptop into a media player. While this concept is not new, I want custom functionality, so this is why I am not reusing existing products.
I'm a C# developer, so the app should ideally be written in C#. And there is 1 other consideration, I need to accept input via the MCE Remote.
I was considering using Silverlight for this. Would you recommend this? Or any other recommendations for frameworks before I begin planning around this.
Thanks in advance.
This is the type of stuff that the Windows Presentation Foundation was meant for. You'll get a lot more access to the hardware than Silverlight would provide (I.E. that MCE remote you mentioned). You mark up your UI with vector graphics/XAML, and then perform the logic with C#.
EDIT: WPF also has support out of the box for animations which can make your UI a lot more interactive.
EDIT 2: Scott Hanselman has written a really cool application called BabySmash and posted the source online. It basically intercepts keyboard input and shows shapes and sounds on the computer. It's a good "child-proofing" method for your PC. The code could provide you with some insight into WPF and how to do the animations and interactivity that you're looking for.
Is this a desktop app? If so I would use WPF. Silverlight is a subset of WPF, so using WPF you could potentially do more.
Silverlight or WPF, if you want some extra power. Both have a similar programming model (with XAML and code-behind) so you might be able to start with Silverlight and move up to WPF if you need.
The VLC api might be useful for playing your media, someone has created a C# wrapper for it:
http://wiki.videolan.org/.Net_Interface_to_VLC
WPF is certainly the way to go, and for playing media check out the excellent WPF MediaKit: http://wpfmediakit.codeplex.com/ I've used it successfully in many projects.
I'm using WINFORMS not WPF.
I just know basic c# .net gui programming. I donot want the traditional windows look. I want to have my own custom look (eg. gtalk, antivirus softwares, media players, google chrome).
Actually I'm inspired by google's PICASA software. Its awesome. I want to do something like that.How can I do that? If there is something I should learn please point me.
Also I may have to write my own custom controls (like modified tree view etc..) I guess. Please give some good learning resources.
This article describes how to draw custom windows. The author also shows how to draw non-rectangular windows.
If you could use WPF instead of Windows Forms, this is a good article about customizing window drawing:
http://www.codeguru.com/csharp/.net/net_wpf/article.php/c16379/
There is also a question with some good answers here on SO:
Creating custom forms in WPF?
Update:
I think that skinning and custom drawing is fun to do from a programmers perspective, but I also think that there is almost no benefit for the user.
The creators of the platform you are developing for might have put a lot of effort into the design of their windowing toolkits.
If you just want to change some visual aspects of your application you also should take into account that you might miss some important other aspects of UI design:
consistency
accessibility
aesthetics (if you are overdoing
effects, gradients, ...)
internationalization
...
As you are developing for Windows, you also lose the skinning ability of the OS itself. And I think that some of the skins that come with newer versions of Windows are pretty good.
You can try any of the following:
telerik
Syncfusion
(source: componentsource.co.jp)
Or other components.
They do make your UI pretty.
Edit: if you want to study how they do it, you can buy the source code-- along with documentation and understand from there.
There are some commercial control libraries available.
I can recommend the Krypton Suite. It consists of the free Krypton Toolkit (which contains a lot of skinnable controls) and other non-free controls (Navigator, Ribbon, Docking, Workspace). It has some built-in palettes and renderers that allow you to make your UI look like Office 2010, Office 2007, Office 2003, ...
You want to look for +winforms +skinning. I haven't tried these, but the first hits don't look bad. Most decent skinning tools will be paid for.
From what you said, you want to develop your own custom controls. You have some frameworks for this like Qt which can use Direct3D for hardware accelerated graphics. It also have a Visual Studio plugin. There is a free LGPL version and a commercial version of it.
I remembered about Qt because you mentioned Picasa and as far as I remember, I heard the Picasa UI has been written through Qt.
You can try using "SetWindowRgn(..)" to set an arbitrary region for your window. This may range from giving a rounded rectangle shape to giving a weird looking shape to the form!
Check this out: Link.
There is another option if you are working in Vista(aero enabled), ie you can check out DwmExtendFrameIntoClientArea(..) function here: link text
You can set the form's border style to 'none' and go on to create your custom form! You then might have to create custom buttons to carry out tasks like close, minimise, maximise etc. You might even need to write code for drag and drop events..
For the background, you might need to have a look at the gradient fills to give a great effect, otherwise you can use great looking pictures as Background..! But the latter option isnt good unless you have really good pic.