Can a dialog be resized ?
Can a dialog be resized ?
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.
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Resize a dialog to Image-Size
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.
Regards
Uwe
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.

Code: Select all | Expand
// 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

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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Dialog-Size for Images
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
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

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.
i work with FW.
If you have any questions about special functions, maybe i can help.