Does anybody know how to drag & drop a file to a browse control with file name written in UTF8 with characters other than ASCII, for instance Greak in C6.3?
Thank you!
The program has to process the string returned from the DROPID function invoking on response to the EVENT:Drop event. Strings can be translated from UTF-8 either by the call to the WideCharToMultiByte API function with the first parameter set to CP_UTF8, or just by decoding UTF-8 text to a 8-bit character string “by hands”.
Presumably you have code on the drop event that does something. Because as far as I’m aware theres no built-in “drop file on browse” behaviour.
I also presume your code is now failing. However you didnt share the code, nor have you described where, or how, it is failing.
With this lack of information it is hard to give you a useful answer to your question. Perhaps you can dig a bit deeper to give us more clues?
Also you mention utf-8. What makes you suspect the filename is utf-8 (as distinct from say utf-16?) Presumably the contents of the file are utf-8 , but again you might want to explain how you know this. (Does it have a BOM?)
Thanks for answering
The main problem occurs when the filename is written in Cyrillic characters.
For instance let’s say filename is “Закон о становању и одржавању зграда_ 104_2016-6, 9_2020-3 (др. закон).docx”. In DROPID() from Browse ~FILE it comes like “C:\Users\Djole\Desktop???? ? ??? ? ??? ???_ 104_2016-6, 9_2020-3 (??. ???).docx”.
I think that Drag&Drop work only with ANSII characters, not with UTF8. I need some extension for Drag&Drop in Browse control to overcome this problem.
Thank again!
so, does the filename contain valid utf-8? Or does the way you are displaying the filename not cope with utf-8?
When I’m not sure, I pass the variable into a StringTheory object, then PeekRam it to see what’s actually in there. As in;
str.SetValue(filename)
str.PeekRam(st:hex)
this outputs the actual hex values to debugview.
My guess is that the mechanism you are using to “see” inside the filename can’t display utf-8, hence the ? characters. Equally the Font the display mechanism is using may not have cyrillic characters, and hence displays those characters as ?.
You have a lot more investigating to do to narrow down the source of the problem.
This means that the SYSTEM{PROP:CharSet} property has the value not matching the system codepage.
Set this property to CHARSET:Cyrillic or CHARSET:GREEK or another value matching your system.
Below is the screenshot of the program to test drag-and-drop into a list. The SYSTEM{PROP:CharSet} has value CHARSET:Cyrillic :
Thank you also
I have tried with SYSTEM{PROP:CharSet} = CHARSET:Cyrillic but it won’t work in Clarion 6.3. Maybe some template or extension?
Though the input handling has been rewritten in C9 to support touch input, processing of dropping files is based in the same API function - DragQueryFile. The only difference is that the HDROP handle is retrieving now in another way. Therefore, I’m not expecting sufficient differences with earlier CW versions including C6.3. I can’t look the code closely at the moment because Windows prohibits dropping to windows belonging to programs running under debugger. It’s need to modify the code to log required information. I have no time at the moment but shall do this later.
You can try to make an experiment yourself. Replace the PROP:WindowProc property for a control you drop files to with your function. Handle the WM_DROPFILES message and use the DragQueryFile function in response to this message. This would allow you to see that you receive from Windows.
My test program shows names of dropped files without problems being built using C6.3 and C7 if to not link a manifest to EXE. If manifest is linked, the program does not receive the WM_DROPFILES message from Windows.
What language settings in Windows for not-Unicode texts you have? Control Panel → Region ->Administrative
What is value of the HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Nls\CodePage\ACP registry key on your computer?
Control Panel → Region ->Administrative: Latin - Serbia
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Nls\CodePage\ACP: 1250
My Windows works on English language in Latin of course. My program is written in Latin also. On Desktop can be files with its names written in Latin and Cyrillic for Drag&Drop to the Browse. I didn’t try to set not-Unicode with Cyrillic - Serbia. I will try now.