MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / MakeColorPickButton

Function MakeColorPickButton

src/Helpers.c:665–703  ·  view source on GitHub ↗

============================================================================= MakeColorPickButton()

Source from the content-addressed store, hash-verified

663// MakeColorPickButton()
664//
665void MakeColorPickButton ( HWND hwnd, int nCtlId, HINSTANCE hInstance, COLORREF crColor )
666{
667 HWND hwndCtl = GetDlgItem ( hwnd, nCtlId );
668 BUTTON_IMAGELIST bi;
669 HIMAGELIST himlOld = NULL;
670 HBITMAP hBmp;
671 COLORMAP colormap[2];
672 if ( SendMessage ( hwndCtl, BCM_GETIMAGELIST, 0, ( LPARAM ) &bi ) ) {
673 himlOld = bi.himl;
674 }
675 if ( IsWindowEnabled ( hwndCtl ) && crColor != -1 ) {
676 colormap[0].from = RGB ( 0x00, 0x00, 0x00 );
677 colormap[0].to = GetSysColor ( COLOR_3DSHADOW );
678 } else {
679 colormap[0].from = RGB ( 0x00, 0x00, 0x00 );
680 colormap[0].to = RGB ( 0xFF, 0xFF, 0xFF );
681 }
682 if ( IsWindowEnabled ( hwndCtl ) && crColor != -1 ) {
683 if ( crColor == RGB ( 0xFF, 0xFF, 0xFF ) ) {
684 crColor = RGB ( 0xFF, 0xFF, 0xFE );
685 }
686 colormap[1].from = RGB ( 0xFF, 0xFF, 0xFF );
687 colormap[1].to = crColor;
688 } else {
689 colormap[1].from = RGB ( 0xFF, 0xFF, 0xFF );
690 colormap[1].to = RGB ( 0xFF, 0xFF, 0xFF );
691 }
692 hBmp = CreateMappedBitmap ( hInstance, IDB_PICK, 0, colormap, 2 );
693 bi.himl = ImageList_Create ( 10, 10, ILC_COLORDDB | ILC_MASK, 1, 0 );
694 ImageList_AddMasked ( bi.himl, hBmp, RGB ( 0xFF, 0xFF, 0xFF ) );
695 DeleteObject ( hBmp );
696 SetRect ( &bi.margin, 0, 0, 4, 0 );
697 bi.uAlign = BUTTON_IMAGELIST_ALIGN_RIGHT;
698 SendMessage ( hwndCtl, BCM_SETIMAGELIST, 0, ( LPARAM ) &bi );
699 InvalidateRect ( hwndCtl, NULL, TRUE );
700 if ( himlOld ) {
701 ImageList_Destroy ( himlOld );
702 }
703}
704
705
706//=============================================================================

Callers 1

Style_ConfigDlgProcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected