Can a dialog be resized ?

Can a dialog be resized ?

Postby HunterEC » Wed Nov 26, 2008 8: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.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41901
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Resize a dialog to Image-Size

Postby ukoenig » 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.

Image

Code: Select all  Expand view

// 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 :lol:
Last edited by ukoenig on Wed Nov 26, 2008 4:11 pm, edited 1 time 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 HunterEC » Wed Nov 26, 2008 4: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.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Dialog-Size for Images

Postby ukoenig » Wed Nov 26, 2008 4: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.
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 49 guests