CJPushButton Image

This forum is for support of XCodeJock
Message
Author
skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

CJPushButton Image

#1 Post 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?
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4774
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CJPushButton Image

#2 Post 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
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: CJPushButton Image

#3 Post 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 33095 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
greetings by OHR
Jimmy

skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: CJPushButton Image

#4 Post 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.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4774
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CJPushButton Image

#5 Post 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?
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4774
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CJPushButton Image

#6 Post 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
The eXpress train is coming - and it has more cars.

skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: CJPushButton Image

#7 Post 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.
Best regards,

Chris.
www.aboservice.be

User avatar
Tom
Posts: 1205
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: CJPushButton Image

#8 Post 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.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4774
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CJPushButton Image

#9 Post by rdonnay »

Ok, now I understand.

It may be possible to do it in one command.
I will check into this.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: CJPushButton Image

#10 Post by skiman »

Hi Roger,

Did you find the time to check this?
Best regards,

Chris.
www.aboservice.be

Post Reply