Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Sie können bestimmen, wie viele Farben ein Gerät unterstützt und was diese Farben sind, indem Sie die Anzahl der Farben für das Gerät abrufen und die Farben der Einfarbigen Stifte aufzählen. Um die Anzahl der Farben abzurufen, verwenden Sie die GetDeviceCaps Funktion mit dem WERT NUMCOLORS. Verwenden Sie zum Aufzählen solider Stifte die EnumObjects--Funktion und eine entsprechende Rückruffunktion, die Informationen zu jedem Stift empfängt.
// GetTheColors - returns the count and color values of solid colors
// Returns a pointer to the array containing colors
// hdc - handle to device context
COLORREF *GetTheColors(HDC hdc)
{
int cColors;
COLORREF *aColors;
// Get the number of colors.
cColors = GetDeviceCaps(hdc, NUMCOLORS);
// Allocate space for the array.
aColors = (COLORREF *)LocalAlloc(LPTR, sizeof(COLORREF) *
(cColors+1));
// Save the count of colors in first element.
aColors[0] = (LONG)cColors;
// Enumerate all pens and save solid colors in the array.
EnumObjects(hdc, OBJ_PEN, (GOBJENUMPROC)MyEnumProc, (LONG)aColors);
// Refresh the count of colors.
aColors[0] = (LONG)cColors;
return aColors;
}
int MyEnumProc(LPVOID lp, LPBYTE lpb)
{
LPLOGPEN lopn;
COLORREF *aColors;
int iColor;
lopn = (LPLOGPEN)lp;
aColors = (COLORREF *)lpb;
if (lopn->lopnStyle==PS_SOLID)
{
// Check for too many colors.
if ((iColor = (int)aColors[0]) <= 0)
return 0;
aColors[iColor] = lopn->lopnColor;
aColors[0]--;
}
return 1;
}