The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Using COM APIs in ObjectStudio

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Using COM APIs in ObjectStudio Posted: Feb 18, 2009 1:21 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Using COM APIs in ObjectStudio
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

One of the knocks Smalltalk sometimes takes is the "doesn't play well with others" thing - the notion that it;s a world unto itself. I did a screencast showing how easy it is to hook ObjectStudio and iTunes up this morning - I thought a short post on it might be a worthwhile follow-up.

If you're working on a Mac, pretty much everything can be driven with AppleScript. On Windows, COM serves the same role. So if you fire up ObjectStudio, you can jump straight into that world of APIS by loading the OLE support:

Once you've done that, you can open a browser and define a new class. I just created one in the ObjectStudio namespace, descended from Object, and added one instance variable: 'dispatcher'. The example talks to iTunes (the Windows version). The #initialize method looks like this:


initialize
	"Initialize a newly created instance. This method must answer the receiver."

	| ole |
	super initialize.
	ole := OLEObject newProgId: 'iTunes.Application'.
	dispatcher := ole dispatcher.

That 'dispatcher' object can now invoke various APIs that iTunes understands. So I created a workspace script to try things out:


| model |
model := ITunesModel new.
model setVolume: 100.
model play.
(Delay forSeconds: 10) wait.
model pause.
model nextTrack.
model play.
(Delay forSeconds: 10) wait.
model pause.
model release.

That sets the volume (a property), navigates to the next track, plays, and then pauses. The #release at the end does this:


release
	super release.
	dispatcher release

Since COM uses external Windows objects, we want to ensure that they get released. I'll be adding a simple ObjectStudio GUI to this tomorrow - stay tuned to Smalltalk Daily for that!

The important take-away here is this: using ObjectStudio 8, you get all the power and productivity of Smalltalk (including all of the VisualWorks libraries) - and you still get to play natively with the Windows APIs. That's why it's Vista Certified.

Technorati Tags: , ,

Read: Using COM APIs in ObjectStudio

Topic: OpenGL, the GPU, and Smalltalk Previous Topic   Next Topic Topic: Attitude drives skill

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use