Sunday, December 28, 2008

First guitar class......

Wow that was great!!!!!!!.I had my first guitar classes yesterday around 2'o clock(time is auspicious).

Around 10 to 12 guys were there all younger than me....some studying in 4th some in 9th etc....It was really nice mingling with them and sharing some nice jokes with them.

Coming to guitar as its a string instrument ,what the master told me was it requires a lot of training/regular practice to play it.I am really looking forward to it.He told me about some notations,open strings like that.I am on the lookout for a guitar now to have more practice @ home if there is time.Work is hectic now a days.The good part is that every art form whether its dance,music or other miscellaneous ones,they all causes an increase in the level of concentarion.

I think its the PinkFloyd,Eagles,Metallica and even IndianOcean that pushed me to land onto the world of guitar.

Saturday, December 27, 2008

just to keep going.......

Today, upon a bus, I saw a girl with golden hair

I looked at her and sighed and wished I was as fair.

When suddenly she rose to leave,

I saw her hobble down the aisle.

She had one leg and used a crutch

But as she passed, she passed a smile.

Oh, God, forgive me when I whine

I have 2 legs, the world is mine.

~~~

I stopped to buy some candy

The lad who sold it had such charm

I talked with him a while, he seemed so very glad

If I were late, it'd do no harm.

And as I left, he said to me,

"I thank you, you've been so kind.

It's nice to talk with folks like you.

You see," he said, "I'm blind."

Oh, God, forgive me when I whine.

I have 2 eyes, the world is mine.

~~~

Later while walking down the street,

I saw a child with eyes of blue

He stood and watched the others play

He did not know what to do.

I stopped a moment and then I said,

"Why don't you join the others, dear?"

He looked ahead without a word.

And then I knew, he couldn't hear.

Oh, God, forgive me when I whine.

I have 2 ears, the world is mine.

~~~

With feet to take me where I'd go.

With eyes to see the sunset's glow.

With ears to hear what I would know.

Oh, God, forgive me when I whine.

I've been blessed indeed, The world is mine.

~~~~~~~~~~~~~~~~~~

after all, it's just a simple reminder....

We have soooooo much to be thankful for!!!

~~~~~~

Sorrow looks back,

Worry looks around,

Faith looks up.

Saturday, December 6, 2008

Jury is hung........

In a small town in India, a person decided to open up his bar business, which was right opposite the temple. The temple and its congregation started a campaign to block the bar from opening with petitions and prayed daily against his business. Work progressed, however, when it was almost complete and was about to open a few days later, a strong bolt of lightening struck the bar and it was burnt to the ground. The temple folks were rather smug in their outlook after that, till the bar owner sued the temple authorities on the grounds that the temple through its congregation and prayers was ultimately responsible for the demise of his bar, either through direct or indirect means.

In its reply to the court, the temple vehemently denied all responsibility or any connection that their prayers were reasons to the bar’s demise. As the case made its way into the court, the judge looked over the paperwork at the hearing and commented: “I don’t know how I’m going to decide this case, but it appears from the paperwork, we have a bar owner who believes in the power of prayer and we have an entire temple and its devotees that doesn’t.”

Wednesday, November 26, 2008

Toothless Night......

Oh.............my tooth was extracted today..............

I thought of a poem which I studied in my school days abt dentist and the vicious circle......

This Is Going To Hurt Just A Little Bit

One thing I like less than most things is sitting in a dentist chair with my mouth wide open.

And that I will never have to do it again is a hope that I am against hope hopen.

Because some tortures are physical and some are mental,
But the one that is both is dental.
It is hard to be self-possessed
With your jaw digging into your chest.

So hard to retain your calm
When your fingernails are making serious alterations in your life line or love line or some other important line in your palm;

So hard to give your usual effect of cheery benignity
When you know your position is one of the two or three in life most lacking in dignity.

And your mouth is like a section of road that is being worked on.
And it is all cluttered up with stone crushers and concrete mixers and drills and steam rollers and there isn’t a nerve in your head thatyou aren’t being irked on.

Oh, some people are unfortunate enough to be strung up by thumbs.
And others have things done to their gums,
And your teeth are supposed to be being polished,
But you have reason to believe they are being demolished.

And the circumstance that adds most to your terror
Is that it’s all done with a mirror,
Because the dentist may be a bear, or as the Romans used to say, only they were referring to a feminine bear when they said it, an ursa,
But all the same how can you be sure when he takes his crowbar in one hand and mirror in the other he won’t get mixed up, the way you do when you try to tie a bow tie with the aid of a mirror, and forget that left is right and vice versa?

And then at last he says That will be all; but it isn’t because he then coats your mouth from cellar to roof
With something that I suspect is generally used to put a shine on a horse’s hoof.

And you totter to your feet and think. Well it’s all over now and afterall it was only this once.
And he says come back in three monce.

And this, O Fate, is I think the most vicious circle that thou ever sentest,
That Man has to go continually to the dentist to keep his teeth in good condition
when the chief reason he wants his teeth in good condition
is so that he won’t have to go to the dentist.

Sunday, November 23, 2008

Options b4 me......................

Jotting down the options now I have..............

1)Looking 4 another job.....which comes naturally.......

2)Further study................which also comes naturally........

3)Do something different.................doing some social activities,joining some social activity club(which is not part of any religious structure.......)

4)Leave India......................which is another thing......dont have much savings....

Expecting more in coming days.............

Saturday, November 22, 2008

The power of Now.......



I humbly request you all to read the book...............and see the difference

Jobless @ recession

Wow wat a feeling to hav worked for abt 3 years and then resign the post at the time of economic slowdown or recession...watever ........

So many stares from here and there........................friends saying to rethink the matter seriously..........buts its all over now..........

No regrets: done wat my mind says........a nice feeling...............

Wednesday, October 29, 2008

Under the Same Sun - Scorpions

I saw the morning
It was shattered by a gun
Heard a scream, saw him fall, no one cried
I saw a mother
She was praying for her son
Bring him back, let him live, dont let him die

Do you ever ask yourself
Is there a heaven in the sky
Why cant we get it right

cause we all live under the same sun
We all walk under the same moon
Then why, why cant we live as one

I saw the evening
Fading shadows one by one
We watch the lamb, lay down to the sacrifice
I saw the children
The children of the sun
How they wept, how they bled, how they died

Do you ever ask yourself
Is there a heaven in the sky
Why cant we stop the fight

cause we all live under the same sun
We all walk under the same moon
Then why, why cant we live as one

Sometimes I think Im going mad
Were loosing all we had and no one seems to care
But in my heart it doesnt change
Weve got to rearrange and bring our world some love

And does it really matter
If theres a heaven up above
We sure could use some love

cause we all live under the same sun
We all walk under the same moon
Then why, why cant we live as one
cause we all live under the same sky
We all look up at the same stars
Then why, tell me why cant we live as one

PinkFloyd - HighHopes lyrics

Beyond the horizon of the place we lived when we were young
In a world of magnets and miracles
Our troughts strayed constandly and without boundary
The ringing of the division bell had begin

Along the long road and on down the causeway
Do they still meet there by the cut

There was a ragged band that followed in our footsteps
Running before time took our dreams away
Leaving the myriad small creatures trying to tie us to the ground
To a life consumed by slow decay

The grass was greener
The light was brighter
With friends surrounded
The night of wonder

Looking beyond the embers of bridges glowing behind us
To a glimpse of how green it was on the other side
Steps taken forwards but sleepwalking back again
Dragged by the force of some inner tide

At a higher altitude with flag unfuried
We reached the dizzy heights of that dreamed of world

Eneumbered forever by desire and ambition
Theres a hunger still unsatisfied
Our weary eyes still stray to the horizon
Though down this road weve been so many time

The grass was greener
The light was brighter
The taste was sweeter
The nights of wonder
With friends surrounded
The dawn mist glowing
The water flowing
The endless river

Forever and ever

Metallica Nothing Else Matters Lyrics

So close no matter how far
Couldnt be much more from the heart
Forever trusting who we are
And nothing else matters

Never opened myself this way
Life is ours, we live it our way
All these words I dont just say
And nothing else matters

Trust I seek and I find in you
Every day for us something new
Open mind for a different view
And nothing else matters

Never cared for what they do
Never cared for what they know
But I know

So close no matter how far
Couldnt be much more from the heart
Forever trusting who we are
And nothing else matters

Never cared for what they do
Never cared for what they know
But I know

Never opened myself this way
Life is ours, we live it our way
All these words I dont just say
And nothing else matters

Trust I seek and I find in you
Every day for us something new
Open mind for a different view
And nothing else matters

Never cared for what they say
Never cared for games they play
Never cared for what they do
Never cared for what they know
And I know

So close no matter how far
Couldnt be much more from the heart
Forever trusting who we are
No nothing else matters

Friday, October 24, 2008

Send Me an Angel -Scorpions lyrics

The wise man said just walk this way
To the dawn of the light
The wind will blow into your face
As the years pass you by
Hear this voice from deep inside
Its the call of your heart
Close your eyes and your will find
The passage out of the dark

Here I am
Will you send me an angel
Here I am
In the land of the morning star

The wise man said just find your place
In the eye of the storm
Seek the roses along the way
Just beware of the thorns

Here I am
Will you send me an angel
Here I am
In the land of the morning star

The wise man said just raise your hand
And reach out for the spell
Find the door to the promised land
Just believe in yourself
Hear this voice from deep inside
Its the call of your heart
Close your eyes and your will find
The way out of the dark

Here I am
Will you send me an angel
Here I am
In the land of the morning star
Here I am
Will you send me an angel
Here I am
In the land of the morning star

Addicted to Rock

My colleague(Binosh) opened the gateway to rock music to me.The first few songs which got hooked me are :

PinkFloyd - HighHopes,
Scorpions - Send Me An angel,
Metallica - Nothing Else Matters,
Scorpions - Under the Same Sun,
Scorpions - Wind Of Change etc................

My next few posts will be the lyrics of these songs

Thursday, October 9, 2008

Stellant Outside In Text Access C# Interface

I was working now mostly(almost 2 months and not finished yet!!!!) on a fulltext search engine development for our document management system.

Lucene.NET was the underlying search engine using by us.

Our company is now a Oracle Development partner as well!!!!!!!!So all the oracle development tools are available just like the Microsofts.

In that a content access library is there (in C and C++),which would give the text of a file.So that thing is useful for us in the fulltext search engine devlopment.

So last week my main job was to convert the api functions to C#.At first it didnt work for some silly parameters problems.One of my colleagues(asan-sen)just changed that and it was working smoothly now.

So the functions are the following:
[DllImport("sccda.dll",CallingConvention=CallingConvention.Cdecl,CharSet=CharSet.Auto)]
public static extern uint DAOpenDocument(ref uint hDoc,uint dwSpecType,IntPtr pSpec,uint dwFlags);
[DllImport("sccda.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
public static extern uint DACloseDocument(uint hDoc);
[DllImport("sccda.dll",CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern uint DAInit();
[DllImport("sccta.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern uint TAOpenText(uint hDoc, ref uint phText);
[DllImport("sccta.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern uint TACloseText(uint phText);
[DllImport("sccta.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern uint TAReadFirst(uint phText, IntPtr textData, uint bufferSize, ref uint pBufCount);
[DllImport("sccta.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern uint TAReadNext(uint phText, IntPtr textData, uint bufferSize, ref uint pBufCount);

Wednesday, August 13, 2008

Set DisplayName to a property to shown in a datagridview

We have a class or a structure which contains few properties which are bound to a
datagrid.

The example class is like this:

public class Details
{
private string vaultName;
private bool isBackUp;
private bool isArchive;
private string vaultLocation;


public bool IsBackUp
{
get { return isBackUp; }
set { isBackUp = value; }
}
public string VaultName
{
get { return vaultName; }
set { vaultName = value; }
}
public bool IsArchive
{
get { return isArchive; }
set { isArchive = value; }
}
public string VaultLocation
{
get { return vaultLocation; }
set { vaultLocation = value; }
}
}
The datagrid when bounded look like this:


That contains just the property names as the column headers which are not meaningfull to users.

So if we want to show other names , we can just add DisplayName attribute to the
property.Just like this:

public class Details
{
private string vaultName;
private bool isBackUp;
private bool isArchive;
private string vaultLocation;

[DisplayName("Add")]
public bool IsBackUp
{
get { return isBackUp; }
set { isBackUp = value; }
}
public string VaultName
{
get { return vaultName; }
set { vaultName = value; }
}
[DisplayName("Add Repository")]
public bool IsArchive
{
get { return isArchive; }
set { isArchive = value; }
}
public string VaultLocation
{
get { return vaultLocation; }
set { vaultLocation = value; }
}
}
Now the datagridview look like this:


Ajith

Wednesday, July 23, 2008

the Attitude Part

One of my friends penned me these lines and I find it very true in every sense

The longer I live, the more I realize the impact of attitude on life.



It is more important that the past, than education, than money, than circumstances, than failures, than successes, than what other people think or say or do. It is more important than appearance, giftedness or skill.



The remarkable thing is - we have a choice every day of our lives regarding the attitude we embrace for that day.



We cannot change our past. We cannot change the fact that people will act in a certain way. We cannot change the inevitable.



The only thing we can do is play on the one string we have, and that is our attitude.



I’m convinced that life is 10% what happens to me and 90% how I react to it. And so it is with you.



We are in charge of our attitudes.



~ Charles Swindoll ~

Monday, July 14, 2008

Lucene Searching GuideLines

Searching Guidelines

Lucene allow searching and indexing simultaneously. However, an IndexReader only searches the index as of the "point in time" that it was opened. Either any updates to the index, added or deleted documents, will not be visible until the IndexReader is re-opened. Therefore, your application must periodically re-open its IndexReaders to see the latest updates. The IndexReader.isCurrent() method allows you to test whether any updates have occurred to the index since your IndexReader was opened.
Lucene supports wild card queries which allow you to perform searches such as book*, which will find documents containing termssuch as book, bookstore, booklet, etc. Lucene refers to this type of aquery as a 'prefix query'.

Lucene also supports wild card queries, which allow you to place a wild card in the middle of the query term. For instance, you could make searches like: mi*pelling. That will match both misspelling, which is the correct way to spell this word, as well as mispelling, which is a common spelling mistake.

Another wild card character that you can use is '?', a question mark. The ? will match a single character. This allows you to perform queries such as Bra?il. Such a query will match both Brasil and Brazil. Lucene refers to this type of a query as a 'wildcard query'.

Leading wildcards (e.g. *ook) are not supported by the QueryParser by default. As of Lucene 2.1, they can be enabled by calling QueryParser.setAllowLeadingWildcard (true ). Note that this can be an expensive operation: it requires scanning the list of tokens in the index in its entirety to look for those that match the pattern.

To restrict searches to only return results from a limited subset of documents in the index (e.g. for privacy reasons) The QueryFilter class is designed precisely for such cases.
Another way of doing it is the following: Just before calling IndexSearcher.search() add a clause to the query to exclude documents in categories not permitted for this search.

If you are restricting access with a prohibited term, and someone tries to require that term, then the prohibited restriction wins. If you are restricting access with a required term, and they try prohibiting that term, then they will get no documents in their search result.

As for deciding whether to use required or prohibited terms, if possible, you should choose the method that names the less frequent term. That will make queries faster.

Lucene Introduction

Lucene.Net is a source code, class-per-class, API-per-API and algorithmatic port of the Java Lucene search engine to the C# and .NET platform utilizing Microsoft .NET Framework.

Lucene.Net sticks to the APIs and classes used in the original Java implementation of Lucene. The API names as well as class names are preserved with the intention of giving Lucene.Net the look and feel of the C# language and the .NET Framework. For example, the method Hits.length() in the Java implementation now reads Hits.Length() in the C# port.
In addition to the APIs and classes port to C#, the algorithm of Java Lucene is ported to C# Lucene. This means an index created with Java Lucene is back-and-forth compatible with the C# Lucene; both at reading, writing and updating. In fact a Lucene index can be concurrently searched and updated using Java Lucene and C# Lucene processes.

Lucene.NET version 2.1 is available which is VS2005 compatible version.

Lucene Indexing

Friday, May 30, 2008

Creating Single Instance Application C#

In the class of my application main I created a static named Mutex:

static class Program {
static Mutex mutex = new Mutex(true, "MyMuteX");
[STAThread]
...
}

By having a named mutex allows us to stack synchronization across threads and processes which is just the magic I'm looking for.

Mutex.WaitOne has an overload that specifies an amount of time for us to wait. Since we're not actually wanting to synchronizing our code (more just check if it is currently in use) we use the overload with two parameters: Mutex.WaitOne(Timespan timeout, bool exitContext). Wait one returns true if it is able to enter, and false if it wasn't. In this case, we don't want to wait at all; If our mutex is being used, skip it, and move on, so we pass in TimeSpan.Zero (wait 0 milliseconds), and set the exitContext to true so we can exit the synchronization context before we try to aquire a lock on it. Using this, we wrap our Application.Run code inside something like this:

static class Program {
static Mutex mutex = new Mutex(true, "{8F6F0AC4-B9A1-45fd-A8CF-72F04E6BDE8F}");
[STAThread]
static void Main() {
if(mutex.WaitOne(TimeSpan.Zero, true)) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
mutex.ReleaseMutex();
} else {
MessageBox.Show("only one instance at a time");
}
}
}

So, if our app is running, WaitOne will return false, and we'll get a message box.

Instead of showing a message box, I opted to utilize a little Win32 to notify my running instance that someone forgot that it was already running (by bringing itself to the top of all the other windows). To achieve this I used PostMessage to broadcast a message to every window (that I had previously registered with RegisterWindowMessage) then my second instance exits. The running application instance would receive that notification and process it. In order to do that, I overrode WndProc in my main form and listened for my custom notification. When I received that notification I set the form's TopMost property to true to bring it up on top.

Here is what I ended up with:

Program.cs

static class Program {
static Mutex mutex = new Mutex(true, "{8F6F0AC4-B9A1-45fd-A8CF-72F04E6BDE8F}");
[STAThread]
static void Main() {
if(mutex.WaitOne(TimeSpan.Zero, true)) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
mutex.ReleaseMutex();
} else {
// send our Win32 message to make the currently running instance
// jump on top of all the other windows
NativeMethods.PostMessage(
(IntPtr)NativeMethods.HWND_BROADCAST,
NativeMethods.WM_SHOWME,
IntPtr.Zero,
IntPtr.Zero);
}
}
}

NativeMethods.cs

// this class just wraps some Win32 stuffthat we're going to use
internal class NativeMethods {
public const int HWND_BROADCAST = 0xffff;
public static readonly int WM_SHOWME = RegisterWindowMessage("WM_SHOWME");
[DllImport("user32")]
public static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
[DllImport("user32")]
public static extern int RegisterWindowMessage(string message);
}

and

Form1.cs (front side partial)

public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
protected override void WndProc(ref Message m) {
if(m.Msg == NativeMethods.WM_SHOWME) {
ShowMe();
}
base.WndProc(ref m);
}
private void ShowMe() {
if(WindowState == FormWindowState.Minimized) {
WindowState = FormWindowState.Normal;
}
// get our current "TopMost" value (ours will always be false though)
bool top = TopMost;
// make our form jump to the top of everything
TopMost = true;
// set it back to whatever it was
TopMost = top;
}
}

Wednesday, March 5, 2008

Standby or Hibernate Windows Programmatically

One of the features of Microsoft Windows is the ability to enter standby or hibernation power-saving states that can be resumed at a later time. Usually the system is paused using the Start menu. However, using .NET 2.0, this can be achieved in code.
Application Class

The .NET framework defines the Application class that contains static methods that are used to start and stop applications, obtain information about the current program and process Windows messages. In the .NET framework version 2.0 and later, the Application class includes a method named SetSuspendState, which permits a program to request that the computer is suspended.
SetSuspendState Parameters

The SetSuspendState method requires three parameters. The first parameter determines whether the computer is to be put into a standby or hibernation power state. The parameter accepts a PowerState enumeration value of either Hibernate or Suspend accordingly.

The second operand is a Boolean value that tells the command whether to force a suspend. If set to true, the system is suspended immediately. If set to false, a message is sent to every other running process to request a standby or hibernation. This preferred method allows other programs to react to the message and possibly prevent the action.

The third parameter is another Boolean value. This parameter indicates whether standard wake events will cause Windows to resume automatically. An example of a wake event is a network message from a central system that starts the computer in readiness for a remote backup operation.
Requesting a Suspend State

Using the SetSuspendState method as described above, a standby can be requested using the following line of code. In this case, the standby is not forced and the system will restart in response to wake events.

Application.SetSuspendState(PowerState.Suspend, false, false);

The second example below performs a forced hibernation of the system and disables automatic resuming due to wake events. NB: Ensure that you save all work in all active processes before testing this code.

Application.SetSuspendState(PowerState.Hibernate, true, true);

Sunday, January 27, 2008

to have controls in a toolbar in MFC

int nIdx = CommandToIndex(nToolBarBtnID);
ASSERT( nIdx >= 0 );
SetButtonInfo(nIdx, nComboID, TBBS_SEPARATOR, 50);
const int nDropHeight = 50;
CRect rect;
GetItemRect(nIdx, &rect);
rect.top = 1;
rect.bottom = rect.top + nDropHeight;
if (!m_comboBox.Create(CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP | WS_CHILD, rect, this, nComboID))
{
TRACE0("Failed to create combobox in ToolBar\n");
return false;
}
// update the combo with a font.
m_comboFont.CreatePointFont( 80,_T("MS Sans Serif"));
m_comboBox.SetFont( &m_comboFont );
m_comboBox.EnableWindow(FALSE);
// show the combobox.
m_comboBox.ShowWindow( SW_SHOWNORMAL );
return true;

In the toolbar that you have created make a button which will be place holder for the
combo(control in this example).....

just pass the placeholders Id and a new Id for the combo box

to align toolbar side by side MFC

this is the function,just call this with the two toolbars that you have

void CMainFrame::DockControlBarLeftOf(CToolBar* Bar, CToolBar* LeftOf)
{
CRect rect;
DWORD dw;
UINT n;

// get MFC to adjust the dimensions of all docked ToolBars
// so that GetWindowRect will be accurate
RecalcLayout(TRUE);

LeftOf->GetWindowRect(&rect);
rect.OffsetRect(1,0);
dw=LeftOf->GetBarStyle();
n = 0;
n = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;

// When we take the default parameters on rect, DockControlBar will dock
// each Toolbar on a seperate line. By calculating a rectangle, we
// are simulating a Toolbar being dragged to that location and docked.
DockControlBar(Bar,n,&rect);
}

and on the OnCreate of MainFrame calling is done like this

m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);


m_wndMergeToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBarLeftOf(&m_wndMergeToolBar,&m_wndToolBar);

Monday, January 7, 2008

Diasble/Enable Menuitem in MFC

CMenu menu;
> menu.LoadMenu(IDR_MNU_THUMB);
>
> CMenu* pmnuPopup = menu.GetSubMenu(0);
>
> CWnd* pwndPopupOwner = this;
>
>
> if(...some conditions)
> {
> pmnuPopup->EnableMenuItem(ID_FILE_RESTORE,
> MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
> }
>
> pmnuPopup->TrackPopupMenu(TPM_LEFTALIGN |
> TPM_RIGHTBUTTON, point.x, point.y, pwndPopupOwner);
> }

Sunday, January 6, 2008

To remove a toolbar button programmatically?

void CMainFrame::OnDelete( )
{
m_wndToolBar.SendMessage ( TB_DELETEBUTTON, ( WPARAM ) 0 ) ;
}
Here, we have called SendMessage( ) function and passed it the message TB_DELETEBUTTON, as we want a toolbar button to be deleted and a zero-based index of the button to be deleted.

Thursday, January 3, 2008

SetFocus to an Edit Control in a Dialog MFC

n your OnInitDialog handler for the dialog, set focus to the control with
something like...

((CEdit*)GetDlgItem(IDC_PREFERRED_EDIT_BOX))->SetFocus();

or via a control mapped variable...

m_ctrlPrefferedEditBox->SetFocus();

Finally, return FALSE from the OnInitDialog handler.