Modern-UI-Components-for-VBA icon indicating copy to clipboard operation
Modern-UI-Components-for-VBA copied to clipboard

Notifications able to open local files

Open krishKM opened this issue 5 years ago • 15 comments

This was raised by "ridders" (a member from access-programmers.co.uk).

Toast notifications can now accept local files as hyperlink and open them. Simply format your hyperlink with a local file. I.E <a href="F:\foldername\pictures\Apple.png">View Apple</a>

While doing this, we also added new function that docmd.openForm command can be passed as hyperlink and open a form in the host application. However this is under testing as I'm not sure if a specific Office PIA dll would work for everyone. Check out the latest sample and let us know.

krishKM avatar Aug 15 '18 08:08 krishKM

It would be nice to have that feature. I tried this enhancement with a function name instead of using a hyperlink not on the toast notification but on the dialog box. I had something like this: <a href=" & CallSampleFunction() & ">Go to settings</a>.

Whenever the dialog box opens or pop up, it executes the function name by opening the settings form without waiting for the user to click on the link "Go to settings". I also observe that when I put a function name there and with parameters, it doesn't work.

This works but without waiting for user on click event: <a href=" & CallSampleFunction() & ">Go to settings</a>

This doesn't work with parameters <a href=" & CallSampleFunction(True) & ">Go to settings</a>

US-Ali avatar Aug 18 '18 11:08 US-Ali

Thanks for the great idea! I will look into this. :)

krishKM avatar Aug 18 '18 17:08 krishKM

@US-Ali Thank you for the excellent idea. This function has been added to Toast & Simple dialog boxes. An update is available now. Check out the latest sample database and let us know.

krishKM avatar Aug 20 '18 12:08 krishKM

I tried the latest feature and sadly I don't know what went wrong. On your sample database, it was working perfectly but when I try to implement it in mine, it doesn't work. I get the following error message from a toast notification saying: Action command request but no callback instance found when I use a sample function as the hyperlink.

Another strange thing I observed is that the dialog box is now stretching across the entire screen instead of it's regular size. I have tried all your updates on my database before now and they all seems to work fine except for this latest update.

More strange is the fact that I removed the latest DLL file and replaced it with the previous one that was working perfectly for me to see if the dialog box stretching across the whole screen will stop, but it didn't. So right now I am confused about what could be responsible for it. Why will the hyperlink enhancement work perfectly on your sample database and not on mine anymore and why will the size of the dialog box suddenly starts displaying across the length of my screen?

US-Ali avatar Aug 21 '18 11:08 US-Ali

Action command request but no callback instance found could be due to following reason.

  1. No OleDBProvider for access is found in your system. Either Microsoft.ACE or Microsoft.JET is required
  2. gdll.DLL function in the sample database contains these new lines. (make sure you copy these new lines to your project too) 'Send this application full name to the dll for future references. I.e. call backs dllObject.SetAccessApplicationPath CurrentProject.FullName

regarding dialog box is now stretching. This is happening in the sample database too?

krishKM avatar Aug 21 '18 12:08 krishKM

I am not sure it has anything to do with the reasons above. I say that because I am able to run your sample database on the same system without any problem.

After my previous comment, I did a system restart, removed the dll and downgraded it to the last one before this recent update and the dialog box was displaying correctly on my database. I did a swap again of the dll to the most recent one just to double check and the problem started with the dialog box displaying across the whole screen.

I am unable to say if it's the dll but that is what it appears to be right now.

US-Ali avatar Aug 21 '18 12:08 US-Ali

Just to make sure: You are able to run the sample database without any problem. that includes, correct size of the dialogboxes as well as no Action command request but no callback instance found error.?

krishKM avatar Aug 21 '18 13:08 krishKM

Exactly! But that's not the case when I move this to my database.

US-Ali avatar Aug 21 '18 13:08 US-Ali

  1. Copy and replace the Public Function DLL() function form sample database to your project. This would get rid of the Action command requested but no callback instance found error
  2. Copy and replace the Public Function ShowDialog( function from sample database to your project. This might get rid of your dialogbox size issue.

Please let me know how this went.

krishKM avatar Aug 21 '18 13:08 krishKM

  1. I have updated my Public Function DLL() function in my database to include the additional lines of codes and this has fixed the Action command requested but no callback instance found error. I am able to use it to open a function name say GoToSettings() but not GoToSettings("frmGeneralSettings"). It doesn't allow any parameters in the function name which is a huge draw back.

  2. I have copied this Public Function ShowDialog() to my database even though it is the same with what I already have but unfortunately the dialog box is still displaying across the screen.

US-Ali avatar Aug 21 '18 15:08 US-Ali

point 1. Fixed.

point2. Can you somehow share your code/database so I can find out more where the problem might be? especially if the sample database is showing the correct size.

krishKM avatar Aug 21 '18 15:08 krishKM

I think I have figured out something that can help you in fixing this. I tried the following on my database:

MsgBox gDll.ShowDialog("A special thank you to all those who have " & _
                   "contributed to the project and the development of the software by " & _
                   "sharing library tools or codes, giving feedback either on their " & _
                   "experiences using the software or otherwise. ", "confirm", "OK", "")
  1. This: MsgBox gDll.ShowDialog("A special thank you to all those who have ", "confirm", "OK", "") gave this sample message (SampleMessage1.png) at https://github.com/US-Ali/Snapshots

  2. This:

MsgBox gDll.ShowDialog("A special thank you to all those who have " & _
"contributed to the project and the development of the software by ", "confirm", "OK", "")

gave this sample message (SampleMessage2.png) at https://github.com/US-Ali/Snapshots

  1. And this
MsgBox gDll.ShowDialog("A special thank you to all those who have " & _
                   "contributed to the project and the development of the software by " & _
                   "sharing library tools or codes, giving feedback either on their " & _
                   "experiences using the software or otherwise. ", "confirm", "OK", "")

gave this sample message (SampleMessage2.png) at https://github.com/US-Ali/Snapshots

  1. I decided to try this
MsgBox gDll.ShowDialog("A special thank you to all those who have " & _
                   "contributed to the project and the development of the software by " & _
                   "sharing library tools or codes, giving feedback either on their " & _
                   "experiences using the software or otherwise. ", "confirm", "OK", "")

on your own sample database and I got this sample messages (Krish's Message.png and Krish's Message2.png) at https://github.com/US-Ali/Snapshots

In Conclusion: As can be seen from the above pictures, I don't think the problem is peculiar to my database alone but to yours as well. The reason why yours is not noticeable was because your message length wasn't long enough. Try changing your message length and check if you will notice this problem. I am sure this can guide you in fixing the display width and height.

US-Ali avatar Aug 21 '18 17:08 US-Ali

@US-Ali Excellent findings. I fixed the parameter issue as well as dialogbox size issue. Please have a look.

Note:public functions take single quote ' instead " i.e. <a href="ExecuteMe('ThisIsAStringParameter')">Execute me</a>

krishKM avatar Aug 21 '18 20:08 krishKM

Excellent fix @krishKM and thanks for investing so much of your time on this. I am thinking again, can the parameter feature be extended further to do the following:

  • Take more than one parameter. Something like this:
  1. <a href="ExecuteMe('ThisIsAStringParameter')">Execute me</a>
  2. <a href="ExecuteMe('ThisIsAStringParameter', 'ThisAnIntegerParameter','etcParameter')">Execute me</a>
  3. <a href="ExecuteMe('frm', 'ProjectID', 'TaskID')">Execute me</a>
  4. <a href="ShowHelpNote('1, 1')">help</a> Functions like this can be used to call a record with recordID =1 and sub record with record ID = 1 too. Just my thoughts!
  • When the link is clicked, can their be an Optional parameter for the dialog box to close without the user clicking any of the buttons (OK, YES or NO). That is, if I click on the link, "Execute Me", The form should open and the dialog box closed all at once (this is especially for an OK only dialog box). BUT this should be an option as there might be instances when you need to still keep the dialog box open until the user clicks Yes or NO.

US-Ali avatar Aug 21 '18 21:08 US-Ali

Point1 is already possible. You just need to have correct public function in your application. Point2 is very interesting. Can you create new issue for this point as I'm trying to keep the issues organised so future readers can collaborate easily.

krishKM avatar Aug 22 '18 08:08 krishKM