I saw that Windows 7 Wizard has the title bar extended without requiring Aero Glass. Look at this:
I made my application to work with Aero Glass, but how about withiut it?
Thanks in advance!
I haven't test this yet, but I think it will work, mark it as answer if you agree:
[DllImport("uxtheme")]
static extern int DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, ref RECT pClipRect);
This method works, loog at this
You shouldn't need to do anything. The DWM is still running when using the Basic theme, it's just not doing any accelerated rendering.
Related
first time writing a question here, this site helped me a lot thru the years, thanks !
DwmGetWindowAttribute doesn't return exact rectangle where the window is and its's size using this code :
[DllImport("User32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("dwmapi.dll")]
public static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, out RECT pvAttribute, int cbAttribute);
Intptr m_current_active_window_handle = GetForegroundWindow();
DwmGetWindowAttribute(m_current_active_window_handle, DwmWindowAttribute.DWMWA_EXTENDED_FRAME_BOUNDS, out RECT __rv, Marshal.SizeOf(typeof(RECT)));
I want to get capture of active/foreground window at specific occasions and I tested on 2 different versions of windows and still not working with my setup..
Dual 1440p monitors (both 100% scaling)
Windows 10 Enteprise LTSC 2019
Windows 10 Pro (19042)
I have disabled animations during minimizie/maximize, dropshadow under windows
here is what I get and sometimes it returns me window with 2 extra pixels on top and non on the other 3 sides which have black border..
ps. ignore white region around the window, it is purposely there to show extra stuff around 'window':
You know when you right-click the desktop and there's a "Sort by" option that allows you to sort the icons by "Name", "Size", "Item Type", or "Date Modified"? Well, I want to find a way to sort the desktop's icons with a push of a button.
I saw a similar question being asked here on stackoverflow but it's old and the code didn't work for me. The link to the question is: Arranging desktop icons with C# . I'm trying to achieve this in Windows 10.
There was a comment on there that said that the LVM_* and LVA_* values are stored in the commctrl.h file which comes with the SDK. I couldn't find that file for some reason.
Here's what i'm using:
//sort desktop
public const int LVM_ARRANGE = 4118;
public const int LVM_ALIGNLEFT = 1;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
//end of sort desktop
private void organizeBtn_Click(object sender, EventArgs e)
{
var DesktopHandle = GetDesktopWindow();
MessageBox.Show(GetDesktopWindow().ToString());
SendMessage(GetDesktopWindow(), LVM_ARRANGE, LVM_ALIGNLEFT, 0);
}
I've been digging for info or some sort of direction about this topic, especially regarding windows 10, but I can't find much. Please help?
In Windows 10, the desktop (not tile world!) is still a SysListView32, but the GetDesktopWindow API call will return the handle of its grandparent, a Progman window - reminiscence of the ancient "Program Manager" of Windows 3.0. Then there is a shim of the SHELLDLL_DefView class, and below that you find buried the listview you're after.
Use the information from this answer to move down from the shell window to the folder view, which you can eventually send the LVM_ARRANGE message.
This is a brittle approach, as it relies on undocumented properties of the operating system, which may change at any time with updates or new versions. It will probably break also when a user uses a slideshow as desktop background, because Windows then rearranges the desktop window stack. Hack to deal with this here.
Another approach which is documented and less likely to break in future versions, with the downside of involving COM and a nightmare from C#, is via the IFolderView of shell automation, two relevant finds here and here.
Hi all am creating an message application but as soon as the app snatch a picture from my webcam it starts showing a window to choice a camera know its only one camera installed
[DllImport("user32", EntryPoint = "SendMessage")]
static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
[DllImport("avicap32.dll", EntryPoint = "capCreateCaptureWindowA")]
static extern int capCreateCaptureWindowA(string lpszWindowName, int dwStyle,
int X, int Y, int nWidth, int nHeight, int hwndParent, int nID);
const int WM_CAP_CONNECT = 1034;
const int WM_CAP_DISCONNECT = 1035;
const int WM_CAP_COPY = 1054;
const int WM_CAP_GET_FRAME = 1084;
This api works on windows xp with a service application so i created service app which pipe communicate with the appliaction and transfer the picture in bytes but note it only works on windows xp
how can i catch a webcam picture without this window am using some api in windows vista,7,8
Thanks B.
The API you are referring to (Video for Windows) is not supposed to operate without a window. The window however does not need to be visible, and you can move it out of work area too. It does not have to paint actually captured video as well, the window purpose is to communicate with the API. So it is usable in Window 7 too, provided of course that you have a well operating driver for these operating systems as well.
Other APIs you might want to look at are DirectShow and Media Foundation. DirectShow is the richest and best compatible throughout versions of Windows API, and you can do the task mentioned in the subject (capture without showing). From C# you typically work with it via DirectShow.NET library/binding and it has decent samples to look at on the website.
How on earth can you control the volume of the sound played using SndPlayAsync on Windows Mobile 6??
It seems like no one knows! The documentation doesn't mention anything regarding it...
So either there's no way, or it is kept top secret...
In addition, I am aware of the possibility of using the Windows Media Player, but I rather not, if possible.
Thanks for any help!
Aviv.
My suggestion is:
[DllImport("coredll.dll", SetLastError = true)]
protected static extern int waveOutSetVolume(IntPtr device, uint volume);
[DllImport("coredll.dll", SetLastError = true)]
internal static extern int waveOutGetVolume(IntPtr device, ref int volume);
And then you can call methods:
int before;
uint maxVol = uint.MaxValue;
waveOutGetVolume(IntPtr.Zero, ref before);
waveOutSetVolume(IntPtr.Zero, maxVol);
//Do some playing
waveOutSetVolume(IntPtr.Zero, before);
You can debug for other values. This will set it to highest.
Hope it helps?
You need to use the mixer... API functions to set the master volume. Here is a code sample:
http://www.csharp-home.com/index/tiki-read_article.php?articleId=134
To use this code in your Windows Mobile application, you need to change "winmm.dll" to "coredll.dll". Also, these methods may not be supported in Windows Mobile, but I'm pretty sure they are.
I'm using Visual C# 2008 Express. I'd like to use the same icon for the application (ie, the icon shown for the .exe), and for the main form. Unfortunately, VC# doesn't seem to be very smart about this, and insists on duplicating the icon data.
There doesn't seem to be a way of selecting an "already embedded" icon for use in the form or project icon (only selecting a file), and using the same file for both icons just embeds the file twice as far as I can see. It's not a big deal (hard drive space is cheap now, right?), but it bugs me.
Any idea how to avoid this? Is there a way to programatically load the executable's icon for use when the form is constructed, say? A couple of forum posts about similar things seem to suggest that .NET resources don't use the normal old Windows resource system -- is there a way from within the framework of getting at the old-style resources? Or do I have to bind the Win32 API functions to do it?
You're right, and it's rather annoying.
You have to load the icons yourself instead of relying on designer-generated code. Save the icon as a project resource, then load the resource into the form's Icon property in the form's constructor:
this.Icon = Properties.Resources.myIconResourceName;
You're looking for Icon.ExtractAssociatedIcon. Call passing your executable:
var icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
Yeah, it's pretty annoying. But the problem with the proposed answer of Icon.ExtractAssociatedIcon is that it will retrieve the 32x32 icon, and then downsample to a 16x16 icon in your forms window or on the taskbar, which will look terrible unless your 32x32 icon is very cleverly constructed.
The way I'm doing it is with interop (put the first line in your form constructor):
this.Icon = ExtractSmallIconFromLibrary(Application.ExecutablePath);
...
public static Icon ExtractSmallIconFromLibrary(string file) {
IntPtr[] reficon = new IntPtr[1];
int nextracted = ExtractIconEx(file, 0, null, reficon, 1);
if (nextracted < 1)
return null;
Icon unmanaged_icon = Icon.FromHandle(reficon[0]);
Icon icon = (Icon)unmanaged_icon.Clone();
DestroyIcon(unmanaged_icon.Handle);
return icon;
}
[DllImport("Shell32", CharSet = CharSet.Auto)]
extern static int ExtractIconEx(
[MarshalAs(UnmanagedType.LPTStr)]
string lpszFile,
int nIconIndex,
IntPtr[] phIconLarge,
IntPtr[] phIconSmall,
int nIcons
);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
extern static bool DestroyIcon(IntPtr handle);
But this isn't great, either, since you do want the 32x32 icon for things like the Alt-Tab icon list. So you really need to extract the entire icon, which is a bigger job. Maybe there's a straightforward way to combine the two icons into one. Or you can do like this codeproject program, which extracts the whole icon in the first place with a huge pile of code.
I think in many cases including a duplicate icon is at the end of the day more efficient than trying to extract it from the unmanaged resource - considering you can't use Icon.ExtractAssociatedIcon for UNC paths.
I had a similar problem.
I have and exe icon I want to reuse for subforms without increasing file size.
//From MyApp
MySubForm msf = new MySubForm();
msf.Icon = this.Icon;
msf.Show();
I don't know if this is useful, but I want to share it in anyway.