Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » AlphaColor not working on 2.80?? Collapse All
Subject Author Date
Enrico Da Ros Aug 1, 2007 - 9:44 AM

Hi i had a problem on getting to work AlphaColor in Drawcli sample, mainfrm.cpp, line 411
It seems that loading the bitmap from a file instead of a resource give some problem.
Our current application dinamically create toolbars in runtime allowing the user to load
wetheaver bitmap from file, with arbitrary colors, arbitrary size, arbitrary (ususally different)
backgrounds. I was tryng for
testing purposes to accomply the same taks loading an RGB(128,128,128) filled bmp with 2
RGB(255,0,0) spots exactly in the middle, into drawcli... Transparent background never works :(
I tried with 16x16,32x32,16M,64K,256,16 bitmaps (all the combinations all with the previously
described bitmap) but nothing happens... Am i doing something wrong

I add a snippet from line 411 where i commented out the HICON creation replace with CExtBitmap
and modified CmdSetIcon.
The bitmap is shown but without any kind of transparency


/*HICON hIcon = (HICON)
                ::LoadImage(
                    hInstResource,
                    MAKEINTRESOURCE( nCmdID ),
                    IMAGE_ICON,
                    16,
                    16,
                    0
                    );*/
            CExtBitmap ptr;
            ptr.LoadBMP_File("X:\\Docs\\Repository\\Eagle\\Tests\\a03.bmp",TRUE);
            ptr.Scale(16,16);
            
            ptr.Make32();
            ptr.AlphaColor( RGB(128,128,128), RGB(128,128,128), 0 );
            //ptr.AdjustAlpha(1);

            HICON hIcon =(HICON)ptr.CreateHICON();
            
            if( hIcon != NULL )
            {
                VERIFY(
                    g_CmdManager->CmdSetIcon(
                        g_CmdManager->ProfileNameFromWnd(GetSafeHwnd()),
                        nCmdID,
                        hIcon,
                        true
                        )
                    );
            } // if( hIcon != NULL )
            

Hoping to find an answer, and to buy your product

E.Da Ros

Technical Support Aug 6, 2007 - 8:34 AM

Please use the following code

            CExtCmdIcon ptr;
            ptr.m_bmpNormal.LoadBMP_File("X:\\Docs\\Repository\\Eagle\\Tests\\a03.bmp",TRUE);
            ptr.m_bmpNormal.Scale(16,16);
            ptr.Make32();
            ptr.AlphaColor( RGB(128,128,128), RGB(128,128,128), 0 );
            //ptr.AdjustAlpha(1);
            VERIFY(
                  g_CmdManager->CmdSetIcon(
                        g_CmdManager->ProfileNameFromWnd(GetSafeHwnd()),
                        nCmdID,
                        ptr
                        )
                  );
You should not convert CExtBitmap/CExtCmdIcon objects into GDI icon handles or bitmap handles because such a conversion does not work correctly on some Windows OS versions.