How do I drag and drop an external file to my xojo app and return the path - realbasic

I wanted to drag a file (say abc.txt) to my xojo program and let it to write out the path of the dropped file, returning something like C:\\mydata\abc.txt.
How do I go about doing it? Do I need to enable some properties?
I can't find anything useful from manual or forum.

First, add a File Type Set to your project. It'll be named FileTypes1 initially, but better rename it to "DropTypes". Add file types to it that you like to accept. To accept any file, click on the center of these buttons in the IDE's File Type Set editor:
Choose special/any.
Next, add this line to the Open event of the control or window that should allow drops:
me.AcceptFileDrop DropTypes.All
Then add this code to the control's or window's DropObject event:
if obj.FolderItemAvailable then
dim f as FolderItem = obj.FolderItem
' Now you have the file reference in f.
' Get the path:
dim path as String = f.NativePath ' (in older RB versions, use *f.AbsolutePath* instead)
' Show the path:
MsgBox path
end

Related

pdftoprinter.exe Orientation page command

I need page orientation to landscape with a command through pdftoprinter.exe, does anyone know what parameter?
Dim retval
retval = Shell(App.Path & "\PDFtoPrinter.EXE C:\_GR\VB6\TEstePDF_Printer\pdfs\teste*.pdf ", 0)
If you want to change the orientation, you can use the advise given on the documentation of using the dat-file created by PDF-Xchange viewer:
By default, this system uses these printing options as set in PDF-XChange Viewer: Scaling is set to None; Auto-rotate Sheets; Auto-centre pages in sheets; and Choose paper source by PDF-page size. If you want to change any of these, or choose any other options, download and install PDF-XChange Viewer; open a PDF file, go to the Print menu, set your desired options (and, just to be certain, print the file). Then go to the Edit menu and choose Export All Settings to Data File... Accept the suggested filename, "PDF-XChange Viewer Settings.dat", and save the file to a convenient location. Move or copy the file to the same folder with PDFtoPrinter.exe. When you next run PDFtoPrinter.exe it will use the settings saved in that file.
Found here.
Mind that:
Move or copy the file to the same folder with PDFtoPrinter.exe.

Excel VBA to get UNC from cell and open it in explorer.exe

I have a file with a list of PC hostnames I want to be able to connect to the C drive of a specific one by clicking in a cell or button or something.
Let's say I currently have the hostname in Column A. I use CONCATENATE to turn it into a proper network path \\hostname\C$ and put that in Column B.
Now how can I make it so I can just click on the cell in column B to open that location in explorer.exe?
I have 450 PCs so i need to be able to specify the range, feed the network path into VBA and then open that in explorer.exe
does this make any sense? :P
Would really, really appreciate any help. Thanks.
Wrap the concatenated value in a "Hyperlink()". From then on it is clickable and it will open the explorer.
=HYPERLINK(CONCATENATE("\\";A1;"\C$");A1)
Or you put this code in your Worksheet code pane and double click the cells, where your links stand. But then you mustnt use it in combination with HYPERLINK.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column <> 2 Then Exit Sub
Dim sh As Object
Set sh = CreateObject("Wscript.Shell")
sh.Run ("explorer " & Target.Value)
Cancel = True
End Sub

Print File(NotePad) Without the name of the file appearing in the printing document

Dim ProcessProperties As New ProcessStartInfo()
ProcessProperties.FileName = "notepad.exe"
ProcessProperties.Arguments = "/p c:/doc.txt" 'command line arguments ''
''ProcessProperties.WindowStyle = ProcessWindowStyle.Maximized
Dim myProcess As Process = Process.Start(ProcessProperties)
when printing using the code above i have "doc.txt" printed. I don't want the file name to appear when printing is over
It is not possible to pass an argument through command line to notepad to hide the header, the only parameter accepted for the /P argument is the file name. (See link)
The only way to hide the header from printing is by opening notepad and going to File->Page Setup, and changing the header command. (See link)
If it is really needed to print using a process, you can try searching for third party editing tools which support printing arguments.
Another way is to implement functionality for printing the text file, see this Stackoverflow article (Link)
You will have to configure the header and footer options of Notepad in order to prevent or override the file name appearing on the print page. This can be done by simulating user input to bring up the Page Setup dialog and clear the header and footer.
There are a number of ways to send user input (mouse and/or keyboard). For starters you could look at these two:
Windows Input Simulator
Application and Global Mouse and Keyboard Hooks .Net Libary in C#

Adding new filetypes to Windows 7's New context menu

I'm trying to add CSS, PHP, JS and HTML file types to the "New" right click menu in Windows 7. I know how to add the file types to the menu with ShellNew entries in the registry. But Windows doesn't give you any control over the display names of the new items - according to this the name's always taken from whatever application you've assigned to open the doc. I've set Notepad++ to open all of these file types, so I'm going to end up with several identical "Notepad++ document" entries in the menu, like this:
Does anybody know if there's a way out of this stupid situation without installing any tweak utilities?
Thanks all!
Fred
To rename a context menu > new's item (in Windows 7, at least):
Open regedit.
Go to HKEY_CLASSES_ROOT\.%ext% and note the (Default) value. This is the file extension's ProdID.
Go to HKEY_CLASSES_ROOT\%ProdID% (usually %ext%file) using the value obtained from step two. Set the (Default) value to whatever you would like the context menu new item to display as.
Under HKEY_CLASSES_ROOT\%ProdID%, if there is a FriendlyTypeName value, rename it to FriendlyTypeName.old, as the (Default) value "is deprecated by the FriendlyTypeName entry"
I don't believe there is even a need to log out / restart, but if the changes don't take effect, log out and/or restart.
You could change the file type description for each file class manually.
Look up the prog id under HKEY_CLASSES_ROOT\.%ext% (The default value)
Under HKEY_CLASSES_ROOT\%progid%, set the default value and/or the "FriendlyTypeName" string to the string you want.
You might have to log off for it to take effect.
You should probably stay away from the Chrome and Notepad++ file type/association dialogs so they don't overwrite your strings.
Both Chrome and Notepad++ are open source, you can create a patch for them that use better names for the file types. (What is a "Chrome HTML Document" anyway, HTML5 + extra chrome juice? =) )
I was able to derive a solution from the answers above.
I replicated the particular application (JetBrains PHPStorm in my case) registry entry.
PHPStorm2019.1 -> PHPStorm2019.1.scss, PHPStorm2019.1.js.
Now I changed the Default REG_SZ of PHPStorm2019.1.scss to SCSS File and PHPStorm2019.1.js to JavaScript file.
Mapped .scss and .js to PHPStorm2019.1.scss and PHPStorm2019.1.js respectively.

How to Write a Visual Studio Macro Event to get user's typed Code?

i'm looking for a way to write a macro event to parse user's code.
for example when programmer writes some specific code this event will parse the code line and if matches a regular expression will insert some additional codes on active document.
how can i get hole line code and which event should i use?
You can use TextDocumentKeyPressEvents.AfterKeyPress event. The following macro triggers after user presses any key in text editor. Then it gets the current line. This example tests, if the line contains "hello" text and if so, it shows the line in message box.
Private Sub TextDocumentKeyPressEvents_AfterKeyPress(ByVal Keypress As String, _
ByVal Selection As EnvDTE.TextSelection, ByVal InStatementCompletion As Boolean) _
Handles TextDocumentKeyPressEvents.AfterKeyPress
Try
Dim line As String
Dim aPoint As EditPoint = Selection.ActivePoint.CreateEditPoint
Dim startPoint As EditPoint = aPoint.CreateEditPoint
startPoint.StartOfLine()
Dim endPoint As EditPoint = aPoint.CreateEditPoint
endPoint.EndOfLine()
line = startPoint.GetText(endPoint)
If line.Contains("hello") Then
MsgBox(line)
End If
Catch ex As Exception
End Try
End Sub
To create and apply this macro:
Go to menu Tools - Macros - Macros IDE...
In the Macros IDE Class View navigate to MyMacros - {}
MyMacros - EnvironmentEvents. Open (double-click) EnvironmentEvents.
Paste this code inside module (just before End Module line)
There are events that Macros can respond to, however, I do not believe that text entry is one of them, a better approach might be to use snippets - http://msdn.microsoft.com/en-us/library/ms165392(v=VS.100).aspx
They will allow you to define a keyword and then add text into the editor.
A good example is the property snippet; In your editor type 'prop' and then press Tab (twice in C#, once in VB) to invoke.
Here is more detailed list of available snippets:
http://msdn.microsoft.com/en-us/library/z41h7fat(v=VS.100).aspx

Resources