Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

using onkey functions in HTML dialog box

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • using onkey functions in HTML dialog box

    Below is a script that displays an HTML dialog. I would like to trap onkey for both ESC and PRINTSCREEN. There are several functions like onkeydown, but haven't figured out how to capture which key they pressed to process if is one of the 2 above - any ideas?

    Code:
    lastuse=toseconds(time())
    'Create an XDialog dialog box to prompt for parameters.
    DIM ans as P
    dim ans.object as p 
    dim ans.class as c
    ans.class = "dhtmledit.dhtmledit"
    dim ans.events as c 
    ans.events = <<%code%
    function contextmenuaction as v (itemIndex as N)
    end function
    function displaychanged as v ()
    end function
    function documentcomplete as v ()
    end function
    function onblur as v ()
    end function
    function onclick as v ()
    end function
    function ondblclick as v ()
    end function
    function onkeydown as v ()
     msgbox("","" + a_user.key.value)'does nothing
    end function
    function onkeypress as v ()
    end function
    function onkeyup as v ()
    end function
    function onmousedown as v ()
    end function
    function onmousemove as v ()
    end function
    function onmouseout as v ()
    end function
    function onmouseover as v ()
    end function
    function onmouseup as v ()
    end function
    function onreadystatechange as v ()
    end function
    function showcontextmenu as v (xPos as N,yPos as N)
    end function
    
    %code%
    DIM SHARED varC_result as C
    DIM ans_html as c 
    ans_html = <<%html%
    <html>
    <head>
    <meta name="generator" content="Alpha Five HTML Editor">
    <title></title>
    <style>
    <!--
    p            { margin-top: 0; margin-bottom: 0 }
    -->
    </style>
    </head>
    <body>
    <p>Note: for Rena, Billy, and appropriate others: the 
    "Search" button for the SaltLog is now live - it was previously disabled. In the near future I will add search for MachineLogs. 
    Also, in the near future we will be adding "hotkeys" to forms/screens. They will all follow 
    the following format:</p>
    <p>&nbsp;</p>
    <p><u>N</u>ew Record (Ctrl N)</p>
    <p><u>S</u>ave (Ctrl S)</p>
    <p><u>E</u>dit (Ctrl E)</p>
    <p><u>F</u>ind (Ctrl F) the buttons were previously named Search, but will be 
    renamed to Find</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp; note that on screens where there were/are multiple 
    search buttons, as in Training, this will always refer to the</p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp; top button named Find, for the parent records, and 
    will always be named Find. Secondary search buttons</p>
    <p>&nbsp;&nbsp;&nbsp; &nbsp;will remain&nbsp;named&nbsp;Search, to avoid 
    confusion.</p>
    <p><u>P</u>rint or Re<u>p</u>orts (Ctrl P)</p>
    <p>C<u>l</u>ose (Ctrl L) 
    <strong><em>saves changes</em></strong>     and closes</p>
    <p><u>M</u>ain Menu (Ctrl M)</p>
    <p>&nbsp;</p>
    <p>They have currently been added to the Machine Logs only. When you notice the 
    button changes on a form, they will have been added to that screen.</p>
    <p>&nbsp;</p>
    <p>Other HotKeys are ESC (located at the top left of your keyboard), and Print 
    Scrn (located at the top right of your keyboard.)</p>
    <p>&nbsp;</p>
    <p><strong><u>ESC</u></strong>: with rare exception, when you press the 
    <strong>ESC</strong> key, if you have made a change to a field on a form, the 
    change will be cancelled. If you have made a change to a field in a browse, and 
    you have <strong>not yet moved to a different row</strong>, the change will be 
    cancelled. If no changes have been made, the screen will close. So, in the new 
    format,&nbsp;<strong>Ctrl-S</strong> and <strong>ESC</strong> would save the 
    current record and close the screen. But note also that <strong>Ctrl-L</strong> 
    will do the same thing.</p>
    <p><strong><u>Print Scr</u></strong>: with rare exception, this will 
    print the current screen.</p>
    <p>&nbsp;</p>
    </body>
    </html>%html%
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("Notes to Employees",<<%dlg%
    {startup=init}
    {region}
    | {activex=120,33ans?.t.};
    {endregion};
    {line=1,0};
    {region}
                         <Close>
    {endregion};
    %dlg%,<<%code%
    if a_dlg_button = "init" then 
     a_dlg_button = ""
     ans.object.browsemode = .t. 
     ans.object.appearance = 0
     ans.object.ScrollBars = .t.
     on error goto ans_error
     ans.object.documenthtml = ans_html
     on error goto 0
     ans.object.Refresh()
     a_dlg_button = ""
    end if
    end 
    ans_error:
    ui_msg_box("Error","Invalid URL or HTML content.",UI_STOP_SYMBOL)
    end
    %code%)
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    [email protected]

    ____________________
    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

  • #2
    Re: using onkey functions in HTML dialog box

    bump
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    [email protected]

    ____________________
    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

    Comment


    • #3
      Re: using onkey functions in HTML dialog box

      Martin

      I am not really familiar with the HTML Dialog so maybe I am missing the point in your post - if so I beg forgiveness.

      If you are using the forms onkey event to capture keys then this works in the forms onkey event

      Code:
      IF a_user.key.value = "{Prnt Scrn}" then 'the print screen key is PRNT SCRN  not PRTSC as in sys_send_keys
          a_user.key.handled = .T.
          IF a_user.key.event = "up" then   'in debug PRNT SCRN is an up event not a down event
               msgbox("","prntsc has been pushed")
          end if
          
      elseif a_user.key.value = "{ESC}" then
          a_user.key.handled=.T.
      	if a_user.key.event="down" then
      	    msgbox("", "ESC has been pressed")
      	end if
      	
      elseif a_user.key.value="{SCROLLLOCK}" then 'the scroll lock key is SCROLLLOCK not SCROLLOCK as in sys_send_keys()
      	a_user.key.handled=.T.
      	if a_user.key.event="down" then
      	    msgbox("","scrollock has been pressed")
      	end if
      
      END IF
      Tom Baker

      Comment


      • #4
        Re: using onkey functions in HTML dialog box

        when the html dialog is opened, the parentform does not have focus, so the onkey event for that form won't fire.

        Open a form, put a new button on it, and paste my code in the onpush event. And then in the form's onkey event try to capture say the ESC key

        won't work

        the code has a lot of functions, but "how to use them?" can't find any documentation for
        Cole Custom Programming - Terrell, Texas
        972 524 8714
        [email protected]

        ____________________
        "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

        Comment


        • #5
          Re: using onkey functions in HTML dialog box

          Martin,

          I think you can do it without using the functions of the activex.
          Just place the following as part of the dlg defintion.

          {On_Key=ESC}
          (On_Key=PRTSC}

          When either of those two keys are pressed a_dlg_button will take on their value.

          If the purpose of ESC is to just close the dialog then you don't need to do anything else because leaving a_dlg_button with a value will close the dialog. For PrintScreen you will want to test for it so you can do what you want or at least set a_dlg_button to "" so the dialog doesn't close.

          Hhmmm,

          after a bit of testing I can not get printscreen to cause an event. Even tried the 'Insert Key Code' genie. I can get all kinds of keys to show their code but PrintScreen gives me nothing. (tried on two computers and v8 and v9) A bug may be?

          After some more testing found that the functions in the activex do respond. Change your msgbox to just return some text. It seems the the a_user.key.value is not valid in the context of an xdialog, It must be just a form event. Because the expression errors out the msgbox does not display.

          Even trying to access it in the interactive window would give an error.
          ?a_user.key.value
          ERROR: Property is write only
          a_user.key subelement not found.
          I guess that is why xdialog has the {On_key=} command.

          I also think you might need to use some vb compatable code within the activex function to return the key pressed. Although Alpha functions do seem to work in that context I don't know VB to be able to suggest anything useful.


          EDIT: I see Tom suggested similar in the v8 thread.
          Last edited by Tim Kiebert; 07-19-2008, 01:06 AM.
          Tim Kiebert
          Eagle Creek Citrus
          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

          Comment


          • #6
            Re: using onkey functions in HTML dialog box

            Tim, thanks for looking at this. I tried several things too -

            here is a script I have on all forms for users - they really like it:
            on a LAN, the table 'cscreen' is local and not shadowed, so many users could simultaneously print screens. Notice that it uses "prnt scrn" instead of "prtsc" and it works. If I could figure a way to capture that key I think the same code might work, or else I could make a report.


            Code:
            if a_user.key.value="{PRNT SCRN}" 'see code archive for sample adb using this
             a_user.key.handled=.t.
             ui_bitmap_create_from_screen("test", 0, 0, 8, 6) 
             vBlob = ui_bitmap_save("test") 
             t=table.open("cscreen")
             t.change_begin()
              t.cscreen=vblob
             t.change_end(.t.)
             report.preview("cscreen")
             t.close()
             ui_bitmap_drop("test") 
             delete vblob
             end
            end if
            Cole Custom Programming - Terrell, Texas
            972 524 8714
            [email protected]

            ____________________
            "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

            Comment


            • #7
              Re: using onkey functions in HTML dialog box

              Trap any and all keys. When the "Print Screen" button is pressed, the screen is printed (test by pasting in any other application).
              Last edited by G Gabriel; 07-19-2008, 12:44 PM.

              Comment


              • #8
                Re: using onkey functions in HTML dialog box

                G

                Now that we know it can be done (I have been working on this since yesterday - I like a good puzzle) but I'm exhausted and would really like to know HOW it is done.

                Would you care to share your code?

                If not I understand, and will continue to try to accomplish what you have already accomplished.

                Tom

                Comment


                • #9
                  Re: using onkey functions in HTML dialog box

                  Gabe

                  Use Modeless dialog box so that focus could be returned to the main form.

                  Trap Close key and Red X (Exit) key in the code for the HTML Dialog using "a_dlg_button"

                  In the HTML Dialog give focus to the form by coding a Topparent.activate().

                  That allows the form to handle the onkey events for the ESC key and the Print Screen as well as any other key you want to trap.

                  The onkey event code for the Print Screen trap gives focus back to the modeless dialog and then sens a CTRL P to print the contents of the modeless html dialog.

                  I don't know if this was how you came to coding your app, but this works too.

                  Thanks for the inspiration to keep on going - I have learned a lot about HTML coding and HTML Dialogs.

                  Tom

                  Comment

                  Working...
                  X