This is a tough one. I want to be able to display an image (bmp) in a dialog. No big deal, however, there is a catch. If the image is bigger than the area allowed Iwant it to have vertical and horizontal scroll bars.
This is just to view an image so the only option will be to close the Dialog.
Any ideas?
Display Bitmap image in ver 12
Moderators: JRL, Dorian (MJT support)
Hi Keith,
Try using the vbscript by twardega located HERE, to get the Width and Height of the bitmap. Compare those dimensions to the known dimensions of your dialog. If the bitmap is larger, Set the dialog objectproperty Autoscroll to True.
Here is a weak example. Still needs work. But no time to work on it now.
Try using the vbscript by twardega located HERE, to get the Width and Height of the bitmap. Compare those dimensions to the known dimensions of your dialog. If the bitmap is larger, Set the dialog objectproperty Autoscroll to True.
Here is a weak example. Still needs work. But no time to work on it now.
Code: Select all
Input>Image,get bitmap
GetScreenRes>WinX,WinY
VBSTART
Function ImgDimensions (ImgFile)
dim myImg, fs
Set fs= CreateObject("Scripting.FileSystemObject")
If fs.fileExists(ImgFile) Then
Set myImg = Loadpicture(ImgFile)
iWidth = round(myImg.width / 26.4583)
iHeight = round(myImg.height / 26.4583)
Set myImg = nothing
ImgDimensions = iWidth & "X" & iHeight
End If
End Function
VBEND
VBEval>ImgDimensions("%Image%"),Dims
Separate>dims,X,dim
Dialog>Dialog1
object Dialog1: TForm
Left = 277
Top = 270
Width = 450
Height = 450
HelpContext = 5000
AutoScroll = False
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
Color = clWhite
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSImage1: tMSImage
Left = 2
Top = 2
Width = 500
Height = 500
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,,onclose,Quit
SetDialogProperty>Dialog1,MSImage1,Width,WinX
SetDialogProperty>Dialog1,MSImage1,Height,WinY
SetDialogProperty>Dialog1,MSImage1,LoadImage,%image%
If>{(%Dim_1%>450)or(%dim_2%>450)}
SetDialogProperty>Dialog1,,AutoScroll,True
EndIf
Show>dialog1
Label>Loop
Wait>0.01
Goto>Loop
SRT>Quit
Exit>0
END>Quit
Bitmap in Dialog
Thanks,
Now for another question:
I have a Button on it to close it. Naturally, when you use the Scroll bars the button moves. Next thing you know it is out of sight. I have played with a couple of options and cannot seem to figure out how to make it stay in the same locaiton. In other words, anchor it in relation to the bottom right corner of the Dialog regardless of where the image is when using the vertical or horizontal scroll bars. I'm sure there is a way but I am thinking it must be more than one setting that needs to be changed.
Any ideas?
Now for another question:
I have a Button on it to close it. Naturally, when you use the Scroll bars the button moves. Next thing you know it is out of sight. I have played with a couple of options and cannot seem to figure out how to make it stay in the same locaiton. In other words, anchor it in relation to the bottom right corner of the Dialog regardless of where the image is when using the vertical or horizontal scroll bars. I'm sure there is a way but I am thinking it must be more than one setting that needs to be changed.
Any ideas?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You can just use the image's AutoSize property and the form's AutoScroll property without needing to know the dimensions of the bitmap:
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 420
Top = 118
Width = 447
Height = 250
HelpContext = 5000
AutoScroll = True
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSImage1: tMSImage
Left = 0
Top = 0
Width = 105
Height = 105
AutoSize = True
end
end
EndDialog>Dialog1
SetDialogProperty>Dialog1,MSImage1,LoadImage,%SCRIPT_DIR%\large.bmp
Show>Dialog1,r
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Stationary Button
Yes, I just tried that, it works similar to the example from JRL but how do I put a stationary button on it so when the user scrolls the button remains in place.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Unfortunately because the whole form is scrolling the button will move also.
This is a candidate for a new object - a ScrollBox - which would allow us to make only a portion of the dialog scrollable.
In the mean time, a workaround might be that you could put a panel at the top and set it's align property to alTop, and have a button on the left of it. That would then stay stationary. Anywhere else and it could disappear out of view but since everything is relative to the upper left corner, having it top left would make it always visible:
This is a candidate for a new object - a ScrollBox - which would allow us to make only a portion of the dialog scrollable.
In the mean time, a workaround might be that you could put a panel at the top and set it's align property to alTop, and have a button on the left of it. That would then stay stationary. Anywhere else and it could disappear out of view but since everything is relative to the upper left corner, having it top left would make it always visible:
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 392
Top = 182
Width = 447
Height = 250
HelpContext = 5000
AutoScroll = True
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSImage1: tMSImage
Left = 0
Top = 0
Width = 105
Height = 105
AutoSize = True
end
object Panel1: TPanel
Left = 165
Top = 24
Width = 185
Height = 41
Align = alTop
TabOrder = 0
object MSButton1: tMSButton
Left = 11
Top = 7
Width = 75
Height = 25
Caption = 'Close'
DoubleBuffered = True
ParentDoubleBuffered = False
TabOrder = 0
DoBrowse = False
BrowseStyle = fbOpen
end
end
end
EndDialog>Dialog1
SetDialogProperty>Dialog1,MSImage1,LoadImage,%SCRIPT_DIR%\large.bmp
Show>Dialog1,r
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Here's a way to do it under current object availability. (Isn't there always a way?)
AND... this is not particularly painful even though its not automatic.
This uses Marcus' idea for autoscroll and autosize
You need to use a non-modal dialog. In the idle loop you keep moving the button to its predefined (dialog block) position.
I was happy to discover that the coordinates supplied to MoveWindow> are tied to the parent window and not to the screen so there is no calculation needed to keep the button properly located
AND... this is not particularly painful even though its not automatic.
This uses Marcus' idea for autoscroll and autosize
You need to use a non-modal dialog. In the idle loop you keep moving the button to its predefined (dialog block) position.
I was happy to discover that the coordinates supplied to MoveWindow> are tied to the parent window and not to the screen so there is no calculation needed to keep the button properly located
Code: Select all
Input>Image,get bitmap
Dialog>Dialog1
object Dialog1: TForm
Left = 841
Top = 169
Width = 499
Height = 440
HelpContext = 5000
AutoScroll = True
BorderIcons = [biSystemMenu]
Caption = 'Keith Image Display'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSImage1: tMSImage
Left = 0
Top = 0
Width = 105
Height = 105
AutoSize = True
end
object MSButton1: tMSButton
Left = 212
Top = 361
Width = 75
Height = 25
Caption = 'Close'
DoubleBuffered = True
ParentDoubleBuffered = False
TabOrder = 0
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>Dialog1
SetDialogProperty>Dialog1,MSImage1,LoadImage,%image%
AddDialogHandler>Dialog1,MSButton1,OnClick,Quit
AddDialogHandler>Dialog1,,OnClose,Quit
GetDialogProperty>Dialog1,MSButton1,Left,ButtonX
GetDialogProperty>Dialog1,MSButton1,Top,ButtonY
SRT>Quit
Exit>0
END>Quit
Show>Dialog1
Label>Loop
Let>Win_usehandle=1
MoveWindow>Dialog1.MSButton1.handle,ButtonX,ButtonY
Wait>0.01
Goto>Loop