FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Image usage with BTNBMP
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

Image usage with BTNBMP

Posted: Fri Dec 12, 2014 08:05 AM
I tried to create a fancy looking button by using BTNBMP. However I ran into a few problems.





The prg
Code (fw): Select all Collapse
#include "fivewin.ch"

procedure main()
  local oDlg, oBtn

  DEFINE DIALOG oDlg RESOURCE "MENU"

    redefine btnbmp obtn resource "po","po","po","po_over" id 104 of oDlg noborder action oDlg:end()

  ACTIVATE DIALOG oDlg ON INIT (oBtn:nWidth := 400, oBtn:nHeight := 31) CENTER

return


Rc
Code (fw): Select all Collapse
po      bitmap loadoncall moveable discardable "po.bmp"
po_over bitmap loadoncall moveable discardable "po_over.bmp"

MENU DIALOG 0, 0, 298, 94
STYLE DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION ""
FONT 10, "System"
{
 CONTROL "", 104, "button", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 24, 48, 136, 14
}


The images can be downloaded from https://dl.dropboxusercontent.com/u/55198640/HUABTN.ZIP

Is there also a way to have the button automatically taking up the size of the image?
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

Re: Image usage with BTNBMP

Posted: Fri Dec 12, 2014 08:53 AM

Fixed the missing row of pixel and sporadic yellow dots by touching up the image. Pixel at top left is colored with a colour that doesn't exist in the image

Hope another option can be created rather than manually touch up all the images

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: Image usage with BTNBMP

Posted: Sat Dec 13, 2014 08:45 AM

Hua,

FWH uses the top left pixel of the image to select the transparency color.

This is something that I learnt from Borland :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

Re: Image usage with BTNBMP

Posted: Sat Dec 13, 2014 02:18 PM

What option is available to disable that behaviour when we don't have image that has transparency Antonio?

Is there also a way to hide the focus rectangle?

Thank you

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: Image usage with BTNBMP

Posted: Sun Dec 14, 2014 05:12 AM

Hua,

I just realized that you are using a "Button" here:

CONTROL "", 104, "button", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 24, 48, 136, 14

but in fact it should be a "TBtnBmp" control:

CONTROL "", 104, "TBtnBmp", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 24, 48, 136, 14

Please try it again and let me know if that makes a difference, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

Re: Image usage with BTNBMP

Posted: Mon Dec 15, 2014 03:56 AM

It didn't make any difference Antonio.

However I discovered setting :lBmpTransparent := .f. fixed the issue for me so I'm using that approach to avoid having to touch up the images.

So the remaining questions that I have is:
i. Is there also a way to have the button automatically taking up the size of the image?
ii. How to disable the focus rectangle? (it's ok if this can't be done. It doesn't have a high priority)

TIA

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: Image usage with BTNBMP

Posted: Mon Dec 15, 2014 06:38 AM

Hua,

Glad to know you don't have to modify your images.

> i. Is there also a way to have the button automatically taking up the size of the image?

You could use a TImage control that will paint the image on all its surface. Or we could modify Class TBtnBmp. Whatever is better for you.

> ii. How to disable the focus rectangle? (it's ok if this can't be done. It doesn't have a high priority)

Please try to add this function to your code:

function RoundBox()
return nil

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion