Maisonave
asked on
How is the pallete changed using the CPallete Class
How is the pallete changed using the CPallete Class.
I want to know how to change the pallete on a window using the CPallete class.
I want to know how to change the pallete on a window using the CPallete class.
ASKER
I don't have access to MSDN library.
I already new that a CPalette instance had to be created.
My question was how do I use the class to change the palette of a window.
For example, I have the following code:
CFile file;
CPalette palette;
MYPALETTE pal;
pal.palVersion = 0x300;
pal.palNumEntries = 256;
CString palettefile = FileLocation.Left(FileLoca tion.Rever seFind('\\ ')+1) + "palette.dat";
if (!file.Open(palettefile, CFile::modeRead, NULL))
{
return;
}
file.Read(&pal.palPalEntry ,768);
file.Close();
palette.CreatePalette((tag LOGPALETTE *) &pal);
PALETTEENTRY pal_s;
for (int p = 0;p<256;p++)
{
memcpy(&pal_s,pal.palPalEn try+p*3,3) ;
palette.SetPaletteEntries( p, 1,&pal_s);
}
m_Static.GetDC()->SelectPa lette(&pal ette, FALSE);
m_Static.GetDC()->RealizeP alette();
//************************ ********** ********** ********** ********** ****
In the above code, I pulled out palette data from a file.
I then tried to modify the CPalette class using the data.
I then tried to apply the CPalette class to the attached window.
However, I get no effect. The palette does not change.
Some my question is, "How is a window modified using CPalette Class?"
I already new that a CPalette instance had to be created.
My question was how do I use the class to change the palette of a window.
For example, I have the following code:
CFile file;
CPalette palette;
MYPALETTE pal;
pal.palVersion = 0x300;
pal.palNumEntries = 256;
CString palettefile = FileLocation.Left(FileLoca
if (!file.Open(palettefile, CFile::modeRead, NULL))
{
return;
}
file.Read(&pal.palPalEntry
file.Close();
palette.CreatePalette((tag
PALETTEENTRY pal_s;
for (int p = 0;p<256;p++)
{
memcpy(&pal_s,pal.palPalEn
palette.SetPaletteEntries(
}
m_Static.GetDC()->SelectPa
m_Static.GetDC()->RealizeP
//************************
In the above code, I pulled out palette data from a file.
I then tried to modify the CPalette class using the data.
I then tried to apply the CPalette class to the attached window.
However, I get no effect. The palette does not change.
Some my question is, "How is a window modified using CPalette Class?"
Sorry for not understanding the point of your question at first.
Your code seems fine. Curios at the name of the window (m_Static)...is it a CStatic member? If so, maybe the problem has to do with the control not caring of your settings while drawing itself. Try your code on another non-control window.
If this is the case, consider handling the message WM_CTLCOLOR or something similar depending on what your goal is.
As for MSDN, you can freely access the online version of the library if you take a minute to register at http://www.microsoft.com/msdn.
Davide Marcato.
Your code seems fine. Curios at the name of the window (m_Static)...is it a CStatic member? If so, maybe the problem has to do with the control not caring of your settings while drawing itself. Try your code on another non-control window.
If this is the case, consider handling the message WM_CTLCOLOR or something similar depending on what your goal is.
As for MSDN, you can freely access the online version of the library if you take a minute to register at http://www.microsoft.com/msdn.
Davide Marcato.
ASKER
I don't have access to MSDN library.
I already new that a CPalette instance had to be created.
My question was how do I use the class to change the palette of a window.
For example, I have the following code:
CFile file;
CPalette palette;
MYPALETTE pal;
pal.palVersion = 0x300;
pal.palNumEntries = 256;
CString palettefile = FileLocation.Left(FileLoca tion.Rever seFind('\\ ')+1) + "palette.dat";
if (!file.Open(palettefile, CFile::modeRead, NULL))
{
return;
}
file.Read(&pal.palPalEntry ,768);
file.Close();
palette.CreatePalette((tag LOGPALETTE *) &pal);
PALETTEENTRY pal_s;
for (int p = 0;p<256;p++)
{
memcpy(&pal_s,pal.palPalEn try+p*3,3) ;
palette.SetPaletteEntries( p, 1,&pal_s);
}
m_Static.GetDC()->SelectPa lette(&pal ette, FALSE);
m_Static.GetDC()->RealizeP alette();
//************************ ********** ********** ********** ********** ****
In the above code, I pulled out palette data from a file.
I then tried to modify the CPalette class using the data.
I then tried to apply the CPalette class to the attached window.
However, I get no effect. The palette does not change.
So my question is, "How is a window modified using CPalette Class?"
I already new that a CPalette instance had to be created.
My question was how do I use the class to change the palette of a window.
For example, I have the following code:
CFile file;
CPalette palette;
MYPALETTE pal;
pal.palVersion = 0x300;
pal.palNumEntries = 256;
CString palettefile = FileLocation.Left(FileLoca
if (!file.Open(palettefile, CFile::modeRead, NULL))
{
return;
}
file.Read(&pal.palPalEntry
file.Close();
palette.CreatePalette((tag
PALETTEENTRY pal_s;
for (int p = 0;p<256;p++)
{
memcpy(&pal_s,pal.palPalEn
palette.SetPaletteEntries(
}
m_Static.GetDC()->SelectPa
m_Static.GetDC()->RealizeP
//************************
In the above code, I pulled out palette data from a file.
I then tried to modify the CPalette class using the data.
I then tried to apply the CPalette class to the attached window.
However, I get no effect. The palette does not change.
So my question is, "How is a window modified using CPalette Class?"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You'll be able to find a lot of documentation about palettes on the MSDN Library. An old but still great article you can't miss if you want to know everything about the Windows Palette Manager is "The Palette Manager: How and Why" by Ron Gery, again on MSDN.
Davide Marcato.