Friday, February 15, 2008

Enabling XP Look in a Microsoft Add-in

A common annoyance while writing Microsoft Office add-ins in .Net is that by default your windows show up with the old WinNT look. There's an "add a manifest file" solution suggested on the Internet. It works, yes, but it is kinda hackish. Besides, there's considerable pain involved in keeping track of that file while distributing the app etc.

There's a far simpler solution I ran into. Just add this line somewhere in your OnConnection() function:

System.Windows.Forms.Application.EnableVisualStyles()

This will magically make windows and dialogs sport the XP theme. There are no files to add or keep track of. Just sit back, scratch somewhere if you must and be pleased about not looking like the developer of a half-assed Office app any more.

Cheers.
---

Keywords: Office add-in, XP, theme, theming, Windows, look and feel, visual style.

Saturday, December 29, 2007

"Kitne Monte Cristo they?"

"Count bhool gaya mai-baap"

Saturday, July 07, 2007

In Ohio

The moon is asleep in its
Vast duvet of blackness.
The night has
No promise of luminosity.

Beside Lake Erie I'm sitting,
Inconvenienced by pebbles,
But my brain too drenched
In some opaque sensation to bother.

The water sparkles.
Tiny sounds emerge and enter my ears.
A modest steamer far way ─
Something talks to shadows.

I think of home.
I think of mother.
I think how, why I'm here
Away, so much removed
From all that's precious to me.

The breeze steals into my hair
And I hear the streamer grunt.
The water sparkles even more.
The Erie is indescribably beautiful.

Wednesday, June 13, 2007

Heed The Call

You sit alone
Beneath the tree of love

With sonnets by young poets
Alone and hollow.

Death's waters swelling in blue crests
Welcome thy spirit to the sea.

Set sail
On sunset waves. Leave tiny encumbrances here forever.

The wind will take thy hand
And guide you to where you've always wanted to go.

Be wise.
Heed the call.

Wednesday, May 02, 2007

Past

What’s a bad day
That lasts a decade?
What's happiness
Promised with living
That's a lifetime too late?

Terms would matter
If you only comprehend
Things slipping by memory,
Times and faces,
In a single, wistful blend.

And everything ─
Everything plunging
Into a million miles deep
Clouds of past.

Explanations don’t exist.
Logical cause-and-effect won't fit.
It happened. That's all ─
Get over and live with it.

Live you will,
But sometimes you’ll glance
At the what-could-have-been
And a bygone chance.

And think you didn’t deserve it
Then why were you wronged?
But you'll hear the whisper every time:
Why, to make me strong.

Wednesday, April 04, 2007

Idle Thoughts

1) I've discovered that the real self-confidence comes not from knowing that you are right, but from the realisation that while you could be wrong, just as easily everybody else could too. Therefore, strangely, the absence of an infallible yard-stick of truth actually empowers, not take anything away.

2) Which country makes the sturdiest automobile horns? India of course. With the use that they go through here, things would have been so different otherwise.

Their maintenance alone would've cost a fortune then. We'd perhaps have had shops built entirely around horn repair: "Get your horn repaired here, get a five lakh diamond necklace free". May be we'd have had colleges offering B. Techs in Horn Repair Technology. Who knows? Three year course. Jobs assured (duh!). And best of all, we could possibly have time and again lent our horn maintenance expertise to repair space modules or particle accelerators. Everybody would have called us affectionately as the Horn Repair Guys of the World.

But they are sturdy, aren't they? So may be all that's not too probable. But hey, at least our motorists are trying, you know, by honking their horns like crazy bitches wherever you go. I say, no matter what, we should call each one of them and tell them, "Really, hurray to you guys. We're so moved."

3) It's maddening to think that the moment that just passed is never, ever, coming back. It is as if there's a humongous black-hole chasing you all along your journey through life, its mouth wide open, swallowing from the smallest to the largest of things. Who knows, may be your death is merely the triumph of the black-hole when it makes a final run for it and catches up with you: "Gotcha, baby! You ain't going nowhere."

4) At least there are some questions that I've found answers to:

Q. What do you call Sean Connery after he's just had a hair-cut?
A. Shorn Connery.

Q. What's "a chink in the armour"?
A. A South East Asian wearing a chain-mail.

Q. And a "chink in the door"?
A. A Chinese dude leaning against one of the jambs.

Monday, November 20, 2006

Alone

Since I'm too sleepy to post any crap myself, I'll paste this Poe' poem here:


-- By Edgar Allan Poe

From childhood's hour I have not been
As others were; I have not seen
As others saw; I could not bring
My passions from a common spring.
From the same source I have not taken
My sorrow; I could not awaken
My heart to joy at the same tone;
And all I loved, I loved alone.
Then- in my childhood, in the dawn
Of a most stormy life- was drawn
From every depth of good and ill
The mystery which binds me still:
From the torrent, or the fountain,
From the red cliff of the mountain,
From the sun that round me rolled
In its autumn tint of gold,
From the lightning in the sky
As it passed me flying by,
From the thunder and the storm,
And the cloud that took the form
(When the rest of Heaven was blue)
Of a demon in my view.



I'm a huge fan of Poe's. He draws me not only with his exceptional skill as a writer, but also because of who he was. Though I can't recall much of whatever I've read about his life (except that he was an orphan and all that), his work easily says all about how he thought and reacted to things around him.

The most fabulous thing about Poe, to me, is his open-minded acceptance of the dark, the evil, the deathly, along with all that ─ perhaps this only to a little lesser degree ─ stands for the good, the positive and the living. He has this unwillingness to take exclusively the side of moral rectitude or, for that matter, to be too sure about anything. Most of his work admits implicitly ─ yet quite clearly ─ his difficulty to understand the world and classify its constituents as black and white. However, in this admission of ignorance, it's only his superior intelligence and perception that shines through.

This poem conveys all the above things. It also celebrates his individuality, his faculty to decide for himself what's right or wrong, happy or sad, black or white, as opposed to the following of any norm. Also, notice how a cloud appears to him like a demon in the end. He's never the one to thrust rainbows on you.

I just love Poe (and this Poe-m of his :D). There are few as good as him.

(And guess what, I ended up posting my own crap after all. I'm such an incorrigible mothefucker.)

Wednesday, October 25, 2006

City Of Bridges

In the city of bridges
Men sit hunched on parapets
And direct sad gazes
At car tail-lights
Streaking red blood wakes.

In the city of bridges
Illumination wafts in lofty air
And beneath, on the bruised tarmac,
Sprawl
Residues of darkness from sunless days.

In the city of bridges
Boxes hurtle
In the grime-laden sky,
Yet no one moves,
Destinations slip forever away,
And beginnings fall over railings and die.

Tuesday, October 24, 2006

Nightmare

He sat
Alone
And a poem he wrote

That he tossed
With lightness
And forgot.

But when he slept
At night,
Quiet,

It appeared—
Large, Brash
And iron-clawed.

In words
Flitted
Moonlight streaks

As it struck
Athwart
His pallid face;

As it dug
Its iambs
In pliant skin,

And drew blood
On
His angled cheeks.

Friday, September 15, 2006

Overheard

...in what we call an RTV here, a boxy, ramshackle, van like thing:

Driver: Ispeed to sahi pakde hai yeh.

Cleaner:
Ajee birake bhi jorawar hain iske. Ek nahi to do nahi to teen nahi to paanch chhai paidil [paddle] mein to ruk hi jave hai.

Driver: Haan, bas ek awaj hi thodi bhari bhari si kare hai, nahi to ghodi hai ghodi.

Saturday, August 12, 2006

Going Home Blues

I'm goin' home.
Oh I'm goin' home.

I won't be back
Till the independence day.
It'll just be a
Brief li'l holiday.
On the sixteenth of the month
I'll be here again.
Then till Diwali's time
Won't be goin' away.

Ohhhh I'm going home.
Baby, I'm going home.

That's right..

I'm goin' home.
Oh yeah, baby, I'm going hoooome.


(So no more crap till then)

Monday, August 07, 2006

That Thing

Your hands squirm in a sweat-soaked grip.
Nothing flows from your stymied lips.
Standing quiet in the August sun
You wait for your voice to come undone.

It's time baby you felt that thing
That blows in your ribs like an arid wind.
It's time baby you said something.
On your words our prettiest hopes are pinned.

Don't smother your mind; don't let it die.
You missed that chance, but don't quit trying.
The restless will, and the conscience free,
If you don't do their bidding, won't let you be.

It's time baby you said something,
Those words on which our hopes are pinned.
It's time baby you flapped your wings,
And flew just once up 'gainst the wind.

Friday, August 04, 2006

Overheard

... in the bus this morning:

"Yeh kaun si kitab hai?"

"Fundmentals of Business Administration."

"Business walon ke liye hai kya?"

"Kya?"

"Business walon ke liye hai?"

No answer.

"Ise bus mein leke kyun khade ho?"

"Yeh to...."

"Yahan koi na lene ka."

"Bech thode na..."

"Red light pe becho. Yahan koi na lene ka."

Thursday, August 03, 2006

Presence

Who are you the mum declaimer?
Who are you the masked lurker?
Who are you the fuzzily present?
Who are you alone and sobbing?

Who are you?

How are you?

What is it that keeps you breathing?

Saturday, June 17, 2006

An Exchange

"Who gives a fuck?"

"Not me. I like to keep mine with meself."

Monday, June 12, 2006

My Rules

I have only two rules in life:

1. Never take yourself seriously.

2. Rule 1. is a joke.

.. Am I the Only One

Is anyone else, too, lost irreversibly for words?
Or am I the only one holding little mouthfuls of vaccum?

Is anyone else, too, seeking bloody knots of viscera?
Or am I the only one rapt gazing inwards?

Is anyone else, too, tossing stained tissues to dustbins?
Or am I the only one with a mist of blood on my breath?

Is anyone else, too, falling slowly numb to stimulus?
Or am I the only one having his head gently hewn off?

Is anyone else, too, driving down this road in gaiety?
Or am I only one adrift, celebrating, to decadance.

Is anyone else, too, dying to get beyond it?
Or am I the only one who has had enough of Animation?

Monday, May 22, 2006

Knickknacks

The old man wailed, "I'm the father".
His words fell down, and dissolved in rain.
In a simple thought are easily gathered
Ghosts of misery and ogres of pain.

A red flag flies
On a guarding post.
In the tall growth of corn
Two lives are lost

Grey stone bridge is an ancient relic
Under it lies an unclothed river.
"Your heart, my darling, is truly angelic
I could rip it out, but my hand quivers."

From far-flung towns
Souls in gowns
Congregate
In verdant lawns,
And utter softly
Indistinct sounds.

Saturday, May 13, 2006

In Memoriam

A piece of blue velvet
And wings of butterflies;
Phials of poison
And a bottle of wine;
Emerald marbles,
Red cricket balls;
Pictures of saints
On whitewashed walls;
Stiff, wooden fish
With dull silver fins;
A buoyant li’l boy
In a sun burnt skin.

Nothing stirs;
It’s mortally still.
Can’t come back –
It never will.

Friday, May 05, 2006

What's up with the Pascalian existentialist who joined ISKON?

He just sits there and sings all day:

Memento mori main nahi maakhan khayeyo,
Memento mori main nahi maakhan khayeyo.

:-p

Friday, April 21, 2006

Lonesome Death

As the sun in the sky drags quietly
Its sure yet slothful feet,
The sand burns on the ground like pearls
'Round the nape of a demon of heat.

The flaps of the tent dance as mad-men.
The coarse black canvas is awash
With winds from the south o’ this endless desert
Bearing scents of our joyous pasts.

Crimson cummerbunds around our waists,
And soft, black heckles on our heads,
As a baleful storm is a-brew on the dunes
We’re just about dead in our beds.

Hear O hear, O my prettiest darling
Is your breast still a tiny bit sore?
Or the shaft of iron has turned to a feather
And you can't feel the knife any more?

This Isfahan carpet with pictures of kings
And scenes from the battles of yore
Is stealing my life through a hole in my temple,
And is steeped in my blood and gore.

Your face is pale as the skin of a lizard,
My tongue as dry as a stone.
Our voices lost, our breaths are slowing,
Not long when we’ll be gone.

But will this tale be known again,
This song of our lonesome death?
Will it forever wander in the ear of these sands?
Will it perish upon our breaths?

Monday, April 10, 2006

Summer In Delhi

In the middle of the noon,
The huge, crackling fireball,
A man takes a walk
Wearing pink corduroys
And shoes without soles
Over the searing blackness
Of hard concrete.

A large black crow
Of shiny feathers
Crawls in the skies
And drags under its belly
A withersome shadow
'Cross the searing blackness
Of hard concrete

Cars roll
Up slopes of bridges
Down slopes of bridges
And suck dry refuse
In their shimmering wakes
On the searing blackness
Of hard concrete.

And steel bus-stops
With black green names,
And sparse little trees
Spill chequered shades
That meld in the lap
Of the searing blackness
Of hard concrete.

In the solace of petals
And moist, tender leaves,
Of an unlit alcove
Hides a decadent frame.
And lying right by
The smashed forehead
A big, jagged rock
Has smeared over it
Cold, cold blackness
Of hard concrete.

Friday, February 03, 2006

Howto: Calling DASSL from C++

I am not going to tell what DASSL is; since you've continued past the semicolon, I'll just assume you already know that. What I am going to tell you here is how you can go about calling DASSL, which is written in FORTRAN, from within a C++ program. If any of this matters to you, you may read on.

I've written this howto out of my own experience. For a simulation application I'm writing, I needed to call DASSL from within Microsoft Visual C++ 6.0; and I didn't know how to do that. I searched for days over the Internet but found only scattered pieces of information that each, taken alone, was of as much use to me as a pair of low-rise jeans is to a dining table. Yet, I continued to experiment and try all sorts of things (some of which can't be mentioned in a polite gathering); and so it went on for a week. Then, after all the efforts, one day, a call to DASSL went through -- just like that. The code ran without a hitch.

And as I sat there shouting, "Yoo hoo. Sweet bleedin' mama", I knew, the way had been found.

So, since I've been there and done all that, you can appreciate that I understand your pain very well. And as a pioneer, I feel but bound to share my experience in a simple, step-by-step format to spare you, and all those yet to be born, any more undeserved distress.

Take heart ye all, for the fort of Calling DASSL from C++ has been taken.

Okay, without any further ado and bad metaphors, comerades, here down to business we get:


First, assumptions and other prologue-y things:
1) DASSL is written in FORTRAN. I don't know if it's FORTRAN 77, FORTRAN 95 or FORTRAN TWO THOUSAND AND FIFTY FOUR. It makes no difference to what we are trying to achieve here.

2) I work on Microsoft Visual C++ 6.0 (MSVC6) on Windows XP. So whatever I say here applies to this platform alone. I'm not sure if this works with GCC and Unix or even the old versions of Windows and MSCV; but I believe whatever I did in my case would not be too different from what you’ll need to do on your platform. So, if you have to, adapt this howto to your needs.

3) My FORTRAN compiler is g95. It’s a free, open-source compiler. FORTRAN compilers vary in how they decorate compiled code and all that. I do not claim knowledge about all those issues. I used g95 and was happy. You will be too; take my word.

4) Three flavours of DASSL are available: DASKR, DASPK and DASSL. In this howto I shall use the name DASSL, irrespective of which of the three you're using. What I say here applies to all of them equally well.

So that’s that. Let’s now get on with how actually to do it.

The steps for making it happen:
1) Download the DASSL source code from here. Choose DASKR, DASPK, or DASSL as per your requirements. The procedure for calling them from MSVC is exactly the same, except, of course, the signature of the function call in each case.

After downloading the zipped file (ddassl.tgz), unzip it. You’ll now have a folder called DASSL with the following files in it: daux.f, ddassl.f, and dlinpk.f.

2) Download g95 from this place. Follow the instructions on the g95 website and install it.

3) Next, you need to compile the DASSL code with g95. Go to the DASSL folder, compile the three files with the following command:

g95 –c daux.f ddassl.f dlinpk

After compilation you’ll find three new, object files in the same folder: daux.o, ddassl.o, and dlinpk.o. The option “-c” ensures that g95 merely compiles the three files and does not attempt to link them together. We’ll be doing the linking job later with MSVC.

4) Create your C++ project in MSVC6. Declare the DASSL call in C++. In my case the declaration looked like this:

extern "C" void ddassl_(
void (*funcptr)(const double& time, const double y[], const double yPrime[], double residue[], int& iRes, const double rPar[], const int iPar[]),
const int& noOfEquations,
const double& currentTime,
const double initialY[],
const double initialYPrime[],
const double& finalTime,
const int info[15],
const double& relativeTolerance,
const double& absoluteTolerance,
int& outputStatusFlag,
const double dWorkArray[],
const int& lengthOfDWork,
const int iWorkArray[],
const int& lengthOfIWork,
const double rParArray[],
const int iParArray[],
void (*jacobian)(const double& time, const double y[], const double yPrime[], double** PD, double& CJ, double rPar[], int iPar[])
);



There are two important aspects of this declaration. First, the declaration is preceded with an extern "C". You need this to avoid name mangling which C++ compilers do. Second, the function name ddassl is suffixed with an underscore. This is important owing to function name issues involved in calling FORTRAN and C++ code from each other. Since I stumbled upon al this by hit and trial, don't expect reasons for this. It works, and that's enough.

The rest of the declaration is nothing remarkable. Read your DASSL documentation to understand it.

5) Next, copy the three object files obtained in step 3 to the folder where your above-mentioned MSVC6 project lies (let's call it the 'project folder'). Also go to the folder where g95 is installed. Once in the g95 folder, follow this path: \lib\gcc-lib\i686-pc-mingw32\4.0.2. In the folder 4.0.2 find two files: libf95.a and libgcc.a. Copy them to the project folder. Now, apart from the C++ files and MSVC files, you have the following files in the project folder: daux.o, ddassl.o, dlinpk.o, libf95.a and libgcc.a. We're going to need these files for linking.

6) Open your C++ prject. Go to Project->Settings->link. Under the field "Object/library modules", enter this: daux.o, ddassl.o, dlinpk.o, libf95.a, libgcc.a. This step adds the requisite libraries and object files the MSVC6 linker is going to need.

7) You're ready to link now. Run the MSVC6 linker. It'll first -- of course -- compile the C++ code and then link it with the above mentioned 5 files.

8) Your work is done. Now call DASSL with apropriate arguments. It should run without problem.

9) Let out a sigh of relief. Go get yourself coffee. Come back. Backslap the dude sitting next to you and ask, "Isn't it a lovely motherfuckin' day, my friend?".

Last words:
I did this exactly as I've described. If it doesn't work for you, you can write to me the email address: gurry_uor at yahoo dot co dot uk. I might also in haste have made mistakes above; point them out to me.

Another friendly tip: your simulation is most likely to be a hybrid simulation. What that means is that you have at least one variable which, with time, goes through a variation which is either discontinuous or its first derivative is discontinuous. DASSL, let it be known, cannot reliably integrate past such discontinuities in the zeroth and the first order. So you'll have to stop your integration whenever any discontinuity is encountered, then reset the initial conditions and then restart it. All major simulation software packages do that; you shall have to too. Read this book for more information.

Though I've focussed on DASSL here, you can use the same approach as above to call any FORTRAN function from MSVC6. I'm sure the astute reader -- look how the rascal's smiling -- would have figured that out already.

Allright, I hope this helps. Google spiders will pick this page up the next month and I hope troubled souls with DASSL afflictions like mine shall then come and find solace here.

I'm outta here.

Idle Thoughts

1) If I were a gigolo, I'd have made sure that I had "SATISFACTION GUARANTEED" tattooed on my lower abdomen before I took any clients.

2) Running the tips of fingers over one's own stubble is the cheapest possible time-warp device available to men.

Women, on the other hand, have childbirth.

3) I chew fast. It makes me feel full of purpose.

4) I wonder how much one's name influences one's personality. I can scarcely imagine how I'd have been had I been named Chaman Lal.

5) Ever had your upper lip throb? It's the queerest sensation.

6) It is strange how you'll never get to have a clear, intimate view of the most organs of your body. In fact, in all probability, you'll die without ever setting eyes on your the great majority of your inner parts that make your life possible. Would it have made me a different person had I been able to look, as if through a glass, upon my own beating heart; and perhaps somehow have a peek at the blood-red, tiny arteries in my cerebral cortex? How about if our skins were of a completely see-through material? Would it have made ouselves more conscious of our existence? Or more beautiful?

7) I think the drive to reproduce is inseparably tied to self-love and the subconscious desire to see ourselves replicated. And, paradoxically, as parents, that's our greatest undoing.

Sunday, January 22, 2006

Fire And Ice

-- By Robert Frost

Some say the world will end in fire;
Some say in ice.
From what I've tasted of desire
I hold with those who favor fire.
But if it had to perish twice,
I think I know enough of hate
To know that for destruction ice
Is also great
And would suffice