Dynamic scroll in a Dialog Box?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

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

Dynamic scroll in a Dialog Box?

Post by JRL » Tue May 29, 2012 5:01 pm

Anyone figure out how to get a dialog box to scroll dynamically?

I want to be able to see the objects move as I move the dialog scroll bar similar to what happens when you scroll the list box in the script below.

I have discovered you can put objects in the list box and they will scroll. But they will not show up if they are below the displayed text.

Any thoughts?

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 454
  Top = 181
  Width = 400
  Height = 300
  HelpContext = 5000
  AutoScroll = True
  BorderIcons = [biSystemMenu]
  Caption = 'Parts Not Found'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSListBox1: tMSListBox
    Left = 26
    Top = 18
    Width = 327
    Height = 203
    ItemHeight = 13
    Items.Strings = (
      '1'
      '2'
      '3'
      '4'
      '5'
      '6'
      '7'
      '8'
      '9'
      '10'
      '11'
      '12'
      '13'
      '14'
      '15'
      '16'
      '17'
      '18'
      '19'
      '20'
      '21'
      '22'
      '23'
      '24'
      '25')
    TabOrder = 0
    Text = 
      '1'#13#10'2'#13#10'3'#13#10'4'#13#10'5'#13#10'6'#13#10'7'#13#10'8'#13#10'9'#13#10'10'#13#10'11'#13#10'12'#13#10'13'#13#10'14'#13#10'15'#13#10'16'#13#10'17'#13#10'18'#13#10'1' +
      '9'#13#10'20'#13#10'21'#13#10'22'#13#10'23'#13#10'24'#13#10'25'#13#10
    SelectedIndex = -1
  object MSButton1: tMSButton
    Left = 121
    Top = 74
    Width = 75
    Height = 25
    Caption = 'MSButton1'
    TabOrder = 9
  end
  end
  object MSButton2: tMSButton
    Left = 121
    Top = 374
    Width = 75
    Height = 25
    Caption = 'MSButton1'
    TabOrder = 9
  end
end
EndDialog>Dialog1

Show>Dialog1,

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue May 29, 2012 5:18 pm

Hi JRL.

Not sure if I understand your question. No time to run your script now, but here are some thoughts I had. Rather than using scroll bar, add a button. Have the button run a subroutine that loops, changing the position properties of each of the objects. You will probably need two buttons, one each for Up/Down. Would have to build in some type of adjustable delay to slow the visual down. Maybe change the positions by increments of 10 or larger vs. 1
but that would not have a smooth appearance.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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

Post by JRL » Tue May 29, 2012 5:26 pm

Bob,

Thanks for the response. Sounds to me like you understood the question perfectly.

I had already thought about doing something like what you've suggested and might still try it if this probe doesn't yield a better answer. I might have thousands of objects and I think the calculations required to control them through movement may take too long, even though essentially, that's what the underlying program is doing.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue May 29, 2012 9:10 pm

OK, so rather than scrolling object by object, could you create some "bookmarks", choose from a picklist of the destination bookmark, and just move those items in that bookmark block to the top? Probably need to record initial location to they can all be restored when done with that area. Maybe make the normal top objects invisible vs. moving them, then restore visibility when done.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue May 29, 2012 9:15 pm

Or, how about making multiple Dialogs in the same position, and just toggle their visibility, have a "start scroll" button, and "stop here" button with a pause long enough for the operator to select. (Maybe Prev/Next Top/Bottom buttons also?)
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Tue May 29, 2012 11:41 pm

This is the best I can come up with on the fly.

I hope it helps.

Code: Select all



Dialog>Dialog1
object Dialog1: TForm
  Left = 511
  Top = 172
  Width = 400
  Height = 486
  HelpContext = 5000
  AutoScroll = True
  BorderIcons = [biSystemMenu]
  Caption = 'Parts Not Found'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSListBox1: tMSListBox
    Left = 0
    Top = 0
    Width = 327
    Height = 297
    ItemHeight = 13
    Items.Strings = (
      ' '
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' '
      ''
      ' '
      ' '
      ' '
      ' ')
    TabOrder = 0
    Text = 
      ' '#13#10' '#13#10' '#13#10' '#13#10' '#13#10#13#10' '#13#10' '#13#10' '#13#10' '#13#10#13#10' '#13#10' '#13#10' '#13#10' '#13#10#13#10' '#13#10' '#13#10' '#13#10' '#13#10#13#10' '#13#10' '#13 +
      #10' '#13#10' '#13#10#13#10' '#13#10' '#13#10' '#13#10' '#13#10#13#10' '#13#10' '#13#10' '#13#10' '#13#10#13#10' '#13#10' '#13#10' '#13#10' '#13#10#13#10' '#13#10' '#13#10' '#13#10' '#13#10#13 +
      #10' '#13#10' '#13#10' '#13#10' '#13#10#13#10' '#13#10' '#13#10' '#13#10' '#13#10#13#10' '#13#10' '#13#10' '#13#10' '#13#10#13#10' '#13#10' '#13#10' '#13#10' '#13#10
    SelectedIndex = -1
    object Panel1: TPanel
      Left = 0
      Top = 0
      Width = 306
      Height = 900
      BevelOuter = bvNone
      Caption = 'Panel1'
      Color = 15987699
      ParentBackground = False
      TabOrder = 0
      object MSButton1: tMSButton
        Left = 17
        Top = 9
        Width = 75
        Height = 25
        Caption = 'MSButton1'
        TabOrder = 0
        DoBrowse = False
        BrowseStyle = fbOpen
      end
      object MSButton2: tMSButton
        Left = 57
        Top = 300
        Width = 75
        Height = 25
        Caption = 'MSButton1'
        TabOrder = 1
        DoBrowse = False
        BrowseStyle = fbOpen
      end
    end
  end
end
EndDialog>Dialog1

SetDialogObjectFocus>Dialog1,MSButton1
Show>Dialog1,r


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

Post by JRL » Tue May 29, 2012 11:46 pm

Thanks for the responses.

I have something pretty much the same I've been testing. Works for 100 items but if I move to 1000 I get a blank dialog if I try to scroll through too fast.

Code: Select all

Let>Limit=100

Let>list=;
Let>List2=
Let>kk=0
Repeat>kk
  Add>kk,1
  Random>%limit%,res
  Concat>List,%res%;
  Concat>list2,''#13#10 +%crlf%
Until>kk=%limit%

Concat>list2,''

Let>DFile=%temp_Dir%Scrolling Demo Dialog.scp
IfFileExists>DFile
  DeleteFile>DFile
EndIf

WriteLn>DFile,wres,Dialog>Dialog1
WriteLn>DFile,wres,object Dialog1: TForm  Caption = 'Numbers not found' Position = poScreenCenter AutoSize = True
WriteLn>DFile,wres,object Label1: TLabel Left = 8 Top = 4 Width = 32 Height = 13 Caption = 'Line' end
WriteLn>DFile,wres,object Label2: TLabel Left = 58 Top = 4 Width = 32 Height = 13 Caption = 'Match' end
WriteLn>DFile,wres,object Label3: TLabel Left = 108 Top = 4 Width = 32 Height = 13 Caption = 'Qty' end
WriteLn>DFile,wres,object MSListBox1: tMSListBox Left = 0 Top = 30 Width = 170 Height = 400 BorderStyle = bsNone Text = %List2%
WriteLn>DFile,wres,  Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -17 Font.Name = 'MS Sans Serif' Font.Style = []


Let>EBR=0
Repeat>EBR
  Add>EBR,1
    WriteLn>DFile,wres,object Panel_%EBR%_1: tPanel
    Let>Y_Value={(%EBR%*20)-20}
    WriteLn>DFile,wres,Top = %Y_value%
    WriteLn>DFile,wres,Left = 0
    WriteLn>DFile,wres,Width = 50
    WriteLn>DFile,wres,Height = 20
    WriteLn>DFile,wres,Alignment = taLeftJustify
    WriteLn>DFile,wres,Caption = '%EBR%'
    WriteLn>DFile,wres,End
    
    Separate>List,;%EBR%;,found
    

   
    WriteLn>DFile,wres,object Panel_%EBR%_2: tPanel
    WriteLn>DFile,wres,Top = %Y_value%
    WriteLn>DFile,wres,Left = 50
    WriteLn>DFile,wres,Width = 50
    WriteLn>DFile,wres,Height = 20
    WriteLn>DFile,wres,Alignment = taLeftJustify
    If>%found_count%>1
      WriteLn>DFile,wres,Caption = '%EBR%'
      WriteLn>DFile,wres,Color = 12639424
    Else
      WriteLn>DFile,wres,Caption = 'N/A'
      WriteLn>DFile,wres,Color = 8946874
    EndIf
    WriteLn>DFile,wres,End
    
    WriteLn>DFile,wres,object Panel_%EBR%_3: tPanel
    WriteLn>DFile,wres,Top = %Y_value%
    WriteLn>DFile,wres,Left = 100
    WriteLn>DFile,wres,Width = 70
    WriteLn>DFile,wres,Height = 20
    WriteLn>DFile,wres,Alignment = taLeftJustify
    Let>value={%found_count%-1}
    WriteLn>DFile,wres,Caption = '%value%'
    WriteLn>DFile,wres,End
    
    Let>found_count=0
Until>EBR=%limit%
WriteLn>DFile,wres,end
WriteLn>DFile,wres,end
WriteLn>DFile,wres,EndDialog>Dialog1

Include>Dfile

Show>Dialog1,

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Tue May 29, 2012 11:47 pm

I made a few adjustments to my original example.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Tue May 29, 2012 11:53 pm

I'm trying your example now. I've changed it to 1000. It's taking a long time :? I let you know what's going on when it's done loading.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed May 30, 2012 12:17 am

I have the same problem compiled or not. The objects disappear as soon as I scroll too fast.

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

Post by JRL » Wed May 30, 2012 6:16 am

I might have thousands of objects and I think the calculations required to control them through movement may take too long, even though essentially, that's what the underlying program is doing.

Not to mention the positioning might just fail.


The underlying program calculating positions is losing track of the objects when there are 1000 rows of them.

You can observe this by running the program I posted above with the "limit" variable set to 1000. After the dialog displays, close the program, then go to your temp folder and edit the script (that should be there) named ScrollingDemoDialog.scp

the last four lines of ScrollingDemoDialog.scp should be:

End
end
end
EndDialog>Dialog1

replace those four lines with:

Code: Select all

End
end
  object MSButton1: tMSButton
    Left = 190
    Top = 10
    Width = 75
    Height = 25
    Caption = 'Check'
  end
    object MSButton2: tMSButton
    Left = 190
    Top = 40
    Width = 75
    Height = 25
    Caption ='Reposition'
  end
end
EndDialog>Dialog1

AddDialogHandler>dialog1,msbutton1,OnClick,check
AddDialogHandler>dialog1,msbutton2,OnClick,reposition
AddDialogHandler>dialog1,,OnClose,Quit

Show>dialog1

Label>Loop
  Let>WIN_USEHANDLE=1
  MoveWindow>Dialog1.panel_1_1,0,0
Goto>Loop

SRT>check
  GetDialogProperty>Dialog1,Panel_1_1,top,ypos
  GetDialogProperty>Dialog1,Panel_1_1,left,xpos
  SetDialogProperty>Dialog1,label1,caption,%xpos% %ypos%
END>check

SRT>reposition
  SetDialogProperty>Dialog1,Panel_1_1,top,0
  SetDialogProperty>Dialog1,Panel_1_1,left,0
END>reposition

SRT>Quit
  Exit>0
END>Quit
Then run ScrollingDemoDialog.scp. The two added buttons let you look at and reset the position of the number one panel. You'll find that when it disappears its position is way off.

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

Post by JRL » Wed May 30, 2012 3:24 pm

So it appears that hijacking the scroll functionality of the listbox object won't work so I'm back to asking my original question.

Anyone figure out how to get a dialog box to scroll dynamically?

Perhaps a little more detail on why I'm doing this. I often acquire information from our database and manipulate then display it. I usually paste the data into Excel for display. I'm trying to eliminate the Excel component of the process.


Hmmmmmmm
Typing is like talking... sometimes discussing things is inspirational. The act of typing this has given me a couple of other ideas to test. I'll be back.

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

Post by JRL » Thu May 31, 2012 11:30 pm

Still don't know if there is a way to get the standard dialog box to scroll smoothly but the following script uses HTA to emulate a grid object. It will work for what I need. Thanks to all who looked at this.

Edit - 06/08/2012

Added comments to the script below. The script invents some data using random numbers then displays that data in an html table. The table is displayed using hta then the hta window is acquired by the Macro Scheduler dialog.

The left hand column cell information can be handled via a double click on a left hand column cell. In this script the cell information is displayed in a message box.

See the comments for more detail.

Code: Select all


//A file to contain the value of the cell a user double clicks
Let>HTAReadFile=%temp_dir%HTA_Data_File.txt

//If for some unforseen reason the above file already exists, delete it
IfFileExists>HTAReadFile
  DeleteFile>HTAReadFile
EndIf

//The moment the above file exists process "GetPageData" subroutine
OnEvent>file_Exists,HTAReadFile,0,GetPageData

//"GetPageData" subroutine can do whatever it needs to do to process the data
//from the cell the user double clicked.  In this sample the above file
//is read then deleted and the file (cell) contents display in a message box.
SRT>GetPageData
  ReadLn>HTAReadFile,1,line
  DeleteFile>HTAReadFile
  MDL>Line
END>GetPageData

//Upper and lower limits for the random number count that is the procees
//creating the demo data.
Let>LowerLimit=10000000
Let>UpperLimit=10001000

//A dialog to contain the hta dialog.  Though the hta dialog could be built to stand
//alone.  The purpose for creating this script was to demonstrate a way to
//display a useful grid in a Macro Scheduler dialog.
Dialog>Dialog1
object Dialog1: TForm
  BorderIcons = [biSystemMenu]
  Caption = 'List'
  ClientHeight = 330
  ClientWidth = 210
  Position = poScreenCenter
  Color = 16777215
  object Label1: TLabel
    Left = 16
    Top = 8
    Width = 63
    Height = 24
    Caption = 'Line       Match   Qty'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -16
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentFont = False
  end
End
EndDialog>Dialog1


//A loop to generate random data that can be displayed for demo purposes
Let>list=;
Let>kk=LowerLimit
Repeat>kk
  Add>kk,1
  Random>{%UpperLimit%-%LowerLimit%},res
  Let>res={%LowerLimit%+%res%+1}
  Concat>List,%res%;
Until>kk=%UpperLimit%

//A file to contain the hta dialog definition that is created using Macro Scheduler
Let>HTA_File=%temp_dir%Random_List.hta
IfFileExists>HTA_File
  DeleteFile>HTA_File
EndIf

//HTA header information
//A good hta site: http://technet.microsoft.com/en-us/library/ee692926.aspx
  WriteLn>%HTA_File%,wres,<title>~DataListBoxViaHTA~</title>
  WriteLn>%HTA_File%,wres,<HTA:APPLICATION
  WriteLn>%HTA_File%,wres,Caption = "no"
  WriteLn>%HTA_File%,wres,SCROLL="yes"
  WriteLn>%HTA_File%,wres,INNERBORDER="no"/>
//VBScript that runs when a user double clicks a cell
//the script writes to the "HTAReadFile" file
  WriteLn>%HTA_File%,wres,  <SCRIPT Language="VBScript">
  WriteLn>%HTA_File%,wres,Sub MakeFile (makefiletext)
  WriteLn>%HTA_File%,wres,  set outFile = CreateObject("Scripting.FileSystemObject").CreateTextFile("%HTAReadFile%")
  WriteLn>%HTA_File%,wres,  outFile.writeline makefiletext
  WriteLn>%HTA_File%,wres,End Sub
///////////////////  VBScript end  ///////////////////
  WriteLn>%HTA_File%,wres,window.resizeTo 210,300
  WriteLn>%HTA_File%,wres,window.moveTo -10100, 100
  WriteLn>%HTA_File%,wres,</SCRIPT>
  WriteLn>%HTA_File%,wres,<Body>
  WriteLn>%HTA_File%,wres,<table border="1" style='border-collapse: collapse' bordercolor='#111111' width='100%' id='Table1'>

Let>EBR=LowerLimit
Repeat>EBR
  Add>EBR,1
  Separate>list,;%EBR%;,found
  Sub>found_count,1
  If>%Found_Count%>0
    If>%Found_Count%>3
//In the following three "WritLn>" lines
//                                    ondblclick=MakeFile("Whatever is in these paranthsis gets written to 'HTAReadFile'")
      WriteLn>%HTA_File%,wres,<tr><td ondblclick=MakeFile("%EBR%")>%EBR%</td><td style="width:55px" bgcolor="#C0DCC0">Yes</td><td style="width:20px" bgcolor="#92A8C1"> %found_count% </td></tr>
    Else
      WriteLn>%HTA_File%,wres,<tr><td ondblclick=MakeFile("%EBR%")>%EBR%</td><td style="width:55px" bgcolor="#C0DCC0">Yes</td><td style="width:20px"> %found_count% </td></tr>
    EndIf
  Else
    WriteLn>%HTA_File%,wres,<tr><td ondblclick=MakeFile("%EBR%")>%EBR%</td><td style="width:55px" bgcolor="#BA8488"> None </td><td style="width:20px"> %found_count% </td></tr>
  EndIf
Until>EBR=%UpperLimit%

WriteLn>%HTA_File%,wres,</table>
WriteLn>%HTA_File%,wres,</Body>

//Run the hta file
ExecuteFile>HTA_File

//Wait for the hta dialog to open.  When it opens use the "SetParent" API
//to make it a part of the Macro Scheduler dialog.  Position the hta dialog
//within the Macro Scheduler dialog as needed using MoveWindow and the hta
//dialog's handle.  Note that the MoveWindow coordinates are relative to the
//Macro Scheduler dialog. 
WaitWindowOpen>~DataListBoxViaHTA~
GetWindowHandle>~DataListBoxViaHTA~,DLBhndl
LibFunc>User32,SetParent,SPRes,DLBhndl,Dialog1.handle
Let>WIN_USEHANDLE=1
  MoveWindow>DLBhndl,0,30
Let>WIN_USEHANDLE=0

Show>Dialog1,















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