FORUMS
Remove All Ads from XDA

WM6.5 - Creating custom shaped form with animation and set opacity level

1,177 posts
Thanks Meter: 245
 
By Nullstring, Retired Recognized Developer on 18th June 2010, 02:58 PM
Post Reply Email Thread
Creating custom shaped form and setting opacity level using SetLayeredWindowAttributes API for Windows Mobile 6.5 only and higher version



I did some cute little application called Neko for Windows Mobile 6.5

and to share the idea on how I done the custom shaped form, here's a little sample code
Attached Files
File Type: zip FormTransparencyTestInWM65.zip - [Click for QR Code] (44.8 KB, 299 views)
 
 
20th June 2010, 03:21 AM |#2  
Nullstring's Avatar
OP Retired Recognized Developer
Flag Baguio
Thanks Meter: 245
 
Donate to Me
More
i'm scared probably somebody will make a Windows Dancer or Virtual Girl

uh oh ................. >.<

LOL
20th June 2010, 07:26 AM |#3  
expressions104's Avatar
Member
Flag Bulacan
Thanks Meter: 49
 
More
I like this app..thank you very much.

----Now I have A pet in my phone..LOL

__>> or a stripper.
20th June 2010, 08:42 AM |#4  
Nullstring's Avatar
OP Retired Recognized Developer
Flag Baguio
Thanks Meter: 245
 
Donate to Me
More
Quote:
Originally Posted by expressions104

I like this app..thank you very much.

----Now I have A pet in my phone..LOL

__>> or a stripper.

I was eager to make a Virtual Dancer but am not sure if most you will like it.
LOL.

Lucky I don't have sprites to start with. haha. will probably use this

but just the guy and dance at the bottom of the screen. lol

hmmmmmmm.................

the dancer is theme-able also.. so the idea will be the same thing as Neko.. I'll do the base and you guys create your own dancers.

>:>
20th June 2010, 08:52 AM |#5  
Nullstring's Avatar
OP Retired Recognized Developer
Flag Baguio
Thanks Meter: 245
 
Donate to Me
More
can't find dancing Spiderman

update: found it!

aha...
21st June 2010, 03:24 AM |#6  
Nullstring's Avatar
OP Retired Recognized Developer
Flag Baguio
Thanks Meter: 245
 
Donate to Me
More
guys, have you tried using UpdateLayeredWindow API?

am not sure why it doesn't work.
meaning.. just a blank layered window ..

PHP Code:
public void MakeEXLAYERED(IntPtr hWnd)
{
    
// add WS_EX_LAYERED and WS_EX_TRANSPARENT extended style in our form 
    
int _initialexstyle Win32.GetWindowLong(hWndWin32.GWL_EXSTYLE);
    
Win32.SetWindowLong(hWndWin32.GWL_EXSTYLE_initialexstyle Win32.WS_EX_LAYERED Win32.WS_EX_TANSPARENT);
}
        
public 
void SetBitmap(IntPtr hWndPoint locationBitmap bitmapbyte opacity)
{
    
//if (bitmap.PixelFormat != PixelFormat.Format32bppArgb)
    //    throw new ApplicationException("The bitmap must be 32ppp with alpha-channel.");

    
IntPtr screenDc Win32.GetDC(IntPtr.Zero);
    
System.Diagnostics.Debug.WriteLine("screenDc: " screenDc);
    
IntPtr memDc Win32.CreateCompatibleDC(screenDc);
    
System.Diagnostics.Debug.WriteLine("memDc: " memDc);
    
IntPtr hBitmap IntPtr.Zero;
    
IntPtr oldBitmap IntPtr.Zero;

    try
    {
        
hBitmap bitmap.GetHbitmap();  // grab a GDI handle from this GDI+ bitmap
        
System.Diagnostics.Debug.WriteLine("hBitmap: " hBitmap);
        
oldBitmap Win32.SelectObject(memDchBitmap);
        
System.Diagnostics.Debug.WriteLine("oldBitmap: " oldBitmap);

        
Win32.Size size = new Win32.Size(bitmap.Widthbitmap.Height);
        
Win32.Point pointSource = new Win32.Point(00);
        
Win32.Point topPos = new Win32.Point(location.Xlocation.Y);

        
Win32.BLENDFUNCTION blend = new Win32.BLENDFUNCTION();
        
blend.BlendOp Win32.AC_SRC_OVER;
        
blend.BlendFlags 0;
        
blend.SourceConstantAlpha opacity;
        
blend.AlphaFormat Win32.AC_SRC_ALPHA;

        
Win32.Bool success Win32.UpdateLayeredWindow(hWndscreenDcref topPosref sizememDcref pointSource0ref blendWin32.ULW_ALPHA);
        if(
success == Win32.Bool.FalseSystem.Diagnostics.Debug.WriteLine("failed to blend");
    }
    finally
    {
        
Win32.ReleaseDC(IntPtr.ZeroscreenDc);
        if (
hBitmap != IntPtr.Zero)
        {
            
Win32.SelectObject(memDcoldBitmap);
            
Win32.DeleteObject(hBitmap);
        }
        
Win32.DeleteDC(memDc);
    }

Bitmap must be an PNG image with alphablend

21st June 2010, 03:41 AM |#7  
Nullstring's Avatar
OP Retired Recognized Developer
Flag Baguio
Thanks Meter: 245
 
Donate to Me
More
something's wrong here

PHP Code:
hBitmap bitmap.GetHbitmap();  // grab a GDI handle from this GDI+ bitmap
                
System.Diagnostics.Debug.WriteLine("hBitmap: " hBitmap);
                
oldBitmap Win32.SelectObject(memDchBitmap); 
22nd June 2010, 04:56 PM |#8  
NRGZ28's Avatar
Retired Senior Mod & Senior RD - (old) King of WinMo
Flag XDA-Developers
Thanks Meter: 10,071
 
More
Very cool stuff :P
10th July 2010, 08:29 PM |#9  
Chainfire's Avatar
Moderator Emeritus / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 88,039
 
Donate to Me
More
Interesting, I haven't use this API in years (since it was first introduced in W2K). Didn't know it was now supported in 6.5 ! Gonna see if I can do some fun things with it.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes