PDA

View Full Version : Just sharing something by way of thanks :-)


ABC123

GaryRockley
11-20-2014, 10:00 PM
Hi everyone,

Long post again, though this is by way of a thank you for the help to my previous question, - and something of a question, and some general info, not Alpha specific, but may be relevant for desktop app devs.

The background to this is that some time ago, I wrote some code to de-munge, & purge google's results links of tracking data, with the option to scan the target URL for specific info. This is using MS-Access.

Works very nicely. Users can simply drag a link (or Right Click Copy and then hit a Paste button).
It all worked very nicely until Win7 or Win8, where the drag drop aspect fails.

It seems that on Win7/8, one can not simply drag a link, or even text from the browser to anything - including wordpad.
By the same token, one can not drag text, even from word pad to my lil 'drop box' in Win7 or Win8.

This seems very odd because all other versions of Win seem okay.

Now, while I know this is such a trivial thing, and may not be relevant to most desktop apps, it is still really annoying when there is no apparent reason.

So, I'm curious to know if this is the same in Alpha Five.

Given a text box on a form, can you drag a link or text from a browser to the text box (while running on Win7\Win8)?. My guess is no.

If my guess is correct, and in the event that someone else may need to know, and since I'm so grateful for the feedback I received to my previous question, I figured I'd share.

After a lot of research, where I see suggestions of very odd Win Registry Hacks or turning off Protected Mode for Explorer - none of which work btw, and are certainly not practical as end user advice, I realized the following.

All browsers run in 'Protected Mode' on Win 7/Win8. This is to prevent malicious code - which is why we no longer need anti stealth or anti-virus programs (thank you Microsoft, you are my hero).

But, Microsoft's 'Protected Mode' a bit pedantic. Bit like the overtly moral guy who wouldn't sleep with his wife because she was a married woman.

Along with 'Protected Mode', all browsers function under lower permissions. So, even if your app is running under elevated perms, the browser itself is low man on the ladder, and can't invoke as a Drag/Drop source.

Without the need to modify Protected Mode (so it's still doing it's job), one needs to launch the Browser/Program with Admin Permissions.

There are 3 ways of doing this.

1. For just this session: Right Click App icon and Click Run As Admin

2. For All sessions, Right Click App Icon, Click Properties.
On the Shortcut Tab, Click Advanced, Click Run As Admin

3. Registry Edit, or Via Code
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
New String Value = [Full Path to App Name]
Data = "RUNASADMIN"

Once the target (browser or Wordpad) runs as Admin, it will invoke as a Drag Drop Source, so Drag and Drop will work.

This does not compromise Protected Mode or Windows Defender. Simply allows Drag Drop to Work.

Only applies to Win7 and above.

Proviso for single session:
If another instance of the browser is already running, the new instance will inherit the start up params of the existing instance, so close all browser sessions and start a new one with Run as Admin.

Hopefully, I'm not the only one who finds this useful.

Best Wishes to all, Gary

DaveM
11-21-2014, 01:33 AM
Not sure what you are saying about drag & drop or copy paste. I just copied the url from here to wordpad on my win8.1 machine and it is the first time wordpad has ever been opened on this machine.

I run a test adb here so just copied the same url into a ch 255 field, no problem

No drag and drop to alpha only copy paste.

GaryRockley
11-22-2014, 10:06 PM
Hi Dave,

Apologies if I was unclear.

This is about Drag/Drop - per my previous "It all worked very nicely until Win7 or Win8, where the drag drop aspect fails."

Of course you can copy/paste browser to Word Pad (or notepad, for that matter). But, you can't drag drop from any Browser that is not Run As Admin.

Word Pad was used as an example - of the absurdity of Microsoft's 'Security' in that one can not even drag/drop to Word Pad if the browser is not Run As Admin.

And, as it happens, also FROM Word Pad, if Wordpad is not Run As Admin - which is nothing short of stupendously stupid.

I've tested on almost every version of Win7 and Win8 (Home thru Enterprise). I also know this is an issue for multiple platforms, .net, C++, C#, Wine, Delphi, VB, et al). I've read hundreds of suggestions on how to fix, including MS, and not one of them was right. Since I do know what works, I threw it out there as thanks and fyi.


But, you just raised a bigger issue.

You can't Drag Drop to an Alpha Five ch field? wtf?

I could understand if it was a bound field with a limit of n Chrs and you tried to exceed it, but, even in Access, an unbound Field can receive drag/drop up to 64K, and a Bound Memo field 1GB.

Are you seriously telling me that Drag/Drop functionality does not exist in A5?

Please, do me a big favor. Start either Firefox or Chrome or Word Pad (Right Click - Run As Admin)
Then select some text and drag/drop to an A5 Chr field - Preferably UnBound.

If Alpha is not registered as a Drag/Drop Client then it will fail. But if that's true, I have to wonder why Alpha is so far behind on 25 year old (very basic) registry semantics.

Or do we have to create a GUID per exe?, and then have the installer edit the registry and add the GUID as a Drag/Drop Client for each exe?

Since this is part of HKLM hive in the resistry, I can see some potential issues if the installer does not elevate permissions.

Either way, if you could indulge me by checking, I guess it would be nice to know in advance.

TIA & Regards,

Gary

DaveM
11-23-2014, 12:56 AM
I had already tried that and all my pc's are run as admin. All my clients machines are too.
You can copy paste to a memo/rtmemo field. That comes at some risk, so I now include a small free utility that strips all but true text out of the paste part. It is called pure text.

My newer apps are set up so the users get a variable field to type in and then it is put in the memo field so they can't type or paste directly.

GaryRockley
11-25-2014, 03:51 AM
Hello Dave,

Your reply is kinda understood, but,

When you say "already tried that", & all your machines are "Run as Admin", the fact is that even if you've turned off UAC and have full admin perms, Explorer, Firefox & Chrome still do not "Run as Admin" unless implicitly specified at run-time.

This is tested under Win7 & win8 Enterprise, & Win8 Home.

You simply can not Drag/Drop a link or text from a browser to even wordpad unless the browser itself is implicitly Run as Admin.

I certainly admit to perhaps not being clear enough when I said 'Drag/Drop', since I can see how this is so easily confused with 'Copy/Paste'. Please accept my apologies for my oversight. I shall endeavor to be more specific.

Copy/Paste is irrelevant in this regard. We can all Copy/Paste (which sends to Clipboard with implicit elevated perms). The ONLY point here is Drag/Drop. Please try to do what I asked, before you say I'm wrong. Drag/Drop -----> Not Copy/Paste

Although I hope that I was now specific enough, you raise even bigger questions.

We have determined that if Alpha-Five Can Not initiate as a drag drop client then it has significantly limited utility for basic applications.

Per previous follow up question - 'Unless one has to create a GUID' -> for the specific exe app name and register that.

So now, does A5 have a GUID create function ?

When you said "tried that", are you saying that you attempted to create a GUID and append that to the windows registry as a drag/drop client? If so, HKLM or HKLU ? - Important coz without elevated perms you can not write to HKLM, which is where you need to write this shit.

And, you raise yet a new very important issue.

Curious bout your util. When you say "strips out all but true text", are you referring to, say chr(32) to chr(127) as true text?

If so, I can see that as a very limited remedy for getting rid of those little squares that can crop up with some chrs (assuming all your clients are US based), but it raises in my mind, a whole bunch of questions about how Alpha Five handles Unicode. Especially since some of us have clients who use those pesky foreign languages.

Per microsoft, (& persons who like to just like to re-quote microsoft), VB treats internally all text as Unicode. Strictly speaking, this isn't true, and it leads to problems on your/my code installed on some international versions of the Op Sys.

For example, Chinese versions of Windows are are a problem because of their interpretation of what happens to ascii chrs above 127 - they are treated a DBCS - not UTF-8 (Multibyte), which is what VB actually runs under -----> VB uses UTF-8, Multibyte - (NOT Unicode which is technically UTF-16 (DBCS).

This all may seem like splitting hairs and trivial crap but, not only am I sick of self proclaimed experts simply spouting shit from the manufacturer, without ever testing anything, or knowing what they are talking about, this is also my livelihood. Consequently, questions that I ask are very important. In the same way, I never offer info or advice that I have not thoroughly checked.

The difference between Drag/Drop & GetClipboard is staggeringly wide depending upon how;
1. The interpreter/compiler handles it.
2. The platform the app is installed to.
3. What we are trying to achieve.

I know that you are not trying to be deliberately obtuse, and I have a feeling that if & when I make the switch to x-basic/A5, chances are you will be a very important person to me.

But, I posted a quick fyi as a thank you, (which is 100% accurate). You can not Drag/Drop from a browser if the Browser is not Run as Admin under W7 or W8. Period. Again, may seem trivial but run a google search and check out the thousands of wrong answers. The correct answer may be important to someone, that's why I shared - and btw, that took many hours and verifying tons of useless 'advice' from forum 'experts'.

That aside, I now need to think about some new questions before I risk the future of my business, and my clients, on switching platforms.

Certainly if Alpha Five can not invoke as a drag drop client, that is VERY disappointing.
If A5 can not store data in in utf-8 or utf-16, it's a drag, but no different to what I'm used to.

Manipulation of utf=8, utf-16 files is critical, since the remedy to lack of db support with ms-access for utf-8/utf-16 db support is to create pseudo tables as dat files and read them into mem as required, but if Alpha's compile/interpreter has issues with multibyte or doublebyte then A5, despite it's very impressive videos is useless to me.

Dave, I appreciate your responses, I know you are a respected member of this community, and I am not looking to piss you off.

However, I do need serious answers. I am not a light weight, and I'll not be treated as such.

Many thanks again,

Regards,

Gary

Ted Giles
11-30-2014, 04:42 AM
Just to chip in here.
There was a video a while back showing a D&D feature.
Having worked with AS for as long as Dave, I was bowled over, so I asked it was done and how to do it.
I never got a reply, and suspect a C# pkug in was used.
Dave is right about the risks associated with data in Memo fields. It's text only or you will get a screw up.

As a matter of interest, I'm working on a problem in a gvmnt. application. Not mine, but a very expensive web based one.
They cannot enter "@" as in " 5 days @ £15 " without Oracle throwing a wobbly.

I'll try your suggestion Gary, as it would be the Holy Grail if I can get it to work.
In the meantime, see PM.

Edit.
This is what I tried.
Open Chrome and run as admin.
Open Wordpad as admin.
Select text and D&D from Chrome to Wordpad
Successful

Close both.
Open Chrome not admin
Open Wordpad not admin
Select text and D&D
Success.

Open Chrome as admin
Open A5 v11 with unbound HTML Memo and Memo field
Select text and D&D
Failed all fields.

So.
D&D works on my laptop even without running the browser as admin.
D&D does not work with A5 - as we all really knew, but worth a punt anyway.
Thanks for sharing, but I'm not sure that there was a problem to begin with. Well not on my kit anyway.
T

DaveM
11-30-2014, 05:47 PM
Funny. I just needed to fill a few fields in a browse with character based fields. Could not drag and drop, but copy and paste did work. It will also work on memo files, but again, if doing something like that with a lot od formatting, you may lose your memo field.

when My users or I copy to the clipboard, we use a paster called "Pure Text" for that operation. I have it set up to paste with ctrl-A. It takes the junk out before the paste. I don't know if it is perfect, but it has been perfect so far.

As a note: I would love D&D for images.

Ted Giles
12-01-2014, 03:03 PM
Cool Dave. Also strips out crapola.
I have used the Saveto and Insertfrom the Clipboard a lot using buttons.
How did you get on with HTMLMemo?

GaryRockley
12-01-2014, 10:55 PM
Hi Dave & Ted,

I am indebted to you both for your replies.

For Ted, your '@' key issue may be related to the type of Keyboard mapping. I noticed you are in the UK.

If Memory serves correctly, the UK Pound Symbol is where the @ is on a US keyboard.

We had some issues with Keyboards in Europe using the Alt-GR Key for the '@' character, because Alt-GR maps to different values depending on the language set of the O/S. iow, the key combination to generate @ is different of French, UK English, German etc. Keyboards.

For me, the simplest remedy was to have a label with some code behind it that inserted '@' in an 'email address' field.

You could also use the Decimal Value 64, or Hex 40 to generate the correct Chr.


May I ask, which version of Windows did you do the drag/drop test on?

I have VMs of most versions of Windows and found the Drag/Drop would fail if the source app was not enabled as Admin on Win7, 8, and 8.1.


btw, for versions of Win where I don't own the install CD, Microsoft have free Dev VMs (ostensibly to test Internet Explorer) that you can download. They are usually 90 days enabled. After 90 days, you just need to either download again or use an 'unitialized' VM. If anyone is interested I'll try to find the Microsoft Link.


I did quite a bit of research on the whole drag/drop with Alpha, going back over several years of forum posts, and it does seem, Dave, that you are correct. A5 does not have drag/Drop, which I find annoying, to say the least.

Dave, I'm also more that just a tad troubled by your notes regarding Memo fields, since I use them extensively and need to retain Unicode values. Access too has quirks with memo fields, but after 20-odd years, I'm kinda used to the issues and can work around them.

I've seen some references to 'Pure Text' before. Obviously, I need to look into that. But, when you guys refer to stripping out junk/crapola, are you referring to character codes above say chr(127)? If so, it does lead to another question, which is knowing how A5 handles Unicode at the compiler level. I've asked Alpha directly and am waiting on the reply.


To explain why it's important, and this isn't me asking a different question. I try to respect thread purity and don't want to co-mingle, but I do need to explain why this is relevant.


I can understand if you are just working with standard ASCII (US/UK English) that you may want to simply nix any characters that are below ANSI 127, (or ANSI 255 for the original extended chr set). But, if you have clients in say, China, you can't simply nix them. So, while this Unicode thing may not be a fundamental issue to many, it really is kind of a big deal.

For example, if you are say retrieving a google link to web page in China and want to strip out the google tracking data, you still need to retain the unicode to render a link that is readable to the person in their native language.

While MS claim that VB handles all text as Unicode. This is not, strictly speaking, an accurate claim.

Additionally, the MS-Access Jet DB Engine (and therefore the underlying tables) will only display in the code page assigned by the Operating System at boot.

In other words, if you read a web page in say, Greek, and write that to either a text field of memo field, and your O/S is set to US English, you will see a lot of ?????'s. This is true, even if you change the font to Lucinda Unicode.

But, change the O/S Language to Greek, Reboot and now you can read it. This has always struck me as way dumb, because.......

If I write that same info to a text file, "myGreek.txt", and append file headers for either UTF-8 or UTF-16, and then shell to notepad to open it, it will display the correct text - without reboot, and without having to change the language of the O/S, and without having to change the Font (even if the default font for notepad is Courier New).

Given that Microsoft have been saying for about 12 years that developers should switch to Unicode (which, quite frankly means nothing by itself and, if anything is not a good idea, since Microsoft can't even decide what they mean by Unicode) it has always struck me as nuts that notepad can display in any language format if the correct headers are in place, but MS-Access can't.

To compound all of this, while VB itself handles strings as UTF-8, if you run a debug.print on a string, it's 7-bit ANSI.

I swear that sometimes I just wanna grab the stupid b's responsible for this mess by the lapels and.... then make them a nice cup of hot chocolate so's we can all be friends.

At some point, I'll need to know where Alpha's idiosyncrasies are in this regard, but not right now.

Thank you both again for your indulgence.

Best,

Gary

Ted Giles
12-02-2014, 04:27 PM
May I ask, which version of Windows did you do the drag/drop test on?
Win7.
Interesting and detailed analysis Garry. I will check the points you make tomorrow.
Seamless it most certainly ain't.

DaveM
12-02-2014, 09:55 PM
win 8.1 here and win7

mariusm
12-11-2014, 08:07 PM
Was curious so I tried as well - in Win 8.1 - from Chrome, not as admin, I can D&D into OpenOffice (not as admin also) but not in Alpha5.
I'm happy, I don't want my users to drag and drop!