FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Can a dialog be resized ?
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Can a dialog be resized ?
Posted: Wed Nov 26, 2008 08:04 AM

I need to resize a dialog that is displaying an image. If the user selects to stretch the current image or display another one with different size, then the dialog changes it size to the new one. Can this be done ? Thank you.

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Can a dialog be resized ?
Posted: Wed Nov 26, 2008 10:08 AM

Gustavo,

oDlg:SetSize( nNewWidth, nNewHeight )

or simply:

oDlg:nWidth := ...
oDlg:nHeight := ...

With oDlg:SetSize() you do it in one single step.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Resize a dialog to Image-Size
Posted: Wed Nov 26, 2008 11:02 AM
Hello HunterEC,
Your question is : the dialog resized to the Image-size.
Shows this Screenshot, what you want to do ?
The Preview of the real Alpha-Channel-BMP,
is shown in a adjusted Dialog in relation to the Image-size.



// The Dialog-Button to Show a adjusted-Dialog
// -----------------------------------------------------------

REDEFINE BUTTONBMP oBtn12  ID 75 OF oDlg3 ;
ACTION ( ALPHA_IMG(oDlg3, cImage) ) ; 
BITMAP "preview" PROMPT "       &Alpha-Channel" TEXTRIGHT
oBtn12:cTooltip =  { "Preview" + CRLF + ;
                                "Alpha-Channel","Preview", 1, CLR_BLACK, 14089979 } 


// ------------ Image-Resource in Folder for normal Preview 
// ------------on Record-change in xBrowse => oBMP10:Refresh() -----


REDEFINE BITMAP oBMP10  ID 210  ADJUST  RESOURCE "Blanc"  OF oFolder:aDialogs[1] UPDATE
oBMP10:bPainted := {|hDC| DRAW_IMG1( oBMP10, cIMAGE ) }


// ------------  IMAGE - Preview in Folder -----------------------------------

FUNCTION DRAW_IMG1( oBitmap, cBitmap)

DEFINE IMAGE oImage FILENAME "&c_Path\" + ALLTRIM(cSUBDIR) + cBitmap 

// Image-Size adjusted to BMP-resource in Folder 
// If the Image is bigger, it is reduced to the < TBitmap-Resource > size
// --------------------------------------------------------------------------------
aRect := GETCLIENTRECT( oBitmap:hWnd )
hDC := oBitmap:GETDC()

IF nWIDTH < aRect[4] .and. nHEIGHT < aRect[3] 
	PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , nWIDTH, nHEIGHT ) 
ENDIF

IF nWIDTH > aRect[4] .and. nHEIGHT <= aRect[3] 
     nNewproz := ( aRect[4] / nWIDTH ) * 100
	nNewHeight := ( nHEIGHT / 100 ) * nNewproz
	PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , aRect[4], nNewHeight ) 
ENDIF

IF nWIDTH <= aRect[4] .and. nHEIGHT > aRect[3] 
	nNewproz := ( aRect[4] / nHEIGHT ) * 100
	nNewWidth := ( nWIDTH / 100 ) * nNewproz
	PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , nNewWidth, aRect[3]  ) 
ENDIF

IF nWIDTH > aRect[4] .and. nHEIGHT > aRect[3] 
	nNewprozW := ( aRect[4] / nWIDTH ) * 100
	nNewprozH  := ( aRect[4] / nHEIGHT ) * 100
	nNewWidth := ( nWIDTH / 100 ) * nNewprozW
	nNewHeight := ( nHEIGHT / 100 ) * nNewprozW
	PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , nNewWidth, nNewHeight ) 
ENDIF

lRESIZE := .F.

ReleaseDC(hDC)

RETURN( NIL )

// ------------ ALPHA- IMAGE  ( Dialog adjusted to Image ) ------------
//------------- give a little bit space around the Image ----------
// nHEIGHT + 50, nWIDTH + 40 
// take care of the Dialog-border : ABPaint( hDC, 10, 10 ......

FUNCTION ALPHA_IMG(oDlg3, cBitmap)
Local oDlg, oBmp, oBrush, oBtn

// nHeight = Image-Height
// nWidth := Image-Width

DEFINE BRUSH oBrush STYLE "BORLAND"
DEFINE BITMAP oBmp FILENAME "&c_Path\" + ALLTRIM(cSUBDIR) + cBITMAP 

DEFINE DIALOG oDlg FROM 35, 20 TO  nHEIGHT + 50, nWIDTH + 40 ;
     OF oDlg3 COLOR 0, "N/W" BRUSH oBrush ;
    TITLE  "BMP with Alpha-Channel"  PIXEL 

ACTIVATE DIALOG oDlg ;
ON PAINT ABPaint( hDC, 10, 10, oBmp:hBitmap, 220 ) 

oBrush:End()
oBmp:End()

RETURN( NIL )


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.
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Can a dialog be resized ?
Posted: Wed Nov 26, 2008 04:06 PM

Antonio, Ukoenig:

Thank you very much for your help. Seems that both of your answers are what I'm looking for. I'll give it a try.

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Dialog-Size for Images
Posted: Wed Nov 26, 2008 04:16 PM

Hello HunterEC,

to define the dialog-size, You have to use the Image-size
with a bit space around, like shown in the sample.
The array < aRect > will give You the size you need :
nWIDTH = aRect[4], nHEIGHT = aRect[3]

// Image-Size in Dialog-resource
// ---------------------------------------
aRect := GETCLIENTRECT( oBitmap:hWnd )
hDC := oBitmap:GETDC()

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.

Continue the discussion