Changing an image in a Dialog?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
EnderFFX
Pro Scripter
Posts: 92
Joined: Mon Mar 08, 2004 6:17 am

Changing an image in a Dialog?

Post by EnderFFX » Tue Jun 08, 2010 5:41 pm

Is it possible to change an image from one to another image in a Dialog? If so does anyone have a very simple example of this?

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Tue Jun 08, 2010 6:50 pm


User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jun 08, 2010 7:50 pm

For a v12 dialog just use SetDialogProperty.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

EnderFFX
Pro Scripter
Posts: 92
Joined: Mon Mar 08, 2004 6:17 am

Post by EnderFFX » Tue Jun 08, 2010 8:20 pm

mtettmar wrote:For a v12 dialog just use SetDialogProperty.
I have been trying that to no avail. I'll have to see if I can post an example.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Jun 08, 2010 9:43 pm

The trick is figuring out which property to set. I found this by trial and error with the emphasis on error.

We're all in this together. Hope this is helpful.

Code: Select all

ScreenCapture>0,0,200,200,%temp_dir%dialogsample.bmp

Dialog>Dialog1
object Dialog1: TForm
  Left = 10
  Top = 0
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 223
  ClientWidth = 439
  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 = 200
    Height = 200
    LoadImage = ''
  end
end
EndDialog>Dialog1

SetDialogProperty>Dialog1,MSImage1,LoadImage,%temp_dir%dialogsample.bmp

Show>Dialog1,res1

DeleteFile>%temp_dir%dialogsample.bmp





A little bit more elaborate sample, this one actually changes the image.

Code: Select all


Dialog>Dialog1
object Dialog1: TForm
  Left = 400
  Top = 400
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 223
  ClientWidth = 439
  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 = 200
    Height = 200
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,,OnClose,DoClose
SRT>DoClose
  DeleteFile>%temp_dir%dialogsample.bmp
  Exit>0
END>DoClose

Show>Dialog1

Let>xx=0
Let>yy=0

Label>Loop
  Add>xx,1
  Let>tlx=xx
  Let>tly=yy
  Let>lrx=%xx%+200
  Let>lry=%yy%+200
  ScreenCapture>tlx,tly,lrx,lry,%temp_dir%dialogsample.bmp
  SetDialogProperty>Dialog1,MSImage1,LoadImage,%temp_dir%dialogsample.bmp
  Wait>0.01
  If>xx>1000
    GoSub>DoClose
  EndIf
Goto>Loop

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Jun 11, 2010 5:16 pm

Thanks JRL, great example!
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts