Checkbox and Radio are not transparent!?

Postby Horizon » Mon Nov 03, 2008 1:28 pm

Stephan,

Can you us a small working example please?

Thanks,
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby RAMESHBABU » Mon Nov 03, 2008 2:15 pm

Dear Antonio,

Thanks for your attention to the subject.

>>Ok, so basically what you do is to create a bitmap from the painted
>>gradient and then use the bitmap for a brush.

Yes.

>> could implement a method to automatically do it, without having to >>e any external tool

The main reason to adopt this work around is non functioning of DIBWRITE
in win98. Always I found that a bitmap of 0 bytes is created in win98.

As I said, this is a workaround and if it is done in native FWH, it would be a great help to the total communitiy.

Thanks,

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby StefanHaupt » Tue Nov 04, 2008 8:36 am

Hakan,

lets take Ramesh´s sample, here is the changed test

Code: Select all  Expand view  RUN
#include "fivewin.ch"
#include "Image.ch"

FUNCTION main()

LOCAL oDlg, oIcon, oBrush, oGroup, oRadio, oCheckBox, oSay, oGet, oButton
LOCAL cTest := "Hello world!   ", nValue := 2, lValue := .F., oImage

DEFINE ICON oIcon FILE "..\icons\fivewin.ico"

//DEFINE BRUSH oBrush
oBrush := TBrushX():New (100,160,CLR_WHITE,nRgb(152,194,152), .t.,.f.)   // <------
// Take care that the dimension of the bitmap has the same size as the dialog

DEFINE DIALOG oDlg TITLE "I am a DialogBox" BRUSH oBrush                     ;
       ICON oIcon TRANSPARENT


   @ 4.25,.25 IMAGE oImage SIZE 20, 20 OF oDlg NOBORDER
   oImage:LoadImage( "gradtest", )


   @ 0.25,0.75 GROUP oGroup TO 4,21.80 PROMPT "Test Group" OF oDlg           ;
               COLOR CLR_BLUE TRANSPARENT

   @ 0.75,2.00 SAY oSay PROMPT "Enter your Name:" OF oDlg SIZE 7,12          ;
               COLOR CLR_BLUE

   @ 0.90,7.50 GET cTest OF oDlg SIZE 40,12

   @ 1.75,0.95 RADIO oRadio VAR nValue                                       ;
               ITEMS "&One", "&Two", "T&hree" _3D SIZE 50, 12                ;
               OF oDlg ON CHANGE MsgBeep() COLOR CLR_RED

   @ 3.35,10.00 CHECKBOX oCheckBox VAR lValue PROMPT "&ClickMe" SIZE 100, 12 ;
               OF oDlg                                                       ;
               ON CHANGE oCheckBox:SetText( "New Text" ) COLOR CLR_BLUE

   @ 3.35,5.00 BUTTON "&Ok" SIZE 35, 12 ;
               ACTION MsgInfo( "Any action here!" ) DEFAULT

   @ 3.35,16.00 BUTTON "&Cancel" SIZE 35, 12 ACTION oDlg:End()


ACTIVATE DIALOG oDlg CENTERED                                                ;
                  VALID MsgYesNo( "Do you want to end ?" )

RETURN nil
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby Horizon » Tue Nov 04, 2008 9:46 am

Thanks Stefan,

It works good.

Is it possible to give oBrush's Width and Height in ACTIVATE DIALOG ON INIT like below?

Code: Select all  Expand view  RUN
ACTIVATE DIALOG oDlg CENTERED ON INIT (oBrush:nHeight := oDlg:nHeight,oBrush:nWidth:=oDlg:nWidth)  ;
                  VALID MsgYesNo( "Do you want to end ?" )
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby StefanHaupt » Tue Nov 04, 2008 12:15 pm

Hakan,

no, that´s not possible at the moment, because the bitmap is created only virtually.

But you can try this (not tested):

Code: Select all  Expand view  RUN
DEFINE BRUSH oBrush
//oBrush := TBrushX():New (100,160,CLR_WHITE,nRgb(152,194,152), .t.,.f.)   // <------
// Take care that the dimension of the bitmap has the same size as the dialog

DEFINE DIALOG oDlg TITLE "I am a DialogBox" BRUSH oBrush 

ACTIVATE DIALOG oDlg CENTERED ON INIT (oBrush := TBrushX():New (oDlg:nWidth,oDlg:nHeight,CLR_WHITE,nRgb(152,194,152), .t.,.f.),;
oDlg:SetColor (,,oBrush), oDlg:Refresh() )
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Checkbox and Radio are not transparent!?

Postby Antonio Linares » Wed Feb 04, 2009 2:15 am

A working example:
Code: Select all  Expand view  RUN
#include "FiveWin.ch"

function Main()

   local oDlg, oCbx1, lValue1 := .T., oCbx2, lValue2 := .T., oCbx3, lValue3 := .T.
   local oRadMenu, nValue := 1

   DEFINE DIALOG oDlg TITLE "Test"

   @ 1, 2 CHECKBOX oCbx1 VAR lValue1 COLOR "W+/B"
   oCbx1:lTransparent = .T.

   @ 2, 2 CHECKBOX oCbx2 VAR lValue2 COLOR "W+/B"
   oCbx2:lTransparent = .T.

   @ 3, 2 CHECKBOX oCbx3 VAR lValue3 COLOR "W+/B"
   oCbx3:lTransparent = .T.
   
   @ 1.3, 9 RADIO oRadMenu VAR nValue ITEMS "One", "Two", "Three" SIZE 80, 13 COLOR "GR+/B"
   AEval( oRadMenu:aItems, { | oRad | oRad:lTransparent := .T. } )

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT GradientBrush( oDlg, { { 0.4, nRGB( 75, 144, 223 ), nRGB( 41, 85, 145 ) },;
                                     { 0.6, nRGB( 24,  61, 118 ), nRGB( 50, 95, 158 ) } } )

return nil

function GradientBrush( oDlg, aColors )

   local hDC, hBmp, hBmpOld
   
   if Empty( oDlg:oBrush:hBitmap )
      hDC = CreateCompatibleDC( oDlg:GetDC() )
      hBmp = CreateCompatibleBitMap( oDlg:hDC, oDlg:nWidth, oDlg:nHeight )
      hBmpOld = SelectObject( hDC, hBmp )
      GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aColors )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
      SelectObject( hDC, hBmpOld )
      oDlg:ReleaseDC()
   endif   

return nil

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Checkbox and Radio are not transparent!?

Postby RAMESHBABU » Wed Feb 04, 2009 6:44 am

Hello Mr.Antinio,

Thanks for your nice solution. But I dont find source for "CreateCompatableBitMap()".

I am using FWH 8.09

Please provide it to me.

Regards,

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Checkbox and Radio are not transparent!?

Postby anserkk » Wed Feb 04, 2009 6:50 am

Dear Mr.Ramesh and Mr.Antonio

The Sample is working fine in FWH 9.01

Regards

Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Checkbox and Radio are not transparent!?

Postby RAMESHBABU » Wed Feb 04, 2009 7:10 am

Mr.Antonio,

I got the source for "CreateCompatableBitMap()" function in the earlier pages of this posting
itself.

I have tested your solution in FWH8.09 and worked very well.

Finally our GURU Mr.Antonio has given a very best solution for Gradient Dialogs.

Thank you once again.

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Checkbox and Radio are not transparent!?

Postby Antonio Linares » Wed Feb 04, 2009 8:58 am

Dear Ramesh,

I am happy that finally we found a simple solution for it :-)

As you see the function GradientBrush() dynamically creates a brush but using the dimensions of the dialogbox, so we can use aColors the same way as we use it with GradientFill() :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Checkbox and Radio are not transparent!?

Postby RAMESHBABU » Wed Feb 04, 2009 10:06 am

Dear Mr.Antinio

>>As you see the function GradientBrush() dynamically creates a brush but using the dimensions of the dialogbox, so we can
>>use aColors the same way as we use it with GradientFill()

Yes. The function is simple and intelligent.

Just now I have completed replacing my earlier functions with GradientBrush() in my projects and testing ...

Regards,

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Checkbox and Radio are not transparent!?

Postby byte-one » Wed Feb 04, 2009 3:21 pm

This is functioning but if i use not only one dialog in program, this brush are used also in all other dialogs. But the brush is not defined in this dialogs with ..ON INIT.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Checkbox and Radio are not transparent!?

Postby Antonio Linares » Wed Feb 04, 2009 6:14 pm

Günther,

Yes, its a curious effect :-) caused because we are changing a default brush.

This is the way to solve it: just define a brush for the dialog where GradientBrush() is used:
Code: Select all  Expand view  RUN
#include "FiveWin.ch"

function Main()

   local oWnd
   
   DEFINE WINDOW oWnd
   
   @ 1.6, 17 BUTTON "First" SIZE 70, 25 ACTION First()
   
   @ 3.6, 17 BUTTON "Another" SIZE 70, 25 ACTION Another()
   
   ACTIVATE WINDOW oWnd
   
return nil   

function First()

   local oDlg, oBrush
   local oCbx1, lValue1 := .T., oCbx2, lValue2 := .T., oCbx3, lValue3 := .T.
   local oRadMenu, nValue := 1

   DEFINE BRUSH oBrush COLOR CLR_WHITE

   DEFINE DIALOG oDlg TITLE "Test" BRUSH oBrush

   @ 1, 2 CHECKBOX oCbx1 VAR lValue1 COLOR "W+/B"
   oCbx1:lTransparent = .T.

   @ 2, 2 CHECKBOX oCbx2 VAR lValue2 COLOR "W+/B"
   oCbx2:lTransparent = .T.

   @ 3, 2 CHECKBOX oCbx3 VAR lValue3 COLOR "W+/B"
   oCbx3:lTransparent = .T.
   
   @ 1.3, 9 RADIO oRadMenu VAR nValue ITEMS "One", "Two", "Three" SIZE 30, 13 COLOR "GR+/B"
   AEval( oRadMenu:aItems, { | oRad | oRad:lTransparent := .T. } )

   @ 1.6, 17 BUTTON "Another" ACTION Another()

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT GradientBrush( oDlg, { { 0.4, nRGB( 75, 144, 223 ), nRGB( 41, 85, 145 ) },;
                                     { 0.6, nRGB( 24,  61, 118 ), nRGB( 50, 95, 158 ) } } )

return nil

function Another()

   local oDlg
   
   DEFINE DIALOG oDlg
   
   ACTIVATE DIALOG oDlg CENTERED
   
return nil   

function GradientBrush( oDlg, aColors )

   local hDC, hBmp, hBmpOld, oBrush
   
   if Empty( oDlg:oBrush:hBitmap )
      hDC = CreateCompatibleDC( oDlg:GetDC() )
      hBmp = CreateCompatibleBitMap( oDlg:hDC, oDlg:nWidth, oDlg:nHeight )
      hBmpOld = SelectObject( hDC, hBmp )
      GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aColors )
      DeleteObject( oDlg:oBrush:hBrush )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
      SelectObject( hDC, hBmpOld )
      oDlg:ReleaseDC()
   endif   

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Checkbox and Radio are not transparent!? (solved!)

Postby byte-one » Wed Feb 04, 2009 8:40 pm

Antonio, can this solution not included into the function gradientbrush() with oDlg:setbrush(obrush) or so? In TBrush you are save all brushes for a new call from the same brush. Should be this brush made from gradientbrush() erased? And should the resources hDC and hBmp not be released?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Checkbox and Radio are not transparent!? (solved!)

Postby Antonio Linares » Wed Feb 04, 2009 11:28 pm

Günther,

Yes, I missed to destroy the hDC! :?

hBmp will be destroyed by the brush itself.

The problem to include it as a Method in Class TBrush is that we need the dimensions of the dialog in advance...
Code: Select all  Expand view  RUN
function GradientBrush( oDlg, aColors )

   local hDC, hBmp, hBmpOld, oBrush
   
   if Empty( oDlg:oBrush:hBitmap )
      hDC = CreateCompatibleDC( oDlg:GetDC() )
      hBmp = CreateCompatibleBitMap( oDlg:hDC, oDlg:nWidth, oDlg:nHeight )
      hBmpOld = SelectObject( hDC, hBmp )
      GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aColors )
      DeleteObject( oDlg:oBrush:hBrush )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
      SelectObject( hDC, hBmpOld )
      DeleteDC( hDC )
      oDlg:ReleaseDC()
   endif   

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests