Color bug !!!!!!

Hi their,
Let me explain you my problem in detail.
I am trying to draw both GDI and OpenGL figures in a single window. GDI is in RGB mode. OpenGL is in Color Index mode. For both, i am using an user defined palette.
Hope so far is understood.

Now
Step1:- Fill the window background using FillRect by passing a brush created with an equivalent colorref of a color taken from the palette.
Eg: sb = CreateSolidBrush(0xc0c0f0);
FillRect(…,sb);
where 0xc0c0f0 is a eqivalent to color index 17 in the palette.

Step2:- For opengl set the index to 17 and draw a filled rectangle.

Now if you check the output you can see a slight difference in the background color and the rectangle fill color, even though i am using the same color for both.

I tried this in an NT with 65536 colours.

Hope you got the problem.

Please help me on finding a solution to this.