Cursor for HTMLViewer isn't working

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Cursor for HTMLViewer isn't working

Post by Grovkillen » Mon Sep 27, 2021 8:58 am

See this example here:

Code: Select all


Dialog>Dialog1
object Dialog1: TForm
  Left = -159
  Top = 1305
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 211
  ClientWidth = 476
  Color = clBtnFace
    Cursor = crHandPoint
  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 MSHTMLViewer1: tMSHTMLViewer
    Left = 199
    Top = 50
    Cursor = crHandPoint
    TabOrder = 8
    BorderStyle = htFocused
    DefFontName = 'Times New Roman'
    DefPreFontName = 'Courier New'
    DefBackground = clLime
    HistoryMaxCount = 0
    NoSelect = False
    PrintMarginBottom = 2.000000000000000000
    PrintMarginLeft = 2.000000000000000000
    PrintMarginRight = 2.000000000000000000
    PrintMarginTop = 2.000000000000000000
    PrintScale = 1.000000000000000000
  end
end
EndDialog>Dialog1

show>dialog1,r


Let>ME=%Script%

Running: 15.0.19b
version history

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 972
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Cursor for HTMLViewer isn't working

Post by Dorian (MJT support) » Mon Sep 27, 2021 9:17 am

When I move my mouse over the green square my cursor changes from the hand to the arrow.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Cursor for HTMLViewer isn't working

Post by Grovkillen » Mon Sep 27, 2021 11:09 am

Yes but I have set it to use the hand as well.
Let>ME=%Script%

Running: 15.0.19b
version history

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

Re: Cursor for HTMLViewer isn't working

Post by Marcus Tettmar » Mon Sep 27, 2021 12:44 pm

If you set the HTML of the HTMLViewer and put some text in it you'll notice the cursor changes to the hand pointer when you move over the text. It works with other visible objects too. So it seems you need a visible HTML element in the HTML for the cursor to change.

I tried setting the css cursor property at the body level of the page but it still only changes it when there is some text or e.g. an image.

Your example has no content so perhaps this issue will go away when you add content. Though not sure what you want to do ultimately ....
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Cursor for HTMLViewer isn't working

Post by Grovkillen » Mon Sep 27, 2021 1:27 pm

Ah, thanks for the pointers (pun intended ;) ) !!

Here's a little hack of what I'm trying to do:

Code: Select all


Let>PERCENT=%
Let>BORDER_WIDTH=5px
Let>BORDER_COLOR=limegreen
Let>TEXT_COLOR=white
Let>BACKGROUND_COLOR=black

Dialog>MAIN_DIALOG
object MAIN_DIALOG: TForm
  BorderStyle = bsNone
  ClientHeight = 38
  ClientWidth = 175
  Color = clLime
  TransparentColor = True
  TransparentColorValue = clLime
  object EXAMPLE_BUTTON: tMSHTMLViewer
    Left = -10
    Top = -5
    Height = 50
    Width = 200
    DefBackground = clLime
    Cursor = crHandPoint
  end
end
EndDialog>MAIN_DIALOG

LabelToVar>HTML_CODE_simple_button,EXAMPLE_BUTTON_html,0,0,*/
SetDialogProperty>MAIN_DIALOG,EXAMPLE_BUTTON,HTML,EXAMPLE_BUTTON_html
AddDialogHandler>MAIN_DIALOG,EXAMPLE_BUTTON,OnMouseUp,CLOSE_APP

Show>MAIN_DIALOG

Label>MainLoopStart
Wait>0.25
Goto>MainLoopStart


SRT>CLOSE_APP
  Exit>
END>CLOSE_APP

/*
HTML_CODE_simple_button:
<div style="
  border-style: solid;
  border-width: %BORDER_WIDTH%px;
  border-color: %BORDER_COLOR%;
  background:   %BACKGROUND_COLOR%;
  color:        %TEXT_COLOR%;
  overflow:     hidden;
  height:       25px;
  width:        94%PERCENT%;
  height:       97%PERCENT%;
  font-size:    22px;
  font-family:  Arial, Helvetica, sans-serif;
  ">
    <img src="icon\downloadAnyPngAndPlaceHere.png" style="width:25px;height:25px;margin-top:3px;margin-bottom:-25px;">
    <div style="height:25px;margin-top:-1px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Terminate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
  </div>
*/
Let>ME=%Script%

Running: 15.0.19b
version history

User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Cursor for HTMLViewer isn't working

Post by Grovkillen » Mon Sep 27, 2021 2:43 pm

And here's an updated POC:

Code: Select all


Let>PERCENT=%
Let>BORDER_WIDTH=5px
Let>BORDER_COLOR=limegreen
Let>BACKUP_BORDER_COLOR=BORDER_COLOR
Let>TEXT_COLOR=white
Let>BACKGROUND_COLOR=black
Let>BUTTON_WIDTH=300
Let>BUTTON_HEIGHT=50
Let>END_OF_CODE=/*

Dialog>MAIN_DIALOG
object MAIN_DIALOG: TForm
  BorderStyle = bsNone
  ClientHeight = 88
  ClientWidth = 175
  Color = clLime
  TransparentColor = True
  TransparentColorValue = clLime
  object BUTTON_1: tMSHTMLViewer
    Left = -10
    Top = -5
    Height = 1
    Width = 1
    DefBackground = clLime
    Cursor = crHandPoint
  end
  object BUTTON_2: tMSHTMLViewer
    Left = -10
    Top = 40
    Height = 1
    Width = 1
    DefBackground = clLime
    Cursor = crHandPoint
  end
end
EndDialog>MAIN_DIALOG


GoSub>SETUP_BUTTON,{"1"},{"close"},{"Terminate"},{"CLOSE_APP"}
GoSub>SETUP_BUTTON,{"2"},{"message"},{"Hello!"},{"SEND_MESSAGE"}

Show>MAIN_DIALOG

Label>MainLoopStart
Wait>0.25
GoSub>CHECK_HOVERED_OBJECTS
Goto>MainLoopStart

SRT>CHECK_HOVERED_OBJECTS
  Timer>CURRENT_timer
  Let>k=0
  Repeat>k
    Let>k=k+1
    If>BUTTON_%k%_HOVERED=True
      Let>TIMER_diff=CURRENT_timer-TIMER_%k%
      If>TIMER_diff>500
        Let>TEXT_COLOR=white
        Let>BORDER_COLOR=BACKUP_BORDER_COLOR
        Let>TEMP_icon=BUTTON_%k%_ICON
        Let>TEMP_text=BUTTON_%k%_TEXT
        LabelToVar>HTML_CODE_simple_button,TEMP_html,0,0,END_OF_CODE
        SetDialogProperty>MAIN_DIALOG,BUTTON_%k%,HTML,TEMP_html
        Let>BUTTON_%k%_HOVERED=False
      Endif>
    Endif>
  Until>k=2
END>CHECK_HOVERED_OBJECTS

SRT>UPDATE_TIMER
  Timer>CURRENT_timer
  Let>TIMER_%UPDATE_TIMER_Var_1%=CURRENT_timer
  If>BUTTON_%UPDATE_TIMER_Var_1%_HOVERED=False
    Let>BUTTON_%UPDATE_TIMER_Var_1%_HOVERED=True
    Let>BORDER_COLOR=TEXT_COLOR
    Let>TEMP_icon=BUTTON_%UPDATE_TIMER_Var_1%_ICON
    Let>TEMP_text=BUTTON_%UPDATE_TIMER_Var_1%_TEXT
    LabelToVar>HTML_CODE_simple_button,TEMP_html,0,0,END_OF_CODE
    SetDialogProperty>MAIN_DIALOG,BUTTON_%UPDATE_TIMER_Var_1%,HTML,TEMP_html
  Endif>
END>UPDATE_TIMER

SRT>BUTTON_CLICKED
  Let>BUTTON_LAST_CLICKED=BUTTON_CLICKED_Var_1
  Let>SUB_ROUTINE=SUB_
  ConCat>SUB_ROUTINE,%BUTTON_CLICKED_Var_2%
  UpperCase>SUB_ROUTINE,SUB_ROUTINE
  GoSub>%SUB_ROUTINE%,%BUTTON_CLICKED_Var_1%
END>BUTTON_CLICKED

SRT>SUB_CLOSE_APP
  Exit>
END>SUB_CLOSE_APP

SRT>SUB_SEND_MESSAGE
  Message>SUB_SEND_MESSAGE_Var_1
END>SUB_SEND_MESSAGE

SRT>SETUP_BUTTON
  Let>TEMP_number=SETUP_BUTTON_Var_1
  Let>BUTTON_%TEMP_number%_HOVERED=False
  Let>TEMP_icon=SETUP_BUTTON_Var_2
  Let>BUTTON_%TEMP_number%_ICON=TEMP_icon
  Let>TEMP_text=SETUP_BUTTON_Var_3
  Let>BUTTON_%TEMP_number%_TEXT=TEMP_text
  Let>TEMP_sub_routine=SETUP_BUTTON_Var_4
  LabelToVar>HTML_CODE_simple_button,TEMP_html,0,0,*/
  SetDialogProperty>MAIN_DIALOG,BUTTON_%TEMP_number%,HTML,TEMP_html
  SetDialogProperty>MAIN_DIALOG,BUTTON_%TEMP_number%,Width,BUTTON_WIDTH
  SetDialogProperty>MAIN_DIALOG,BUTTON_%TEMP_number%,Height,BUTTON_HEIGHT
  IfNot>TEMP_sub_routine=
      AddDialogHandler>MAIN_DIALOG,BUTTON_%TEMP_number%,OnMouseUp,BUTTON_CLICKED(%TEMP_number%,%TEMP_sub_routine%)
  Endif>
  AddDialogHandler>MAIN_DIALOG,BUTTON_%TEMP_number%,OnMouseMove,UPDATE_TIMER(%TEMP_number%)
END>SETUP_BUTTON

/*
HTML_CODE_simple_button:
<div style="
  border-style: solid;
  border-width: %BORDER_WIDTH%px;
  border-color: %BORDER_COLOR%;
  background:   %BACKGROUND_COLOR%;
  color:        %TEXT_COLOR%;
  overflow:     hidden;
  height:       35px;
  width:        64.5%PERCENT%;
  font-size:    22px;
  font-family:  Arial, Helvetica, sans-serif;
  ">
    <img src="icon\%TEMP_icon%.png" style="width:25px;height:25px;margin-top:3px;margin-bottom:-25px;">
    <div style="height:25px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%TEMP_text%&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
  </div>
*/
Let>ME=%Script%

Running: 15.0.19b
version history

User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Cursor for HTMLViewer isn't working

Post by Grovkillen » Mon Sep 27, 2021 2:55 pm

Further advances ;)

Code: Select all

Let>PERCENT=%
Let>BORDER_WIDTH=5px
Let>BORDER_COLOR=limegreen
Let>BACKUP_BORDER_COLOR=BORDER_COLOR
Let>TEXT_COLOR=white
Let>BACKGROUND_COLOR=black
Let>BUTTON_WIDTH=300
Let>BUTTON_HEIGHT=50
Let>WIN_USEHANDLE=1
Let>END_OF_CODE=*/

Dialog>MAIN_DIALOG
object MAIN_DIALOG: TForm
  BorderStyle = bsNone
  ClientHeight = 200
  ClientWidth = 175
  Color = clLime
  TransparentColor = True
  TransparentColorValue = clLime
  object BUTTON_1: tMSHTMLViewer
    Left = -10
    Top = -5
    Height = 1
    Width = 1
    DefBackground = clLime
    Cursor = crHandPoint
  end
  object BUTTON_2: tMSHTMLViewer
    Left = -10
    Top = 45
    Height = 1
    Width = 1
    DefBackground = clLime
    Cursor = crHandPoint
  end
end
EndDialog>MAIN_DIALOG


GoSub>SETUP_BUTTON,{"1"},{"close"},{"Terminate"},{"CLOSE_APP"}
GoSub>SETUP_BUTTON,{"2"},{"message"},{"Hello!"},{"SEND_MESSAGE"}

Show>MAIN_DIALOG

Label>MainLoopStart
If>SHOULD_I_CLOSE=True
  CloseDialog>MAIN_DIALOG
  Wait>0.5
  Exit>
Endif>
Wait>0.05
GoSub>CHECK_HOVERED_OBJECTS
Goto>MainLoopStart

SRT>CHECK_HOVERED_OBJECTS
  Timer>CURRENT_timer
  Let>k=0
  Repeat>k
    Let>k=k+1
    If>BUTTON_%k%_HOVERED=True
      Let>TIMER_diff=CURRENT_timer-TIMER_%k%
      If>TIMER_diff>50
        GetCursorPos>MOUSE_x,MOUSE_y
        Let>TEMP_x_min=BUTTON_%k%_X_min
        Let>TEMP_Y_min=BUTTON_%k%_Y_min
        Let>TEMP_x_max=BUTTON_%k%_X_max
        Let>TEMP_Y_max=BUTTON_%k%_Y_max
        IfNot>{(%MOUSE_x% > %TEMP_x_min%) AND (%MOUSE_x% < %TEMP_x_max%) AND (%MOUSE_y% > %TEMP_y_min%) AND (%MOUSE_y% < %TEMP_y_max%)}
          Let>BORDER_COLOR=BACKUP_BORDER_COLOR
          Let>TEMP_icon=BUTTON_%k%_ICON
          Let>TEMP_text=BUTTON_%k%_TEXT
          LabelToVar>HTML_CODE_simple_button,TEMP_html,0,0,END_OF_CODE
          SetDialogProperty>MAIN_DIALOG,BUTTON_%k%,HTML,TEMP_html
          Let>BUTTON_%k%_HOVERED=False
        Endif>
      Endif>
    Endif>
  Until>k=2
END>CHECK_HOVERED_OBJECTS

SRT>UPDATE_TIMER
  If>BUTTON_%UPDATE_TIMER_Var_1%_HOVERED=False
    Timer>CURRENT_timer
    Let>TIMER_%UPDATE_TIMER_Var_1%=CURRENT_timer
    Let>BUTTON_%UPDATE_TIMER_Var_1%_HOVERED=True
    Let>BORDER_COLOR=TEXT_COLOR
    Let>TEMP_icon=BUTTON_%UPDATE_TIMER_Var_1%_ICON
    Let>TEMP_text=BUTTON_%UPDATE_TIMER_Var_1%_TEXT
    LabelToVar>HTML_CODE_simple_button,TEMP_html,0,0,END_OF_CODE
    SetDialogProperty>MAIN_DIALOG,BUTTON_%UPDATE_TIMER_Var_1%,HTML,TEMP_html
  Endif>
END>UPDATE_TIMER

SRT>BUTTON_CLICKED
  Let>BUTTON_LAST_CLICKED=BUTTON_CLICKED_Var_1
  Let>SUB_ROUTINE=SUB_
  ConCat>SUB_ROUTINE,%BUTTON_CLICKED_Var_2%
  UpperCase>SUB_ROUTINE,SUB_ROUTINE
  GoSub>%SUB_ROUTINE%,%BUTTON_CLICKED_Var_1%
END>BUTTON_CLICKED

SRT>SUB_CLOSE_APP
  Let>SHOULD_I_CLOSE=True
END>SUB_CLOSE_APP

SRT>SUB_SEND_MESSAGE
  Message>SUB_SEND_MESSAGE_Var_1
END>SUB_SEND_MESSAGE

SRT>SETUP_BUTTON
  Let>TEMP_number=SETUP_BUTTON_Var_1
  Let>BUTTON_%TEMP_number%_HOVERED=False
  Let>TEMP_icon=SETUP_BUTTON_Var_2
  Let>BUTTON_%TEMP_number%_ICON=TEMP_icon
  Let>TEMP_text=SETUP_BUTTON_Var_3
  Let>BUTTON_%TEMP_number%_TEXT=TEMP_text
  Let>TEMP_sub_routine=SETUP_BUTTON_Var_4
  LabelToVar>HTML_CODE_simple_button,TEMP_html,0,0,*/
  SetDialogProperty>MAIN_DIALOG,BUTTON_%TEMP_number%,HTML,TEMP_html
  SetDialogProperty>MAIN_DIALOG,BUTTON_%TEMP_number%,Width,BUTTON_WIDTH
  SetDialogProperty>MAIN_DIALOG,BUTTON_%TEMP_number%,Height,BUTTON_HEIGHT
  GetWindowPos>MAIN_DIALOG.BUTTON_%TEMP_number%.HANDLE,TEMP_x,TEMP_y
  Let>BUTTON_%TEMP_number%_X_min=TEMP_x
  Let>BUTTON_%TEMP_number%_Y_min=TEMP_y
  GetWindowSize>MAIN_DIALOG.BUTTON_%TEMP_number%.HANDLE,TEMP_w,TEMP_h
  Let>BUTTON_%TEMP_number%_W=TEMP_w
  Let>BUTTON_%TEMP_number%_H=TEMP_h
  Let>BUTTON_%TEMP_number%_X_max=BUTTON_%TEMP_number%_X_min+BUTTON_%TEMP_number%_W
  Let>BUTTON_%TEMP_number%_Y_max=BUTTON_%TEMP_number%_Y_min+BUTTON_%TEMP_number%_H
  IfNot>TEMP_sub_routine=
      AddDialogHandler>MAIN_DIALOG,BUTTON_%TEMP_number%,OnMouseUp,BUTTON_CLICKED(%TEMP_number%,%TEMP_sub_routine%)
  Endif>
  AddDialogHandler>MAIN_DIALOG,BUTTON_%TEMP_number%,OnMouseMove,UPDATE_TIMER(%TEMP_number%)
END>SETUP_BUTTON

/*
HTML_CODE_simple_button:
<div style="
  border-style: solid;
  border-width: %BORDER_WIDTH%px;
  border-color: %BORDER_COLOR%;
  background:   %BACKGROUND_COLOR%;
  color:        %TEXT_COLOR%;
  overflow:     hidden;
  height:       35px;
  width:        64.5%PERCENT%;
  font-size:    22px;
  font-family:  Arial, Helvetica, sans-serif;
  ">
    <img src="icon\%TEMP_icon%.png" style="width:25px;height:25px;margin-top:3px;margin-bottom:-25px;">
    <div style="height:25px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%TEMP_text%&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
  </div>
*/
Let>ME=%Script%

Running: 15.0.19b
version history

User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Cursor for HTMLViewer isn't working

Post by Grovkillen » Tue Sep 28, 2021 8:26 am

If anyone is interested, here's a gif showing you the application I'm working on. All done in MS using the HTMLViewer dialog element. Love it :)

PS. The black background with the icon seen in the preview below is the wallpaper of my computer. The purple dialog elements are the HTMLViewer elements, and I set the rest to be transparent. The app itself is a kind of print screen tool that I'm developing for a company that wants to speed up the creation of guides based on images.

Image
Let>ME=%Script%

Running: 15.0.19b
version history

User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Cursor for HTMLViewer isn't working

Post by Grovkillen » Wed Sep 29, 2021 12:13 pm

Here's another demo. All done in MS :)

Image
Let>ME=%Script%

Running: 15.0.19b
version history

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