Checkbox and Radio are not transparent!?
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
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
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
-
- Posts: 824
- Joined: Thu Oct 13, 2005 7:39 am
- Location: Germany
Hakan,
lets take Ramesh´s sample, here is the changed test
lets take Ramesh´s sample, here is the changed test
Code: Select all
#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
Stefan
Thanks Stefan,
It works good.
Is it possible to give oBrush's Width and Height in ACTIVATE DIALOG ON INIT like below?
It works good.
Is it possible to give oBrush's Width and Height in ACTIVATE DIALOG ON INIT like below?
Code: Select all
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 & VS 2019 & FWH 20.12
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
-
- Posts: 824
- Joined: Thu Oct 13, 2005 7:39 am
- Location: Germany
Hakan,
no, that´s not possible at the moment, because the bitmap is created only virtually.
But you can try this (not tested):
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
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
Stefan
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Checkbox and Radio are not transparent!?
A working example:
Code: Select all
#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
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
Re: Checkbox and Radio are not transparent!?
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
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
Re: Checkbox and Radio are not transparent!?
Dear Mr.Ramesh and Mr.Antonio
The Sample is working fine in FWH 9.01
Regards
Anser
The Sample is working fine in FWH 9.01
Regards
Anser
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
Re: Checkbox and Radio are not transparent!?
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Checkbox and Radio are not transparent!?
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()
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()
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
Re: Checkbox and Radio are not transparent!?
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
>>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
Re: Checkbox and Radio are not transparent!?
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.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Checkbox and Radio are not transparent!?
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:
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
#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
Re: Checkbox and Radio are not transparent!? (solved!)
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?
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Checkbox and Radio are not transparent!? (solved!)
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...
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
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