Page 1 of 2

CJPushButton Image

Posted: Fri Jun 04, 2010 8:36 am
by skiman
Hi Roger,

If I use the IMAGE clause of cjPushButton the image isn't transparent.

This is the syntax I use:

Code: Select all

	
@ 170,10 CJPushButton oBut1 ;
       Size 130,30 ;
       Caption fMessage(6000) ;
       ToolTip fTooltip(6000) ;
       Font '8.Arial Bold' ;
; //       TextImageRelation xtpTextBeforeImage ;
       Transparent ;
       Appearance xtpAppearanceOffice2007 ;
       Style xtpButtonNormal ;
       COLOR GRA_CLR_BLACK, GRA_CLR_WHITE ;
       Parent aWindows[1,1] ;
       ReSize DCGUI_RESIZE_RESIZEONLY ;
       Image ABO_KLANTN ;
       ACTION {|o|lHideDagb:=.T.,;
			o:=Thread():new(),o:start({||fFacturen(oDlg:drawingArea)}),dc_clearevents() }  ;
       when {|| frights("ADH") } ;
       PIXEL
ABO_KLANTN is a resource from my abo_res.DLL.

Any idea?

Re: CJPushButton Image

Posted: Fri Jun 04, 2010 9:59 am
by rdonnay
Chris -

I have a bad feeling about this.
I suspect that transparency doesn't work even though there is a membervar named :transparent in the pushbutton control.

If you look at the Pushbutton control docs, the description under the member "transparent" is the following:

Determines if the background of a TabControlPage is visible in WinXP mode.

If you click on the hyperlink under "transparent" it takes you to a description that is entirely ambiguous and not related at all to pushbuttons. I suspect that this is a feature that is misdocumented and is probably not supported.

Roger

Re: CJPushButton Image

Posted: Fri Jun 04, 2010 5:02 pm
by Auge_Ohr
hi,

what Type is your Image, BMP or ICO ?

i did not have that Problem with HX_Class as you can see Attachment
CJ_PushButton.jpg
CJ_PushButton.jpg (15.3 KiB) Viewed 36752 times
i did have a look into old XCodejock Code and saw

Code: Select all

STATIC FUNCTION _ButtonBlock( i, aDir, nOffset )
RETURN {|o,b|o:caption := 'Appearance ' + Alltrim(Str(i)), ;
           o:appearance := i, ;
           b := DC_GetBitmap('..\..\..\bitmaps\' + aDir[i+nOffset,1]), ;
           b:transparentClr := AutomationTranslateColor(b:transparentClr,.f.), ;
           o:picture := b:getIPicture(), ;
           o:imageGap := 20, ;
           o:click := {|a,b,o|MsgBox('button ' + Alltrim(str(i)))}}
as i can see, this Function use DC_GetBitmap() and use o:picture
but there is also a Icon Property which need ImageManagerIcon.

Code: Select all

   VAR Icon                            // Xbase++ NEW
   VAR x_Icon2
   ASSIGN METHOD _IPicture()           VAR x_Icon2
...
METHOD HX_Button:Create(...)
   //
   // ImageManagerIcon as XbpActiveXControl
   //
   ::oImgList        := XbpActiveXControl():new(,, {0,0}, {0,0} )
   ::oImgList:CLSID  := "Codejock.ImageManager"+HX_VERSION()
   ::oImgList:create()

   IF ::Icon == NIL
      ::Icon := "DUMMY.ICO"
   ENDIF
   IF ::Caption == NIL
      ::Caption := ""
   ENDIF
   IF ::preSelect == NIL
      ::preSelect := .F.
   ENDIF
   //
   // after create ?!
   //
   // ASSIGN METHOD "transfer" data
   //
   ::x_Icon2   := ::Icon
   ::x_Caption := ::Caption
   ::x_Default := ::preSelect

   ::UseVisualStyle := .T.
   //
   // set Presentation Parameter to activeX
   //
   IF .NOT. EMPTY(::aPres)
      HX_PresPara(self)
   ENDIF
   //
   //
   //
   ::Show()
RETURN self

METHOD HX_Button:_IPicture(xValue)     // COM iPicture
LOCAL lOkValue := .T.
LOCAL oLogo
LOCAL oPicture
LOCAL oIco
LOCAL lIco     := .T.
LOCAL nHandle
LOCAL oIcons
LOCAL nResource
LOCAL nCommand

IF PCOUNT() > 0
   IF ::nIcons <= 0
      ::nIcons := 1
   ELSE
      ::nIcons++
   ENDIF

   IF VALTYPE(xValue) = "C"            // STRING
      DO CASE
         CASE ".BMP" $ UPPER(xValue)
            ::oImgList:Icons:LoadBitmap(xValue,::nIcons,xtpImageNormal)
            lIco := .F.

         CASE ".ICO" $ UPPER(xValue)
            ::oImgList:Icons:LoadIcon  (xValue,::nIcons,xtpImageNormal)
      OTHERWISE
         lOkValue := .F.
      ENDCASE

   ELSEIF VALTYPE(xValue) = "N"        // Resoure ID
      oIco := HX_Icon():new():create()
      oIco:load( ::cResDLL, xValue )

      IF NIL = oIco
      ELSE
         ::setproperty("Picture", oIco:getIPicture() )
         ::nIcons++
      ENDIF
      RETURN self
   ELSE
      lOkValue := .F.
   ENDIF

   IF ::oImgList:Icons:Count() == 0
      MSGBOX("Icons "+LTRIM(STR(::oImgList:Icons:Count()))+" can not continue")
   ELSE
      IF lOkValue == .T.
        oIco := ::oImgList:Icons:GetImage(::nIcons,32)
         ::setproperty("Icon"   , oIco )
         ::nIcons++
      ENDIF
   ENDIF
ENDIF

RETURN self
as i can say, BMP have to be use ImageManagerIcon assing to Property Icon
while ICO have to load with XbpIcon() and use with Property Picture

Re: CJPushButton Image

Posted: Sat Jun 05, 2010 2:02 am
by skiman
Hi Jimmy,

I'm using BMP files.

I think that using that imagelist will be necessary when using Codejock. Roger succeeded to avoid this for some commands, but it seems as the use of the imagelist will solve problems as this.

Re: CJPushButton Image

Posted: Sun Jun 06, 2010 11:27 am
by rdonnay
I am misunderstanding something here.

If you run the Pushbutton sample in \exp19\XCodeJock\Samples\SuiteControls\PushButton\Pushbutton.prg, you will see that the images display correctly on the buttons with proper transparency.

What is it that you are looking to do?

Re: CJPushButton Image

Posted: Sun Jun 06, 2010 11:29 am
by rdonnay
Jimmy -

The old XCodeJock code no longer is applicable.
I don't do anything that way any more.

The new XCodeJock uses the image manager.

Roger

Re: CJPushButton Image

Posted: Sun Jun 06, 2010 11:44 pm
by skiman
Hi Roger,

Yes, the cjpƻshbutton sample is working with transparancy. This is with the use of SuiteControlsGlobalSetting and cjLoadBitmap.

No problem for me if that is the way to use it. I thought it could maybe be done direct in one command.

Re: CJPushButton Image

Posted: Mon Jun 07, 2010 12:23 am
by Tom
I get transparent bitmaps as cjpushbutton captions working if the bitmap has the background color I defined with DC_BitmapTransparentColor. If I use icons, there is no transparency, whatever I do.

Re: CJPushButton Image

Posted: Mon Jun 07, 2010 7:07 am
by rdonnay
Ok, now I understand.

It may be possible to do it in one command.
I will check into this.

Re: CJPushButton Image

Posted: Mon Jun 14, 2010 12:51 am
by skiman
Hi Roger,

Did you find the time to check this?