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

Calendar & Calculator Popup

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

    Calendar & Calculator Popup

    This simple solution will allow you to get a calendar popup or calculator when in a browse layout (or infact in any form window) , by simply pressing F11 or F12

    See Attached image for example

    Instructions:

    STEP1 - Create a new function (via Code Tab) called Define_Hotkeys() with the following code

    Code:
     
    function Define_Hotkeys as C ()
     IF a_user.key.value = "{F11}" THEN
      sDate=popup.calendar ("Enter Date",dtoc(date()))
      a_user.key.handled = .T. 
      IF a_user.key.event = "down" THEN
       sys_send_keys(sDate)
         END IF 
     else IF a_user.key.value = "{F12}" THEN
      sNum=popup.calculator ("Enter Date",dtoc(date()))
         a_user.key.handled = .T. 
      IF a_user.key.event = "down" THEN
       sys_send_keys(sNum)
         END IF 
     '**** Take This section Out if you do not want to siable control-D (Delete Shortcut) *****
     else IF a_user.key.value = "{^d}" THEN
      '**** Ignore Control D ****
         a_user.key.handled = .T. 
     '**** End of Section to Take out for Control D ****
     END IF
    end function
    STEP 2 - For each form that you wish to assign the new hotkeys to , goto Forms/Events/Onkey and add the following line of code

    Define_Hotkeys()

    That's it - you now have popup calendar and calculator
    F11 = Calendar
    F12 = Calculator

    Please Note: There is also a piece of code in the function which disables the use opf CTRL-D - which I find is a nuisance in Browses because it tries to delet the parent record, when mostly you just want to delete the current line in the browse. If you require CTRL-D to work as before , just uncomment the lines as noted in the function.

    Regards

    Mike Thomson
    Alpha One Software
    Mike Thomson

    #2
    Re: Calendar & Calculator Popup

    I have used Mike's function in my application, and it works fine. I do have a query though in the following bit of code:

    Code:
    else IF a_user.key.value = "{F12}" THEN
      sNum=popup.calculator ("Enter Date",dtoc(date()))
         a_user.key.handled = .T.
    This bit of code is for the pop-up calculator. What is the significance (if anything) of the ("Enter Date",dtoc(date()) bit in the calculator section?

    Comment


      #3
      Re: Calendar & Calculator Popup

      I think it's a typo, perhaps copied and pasted from the F11 section of the code. There's no point in passing the string value of the current system date to the calculator object. Suggest changing the line as follows:

      Code:
      snum = popup.calculator(0)
      Last edited by Tom Cone Jr; 05-17-2007, 06:41 AM.

      Comment


        #4
        Re: Calendar & Calculator Popup

        What calculator does it pop up?

        I obviously missed a lot the 5 or so times i read this thread?

        Maybe I should try it and see?

        Dave

        PS I tried it an it works great
        Last edited by DaveM; 05-18-2007, 11:31 AM.
        Dave Mason
        [email protected]
        Skype is dave.mason46

        Comment


          #5
          Re: Calendar & Calculator Popup

          Hello Mike

          That bit of code was just what I have been looking for.

          I was messing around with anther one I found on the board but could'nt get it to work every time, yours is magnificent.

          Thanks

          John
          Failure makes improvements

          Comment


            #6
            Re: Calendar & Calculator Popup

            These two functions were working for me so I am thinking I copied over a working script at some point. But in re-copying here I noticed that popup.calendar() returns a character string and must be converted to use in a date field:

            IF a_user.key.value = "{F11}" THEN
            sDate=CTOD(popup.calendar ("Enter Date",dtoc(date())) )
            a_user.key.handled = .T.
            IF a_user.key.event = "down" THEN
            sys_send_keys(sDate)
            END IF
            ...

            But in playing with this script, I saw that the first version used the same hotkey - wouldn't it be possible to verify the type of field that was calling the function so the same Hotkey would work depending on what the field type is? I tried topparent.GetActiveObjParent() to get a pointer and ptr.type_get() to test for "D" or "N", but am unsure how to write it depending on whether the container is a Form or Embedded Browse. So far it isn't working, but I may be having another problem that is unrelated. Like just generally poor syntax skills...
            Robin

            Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

            Comment


              #7
              Re: Calendar & Calculator Popup

              Hello

              I am very unskilled when it comes to code. I just pasted exactly as I received it and it worked. Sorry I can't help.

              Regards

              John
              Failure makes improvements

              Comment


                #8
                Re: Calendar & Calculator Popup

                Robin,
                I haven't tested this but it should work to see if you are in a form or a browse....

                Code:
                if topparent.Class() = "form" 
                    'do something here
                  elseif  topparent.Class() = "browse"
                    'do something else here
                end if
                Mike
                __________________________________________
                It is only when we forget all our learning that we begin to know.
                It's not what you look at that matters, it's what you see.
                Henry David Thoreau
                __________________________________________



                Comment


                  #9
                  Re: Calendar & Calculator Popup

                  Thanks Mike, I forgot about the Class method. Using Browse1.class() should identify an embedded browse on the form I see in the help. I haven't tested the CTOD() wrapper for the popup call yet but it could still be used to convert Sdate for another date type variable for sys_send_keys() to use. I better look that function up first too...duh I am having brain overload here, sys_send_keys takes a character argument. No wonder my modifications don't work!
                  Robin

                  Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                  Comment


                    #10
                    It Worked!

                    This works in either a Date or Numeric field to popup either the Calendar or Calculator, and ignores Character fields.

                    Code:
                    FUNCTION F11_HotKey AS C (checked as D = {})
                     IF .not. (a_user.key.event = "down") THEN
                      exit function
                     END IF
                     IF .not. (a_user.key.value = "{F11}") THEN
                      exit function
                     END IF
                     ''Hot Key to pop up Calendar or Calculator
                     traceln("F11 Calendar/Calculator Hotkey")
                     dim frm as p
                     dim fld as p
                     dim frm_name as c
                     dim fld_name as c
                     dim fld_type as c
                     dim vdate as c
                     dim vnumb as c
                     frm_name = A_FORM_CURRENT
                     traceln("Form name: "+frm_name)
                     'I also tried these
                     'frm_name = a5.active()
                     'frm_name = a5.getactiveobjparent()
                     frm = obj(frm_name)
                     frm.restrict_change = .f.
                     frm.allow_change(.t.)
                     fld_name = frm.active_drilldown()
                     traceln("Field name: "+fld_name)
                     fld = obj(fld_name)
                     fld_type = fld.type()
                     traceln("Field Type: "+fld_type)
                     'Note: Sys_send_keys takes a C argument but returns a N value
                     'Field type is tested to use in either Date or Numeric field
                     'to determine which popup method to use and to ignore C fields
                     SELECT
                      CASE fld_type = "C"
                       traceln("F11 Hot Key: Ignored")
                       EXIT FUNCTION
                      CASE fld_type = "D"
                        IF checkd = {} THEN
                    	checkd = date()
                        END IF
                       IF a_user.key.value="{F11}" THEN
                        vdate = popup.calendar("Select Date",dtoc(checkd))
                        a_user.key.handled=.t.
                        IF a_user.key.event = "down" THEN
                         sys_send_keys(vdate)
                        END IF
                       END IF
                      CASE fld_type = "N"
                       IF a_user.key.value="{F11}" THEN
                        vnumb = popup.calculator(0)
                        a_user.key.handled=.t.
                        IF a_user.key.event = "down" THEN
                         sys_send_keys(vnumb)
                        END IF
                       END IF
                     END SELECT
                    END FUNCTION
                    Last edited by MoGrace; 06-24-2010, 08:05 PM.
                    Robin

                    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                    Comment


                      #11
                      Re: It Worked!

                      Great bit of code but there is a missing "e" in "checkd" in the

                      vdate = popup.calendar("Select Date",dtoc(checkd))

                      It should be
                      vdate = popup.calendar("Select Date",dtoc(checked))

                      Comment


                        #12
                        Re: Calendar & Calculator Popup

                        Hmm, at some point I must have fixed it because it works for me. The best use I have found is in a browse or embedded browse in a form because you can't define a calendar type or calculator type to the field. Thanks for pointing out the typo!
                        Robin

                        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                        Comment

                        Working...
                        X