![]() ![]() LRESULT HitTestNCA(HWND hWnd, WPARAM wParam, LPARAM lParam) HBRUSH DARKEST_BRUSH = CreateSolidBrush(RGB(0, 0, 0)) HBRUSH LIGHTPURPLE_BRUSH_2 = CreateSolidBrush(RGB(255, 174, 201)) HBRUSH LIGHTPURPLE_BRUSH_1 = CreateSolidBrush(RGB(189, 106, 189)) HBRUSH PURPLE_BRUSH = CreateSolidBrush(RGB(163, 73, 164)) HBRUSH DARKBLUE_BRUSH = CreateSolidBrush(RGB(26, 31, 96)) HBRUSH RED_BRUSH = CreateSolidBrush(RGB(237, 28, 36)) #define RECTHEIGHT(rc) (rc.bottom - rc.top) #define RECTWIDTH(rc) (rc.right - rc.left) LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) If you try it please use VS debugger as I did not put functional window buttons. However, It work as Anti Aliased with painted background (Solid) but not with TRANSPARENT background. The issue is I want to do something beatiful and I tried to render a Anti Aliased window border in client area with GDI. The reason I use layered window is, I want to make window's bottom border's corners rounded. My COLORKEY is RGB(0,0,0) SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 255, LWA_COLORKEY) I also use layered window to render background transparent. hr = DwmExtendFrameIntoClientArea(hWnd, &margins) you can't change the Transparency after you've shown it.or else.Ĭhris Sells suggested I set my Window to AllowsTransparency = True all the time, then make a Canvas over the top of it that had an opaque Brush with color and transparency I could change as I liked as it'd be "inside" WPF world and not have to deal with any underlying limitations in Win32.įor now, my not-quite-transparent brush got me the feature I wanted - BabySmash over an existing desktop.I use extended frame to render a custom caption and window border. WindowStartupLocation = WindowStartupLocation.Manual,ĪllowsTransparency = ,īackground = ( ? new SolidColorBrush(Color.FromArgb(1,0,0,0)) : Brushes.WhiteSmoke) Once you've created a Window that is transparent like my funky full-screen one, MainWindow m = new MainWindow(this) This was an interesting edge class where WPF's definition of Transparent didn't quite line up with Window's definition. If you want transparency and hit testing, define a color with minimal alpha just as you have done. If something is 100% transparent then hit testing is bypassed. "Your almost-transparent brush fails the Windows transparency test, so windows delivers events to it. I get the look of transparency, except the Window is still there and I can click on it. Now if I set my Window's background to this Brush: new SolidColorBrush(Color.FromArgb(1,0,0,0)) You've got not just RGB, you've got an Alpha Channel PLUS RGB. I can make a Brush that is not just #000000 (Black) but also #01000000 (really really transparent black. Ok, but I have complete control over my Brushes and their colors. ![]() This is where WPF meets the rest of Windows. It cannot differentiate between null and Transparent."Īh, makes sense. "This is because a layered window is represented to the OS as a bitmap, so all it can do is look at the pixel values. This was interesting because everywhere else in WPF if you have a Brush that is null, that's "hollow" and Transparent is solid. "Windows treats fully transparent layered-windows windows as hollow." Well, here's why, and if I'd read 4 chapters into Chris Sell's book, I'd have figured this out. ![]() I could "click through" the application to the desktop below. It was totally invisble, except for my little bit of text at the top. This made the Window Transparent, but " hollow" in that I couldn't click on it. I went into my MainWindow.xaml and added these attributes: Background="Transparent" AllowsTransparency="True" WindowStyle="None"īam! Right? Well, kind of. I figured, hey, WPF must be good at that, transparency at all. Someone wanted the BabySmash Window to have the option to be transparent. Pick a single line, a section, or subsystem or the whole app! Post your solutions on your blog, in the comments, or in the Feedback and we'll all learn WPF together. I'm calling on community (that's you, Dear Reader) to blog about your solutions to different (horrible) selections of my code. It's not a good example of a WPF application even though it uses the technology. I wrote an application for my 2 year old using WPF, but as I'm a Win32-minded programmer, my working app is full of Win32-isms. Also check out for more developer info on WPF.īACKGROUND: This is one of a series of posts on learning WPF. NOTE: If you haven't read the first post in this series, I would encourage you do to that first, or check out the BabySmash category. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |