WND-Tools => testing of backgrounds for Wnd and Dlg

WND-Tools => testing of backgrounds for Wnd and Dlg

Postby ukoenig » Wed Aug 20, 2008 12:43 am

Hello,

i finished the job on another Tool
for testing <Wnd> and <Dlg>-backgrounds in combination.

Windows : BMP, Brushes, Gradients, Clear-colors
Dialog : BMP, Brushes, Gradients, Clear-colors

Everything works perfect. I can show brushes and pictures.
There is just one little problem.
After solving this, i can put the tool in the forum for download.

A screenshot of the Final-Version :
Image

When i define a new background for the main-window,
the new background is shown behind the dialog.
If i minimize and then maximize the dialog, the color
fills the main window and is shown correctly.
I think, there is something missing

I call this function from the 1. dialog-browser to change the window background :

Code: Select all  Expand view  RUN

// Browser-colorselection

oLbx3:bLClicked := { | nRow, nCol | BR_START := oLbx3:nRowSel, ;
     BR_COLOR1 := NEW_COLOR1(oWnd,oCOLOR1), ;
     oBR_COLOR1:Refresh(), oCOLOR1:Refresh() }

//------  Color defines color 1 - 7 are for gradients ------------------------

FUNCTION NEW_COLOR1(oWnd,oCOLOR1)
BR_COLOR1 := 0

IF BR_POS = 1 // Schwarz
   BR_COLOR1 := 0
   oCOLOR1:SetColor( CLR_WHITE, 0 ) // control-bitmaps for color.
ENDIF
IF BR_POS = 2  // Weiß
        BR_COLOR1 := 16777215
        oCOLOR1:SetColor( CLR_WHITE, 16777215 )
ENDIF
IF BR_POS = 3  // Blau
        BR_COLOR1 := 8388608
        oCOLOR1:SetColor( CLR_WHITE, 8388608 )
ENDIF
IF BR_POS = 4  // grün
        BR_COLOR1 := 32768
        oCOLOR1:SetColor( CLR_WHITE, 32768 )
ENDIF
IF BR_POS = 5  // Rot
   BR_COLOR1 := 128
   oCOLOR1:SetColor( CLR_WHITE, 128 )
ENDIF
IF BR_POS = 6  // Gelb
   BR_COLOR1 := 65535
   oCOLOR1:SetColor( CLR_WHITE, 65535 )
ENDIF
IF BR_POS = 7  // Magenta
   BR_COLOR1 := 8388736
   oCOLOR1:SetColor( CLR_WHITE, 8388736 )
ENDIF

// brushes
IF  BR_POS = 9
     DEFINE BRUSH oBrush1  STYLE HORIZONTAL
ENDIF
IF  BR_POS = 10
   DEFINE BRUSH oBrush1  STYLE VERTICAL
ENDIF
IF  BR_POS = 11
   DEFINE BRUSH oBrush1  STYLE FDIAGONAL
ENDIF
IF  BR_POS = 12
  DEFINE BRUSH oBrush1  STYLE BDIAGONAL
ENDIF
IF  BR_POS = 13
   DEFINE BRUSH oBrush1  STYLE CROSS
ENDIF
IF  BR_POS = 14
  DEFINE BRUSH oBrush1  STYLE DIAGCROSS
ENDIF
IF  BR_POS = 15
   DEFINE BRUSH oBrush1  STYLE BORLAND
ENDIF
IF  BR_POS = 16
   DEFINE BRUSH oBrush1  STYLE TILED
ENDIF

// draw the gradient
// it works, but is shown behind the dialog

IF BR_POS < 8 // Colors for gradient
   gradpaint1( hDC, oWnd )
   oWnd:Refresh()
ENDIF

RETURN ( BR_COLOR1 )

// ------ Gradient-painting for the main-window ----

static func gradpaint1( hDC, oWnd )

local aGrad := { { nMOVE1, BR_COLOR1, BR_COLOR2 }, ;
                   { nMOVE1, BR_COLOR2, BR_COLOR1 } }         

IF BR_STYLE1 = 1
   GradientFill( hDC,  0, 0, oWnd:nHeight, oWnd:nWidth, aGrad, .F. )
ELSE
   GradientFill( hDC,  0, 0, oWnd:nHeight, oWnd:nWidth, aGrad, .T. )
ENDIF

RETURN NIL



Image
Last edited by ukoenig on Wed Aug 20, 2008 12:54 pm, edited 4 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby James Bott » Wed Aug 20, 2008 5:19 am

Uwe,

>When i define a new background for the main-window,
>the new background is shown behind the dialog.
>If i minimize and then maximize the dialog, the color
>fills the main window and is shown correctly.

Hmm, did you mean to word the above differently? It sounds like you are saying that in both cases it is working correctly, so what is the problem?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Background-painting

Postby ukoenig » Wed Aug 20, 2008 9:37 am

Hello James,

Here is a screenshot :

Image

like you see, the new colors are shown at first only with the
dimension of the dialog behind the dialog ( i moved the the dialog a bit ).
With any action, starting another application or resizing the diolog,
the new color fills the main-window.
I think, the old gradient ( white / blue ) is also still active in the main-window.
I could show the results in a extra diolog like i have done before in other
tools, but i prefer, to make it better and show the results directly in the main-window and child-dialog.
I did a oWnd:Refresh(), but it doesn't help.

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Painting backgrounds

Postby ukoenig » Wed Aug 20, 2008 10:51 am

Hello James,

I have done some more tests.
It seems, the problem is the gradient-painting.

When there is a gradient before, it is allways on top .
i tested, to start the dialog without gradient and selected a brush.
The result was ok.

Image

When i want to change < gradient > to < brush > i have a problem.
I think, if i use a < clear > color before, it will work as well.
The gradient is still active and the new brush i can see around the borders
of buttons.

I don't know, how to release a gradient, before i define a new brush.
I testded Erasebackgrd, but it didn't work.

Image

The first time, i used oLbx:Hide()
The user can select, if he wants to use GRADIENTS or a SINGLE-color.
If he wants to use a single color, i hide the 2. browser, because the
color-selection belongs to the 2. GRADIENT-color.
The color-style-browser works like a switch for the 2. color-browser.

Image

It is very difficult, to change GRADIENTS, COLORS, BRUSHES .and. PICTURES at RUNTIME in the same Dialog.
A preview in a extra dialog is no problem. When i cannot solve this
problem ( slowly i getting a bit confused with runtime-preview ),
i have to create a extra dialog for the preview.

That doesn't work at all :
changing the background of the main-window
from a mdi-child-browser-selection

Code: Select all  Expand view  RUN

FUNCTION NEW_COLOR1(oWnd,oCOLOR1)
Local nBrushStyle := 1

*msgalert( CLR_POS1, "1 = Gradient, 2 = Single-color" )
*msgalert( BR_POS1, "Browser-position" )
*msgalert( BR_COLOR1, "Color 1 / Basic " ) 
*msgalert( BR_COLOR2, "Color 2 / for Gradient selected in extra browser" )

// Browser-Selection for Basic-Color
// some predefined colors
// ---------------------------
IF BR_POS1 = 1 // Black
   BR_COLOR1 := 0
   // Color-Control
   // -----------------
   oCOLOR1:SetColor( 16777215, 0 )
ENDIF
IF BR_POS1 = 2  // White
   BR_COLOR1 := 16777215
   oCOLOR1:SetColor( 16777215, 16777215 )
ENDIF
IF BR_POS1 = 3  // Blue
   BR_COLOR1 := 8388608
   oCOLOR1:SetColor( 16777215, 8388608 )
ENDIF
IF BR_POS1 = 4  // Green
   BR_COLOR1 := 32768
   oCOLOR1:SetColor( 16777215, 32768 )
ENDIF
IF BR_POS1 = 5  // Red
   BR_COLOR1 := 128
   oCOLOR1:SetColor( 16777215, 128 )
ENDIF
IF BR_POS1 = 6  // Yellow
   BR_COLOR1 := 65535
   oCOLOR1:SetColor( 16777215, 65535 )
ENDIF
IF BR_POS1 = 7  // Magenta
   BR_COLOR1 := 8388736
   oCOLOR1:SetColor( 16777215, 8388736 )
ENDIF

// defined brushes from browser-pos.
// ----------------------------------------
IF  BR_POS1 = 9
   nBrushStyle := 1
ENDIF
IF  BR_POS1 = 10
   nBrushStyle := 2
ENDIF
IF  BR_POS1 = 11
   nBrushStyle := 3
ENDIF
IF  BR_POS1 = 12
   nBrushStyle := 4
ENDIF
IF  BR_POS1 = 13
   nBrushStyle := 5
ENDIF
IF  BR_POS1 = 14
   nBrushStyle := 6
ENDIF
IF  BR_POS1 = 15
   nBrushStyle := 7
ENDIF
IF  BR_POS1 = 16
   nBrushStyle := 8
ENDIF

// Gradient-Selection
// ------------------------
IF CLR_POS1 = 1                               
   IF BR_POS1 < 9  // predefined colors
       gradpaint1( hDC, oWnd )
   ENDIF
   // No Gradient
   // ---------------
ELSE
   //  Single Color
   // ----------------
   IF BR_POS1 < 9  // predefined colors
      oWnd:SetBrush( TBrush():New(, BR_COLOR1 ) )   
   ELSE
      // Brush-selection
      // ---------------------
      oWnd:SetBrush( TBrush():New(  { "HORIZONTAL","VERTICAL", ;
              "FDIAGONAL","BDIAGONAL", ;
              "CROSS","DIAGCROSS","BORLAND","TILED"}[ nBrushStyle ] ) )
   ENDIF
ENDIF

oWnd:Refresh()

RETURN ( BR_COLOR1 )

// ----- GRADIENT-painting-function for Main-Window ------------

static func gradpaint1( hDC, oWnd )

local aGrad := { { nMOVE1, BR_COLOR1, BR_COLOR2 }, ;
                  { nMOVE1, BR_COLOR2, BR_COLOR1 } } 
       
IF BR_STYLE1 = 1 // Horizontal
      GradientFill( hDC,  0, 0, oWnd:nHeight, oWnd:nWidth, aGrad, .F. )
ELSE
      GradientFill( hDC,  0, 0, oWnd:nHeight, oWnd:nWidth, aGrad, .T. )
ENDIF

RETURN NIL



Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Backgrounds at Runtime

Postby ukoenig » Wed Aug 20, 2008 9:22 pm

Hello,

Here is a small graphic, shows the needed
functions for background-painting at runtime.
I don't know, if everything of the actions is possible.

The red buttons have to change the MDI-window
The green buttons have to change the MDI-child

Image

Green 1 - 4 i have tested at runtime. 1 - 3 works
Green 4 i got only working on DLG INIT

Code: Select all  Expand view  RUN

Green 1
----------
DEFINE BRUSH oImage1 FILE "LOGO.BMP"
SET BRUSH OF oDlg TO oImage1


Green 2     /  BR_COLOR = new Color
------------------------------------------
oDlg:SetBrush( TBrush():New(, BR_COLOR ) )


Green 3    / nBrushStyle = Array-position
---------------------------------------------
oDlg:SetBrush( TBrush():New( { "HORIZONTAL","VERTICAL", ;
      "FDIAGONAL","BDIAGONAL", ;
      "CROSS","DIAGCROSS", ;
      "BORLAND","TILED"}[ nBrushStyle ] ) )

I tested Red 1 like :
-----------------------

oWnd:GetDC()
oImage1 = ReadBitmap( oWnd:hDC, "LOGO.BMP" )
DrawBitmap( oWnd:hDC, oImage1, 0, 0 )
oWnd:ReleaseDC()
DeleteObject( oImage1 )

That doesn't work.



I think, to do some samples for the different actions
and there are no questions anymore.

Regards
Uwe
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Runtime

Postby ukoenig » Thu Aug 21, 2008 10:49 am

Hello,

because all my test to do a previw of the changes at runtime
inside the main-window and dialog, have been a < one way ticket >,
i changed my source, and open a extra preview-window and dialog.
There with ON INIT and ON PAINT for windows and dialog,
everything works like expected. Now it is possible, to show
any combinations of pictures, brushes, gradients and colors between windows and dialog.
In a short time, i can finish the job.

The new WND-Tools will be useful as well for user without FWH-8.07 or 8.08,
because many basic-functions are used in all FWH-versions.

Image

The preview creates the source for you.

Image

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 42 guests

cron