This article will explain how to build a COM visual component in C# using Visual Studio 2010; it is an extension of my earlier example of using the Interop Forms Toolkit to build a Visual Basic COM object. First you need to install the Microsoft Interop Toolkit (available here). Then download the C# Interop Form…
You are currently browsing all posts tagged with Powerbuilder OLE
PowerBuilder – Using C# Visual Objects in PB Classic Applications
PowerBuilder – Timing Out a Windows Session
There are a variety of techniques to locking or timing out an application after a certain amount of inactivity. With earlier versions of Windows (XP and prior) a common approach was to invoke the screen saver via a Send command. send(handle(This),274,61760,0) This doesn’t work with Windows 7 (or Vista). Try the following: integer li_rc OleObject…
PowerBuilder – Using .Net Visual Controls in PB Classic Applications
This article describes the techniques and code used during my presentations at the Carolina Code Camp 2012 and at the May 2012 meeting of the North Carolina PowerBuilder User Group. The techniques described here utilize Visual Basic .Net (coded in Visual Studio 2010) with the Interop Forms Toolkit available from Microsoft. The Interop Forms Toolkit…
PowerBuilder – Reading Outlook Items
Here is some code which reads data from Outlook (2007 was tested) into PowerBuilder. You basically need to create a window with a multiline edit and a button on it. Put this into the clicked event of the button. To run it, open Outlook, select something (email message, task, etc.) then click the button on…
PowerBuilder – Add /Remove a Font at Runtime
Here is a way to add (and remove) a font to the user’s machine at runtime. You can also use this to check if a user has a particular font installed since the code also shows how to list all the installed fonts (need MS Word for this). Way back in my PB5 days I…
PowerBuilder – Locating Windows folders
Here is an easy way to find the paths to the various Windows folders. oleobject lole_wshell lole_wshell = create oleobject lole_wshell.connecttonewobject( "wscript.shell") is_mydocspath = lole_wshell.SpecialFolders("MyDocuments") IF IsValid(lole_wshell) THEN Destroy lole_wshell /* other folders: AllUsersDesktop AllUsersStartMenu AllUsersPrograms AllUsersStartup Desktop Favorites Fonts MyDocuments NetHood PrintHood Programs Recent SendTo StartMenu Startup Templates */
PowerBuilder – Getting Active Directory information
Here is a handy bit of OLE to retrieve Active Directory information. oleobject ads string ls_stuff ads = CREATE OleObject ads.ConnectToNewObject( "ADSystemInfo" ) ls_stuff = 'User: ' + String(ads.UserName) ls_stuff += '~n~r' + 'Computer: ' + string(ads.ComputerName) ls_stuff += '~n~r' + 'Domain: ' + string(ads.DomainDNSName) ls_stuff += '~n~r' + 'Domain short: ' + string(ads.DomainShortName) ls_stuff…
PowerBuilder – OLE with Facsys to Fax a Document
Here is a old post I put on Tek-Tips.com way back in 2001. I have just implemented an OLE faxing solution in my PB7 app using Facsys. This code creates the session, addresses the fax message, then attaches a previously created MSWord document to the fax. lole_facsys = Create OLEObject li_rc = lole_facsys.ConnectToNewObject("facsys.faxsession") //Check for…
Create Word Doc and attach to Outlook Email in PowerBuilder
Here is some sample PowerScript from back in 2004. The word document created is saved from a template doc previously created with specific bookmarks used to format the text. oleobject lole_word OLEObject lole_item, lole_attach, lole_outlook string ls_file_name lole_word = CREATE oleobject lole_outlook = Create OLEObject TRY lole_word.connecttonewobject('word.application') CATCH (runtimeerror a) Messagebox('Error','Error connecting with MS Word.…