🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.controls
Article #44

Problems with GETDIBCOLORTABLE and SETDIBCOLORTABLE

#44
From: dond
Date: Thu, 24 Sep 1998 00:00
41 lines
2020 bytes
hol� !
I have some problems with the two DIB's functions GetDIBColorTable and
SetDIBColorTable.
How can I use this two functions ?
Where is my error ?
Here is some lines of my code:

/////////////////
     CBitmap *pBitmap=pDoc->GetBitmap();
     CDC memDC;
     memDC.CreateCompatibleDC(pDC);
     CBitmap *pOldBitmap=memDC.SelectObject(pBitmap);
      RGBQUAD *pRGB = new RGBQUAD[256];
      for (int i=0;i<=255;i++)
       {
        pRGB->rgbRed=int(255*( ((double)rand())/((double)RAND_MAX) ));;
        pRGB->rgbGreen=int(255*( ((double)rand())/((double)RAND_MAX) ));;
// Random colors generation
        pRGB->rgbBlue=int(255*( ((double)rand())/((double)RAND_MAX) ));;
        pRGB->rgbReserved=0;
       }
      UINT C=::SetDIBColorTable(memDC,0,256,pRGB);
// Changing the colors of the DIB
      DWORD E=GetLastError();
// looking at an error

  FILE *F; F=fopen("C.txt","wt"); fprintf(F,"NCOLORS=%lu\nERROR=%lu\n",C,E);
fclose(F);    // writing to a file to be read
//////////////////

this comes from my OnDraw(CDC *pDC) function of my View Class;

The ERROR is return as 6, that is to say "6  The handle is invalid.
ERROR_INVALID_HANDLE "

When I use GetDIBColorTable this is the same errors.

Can someone help me to use this two functions !

thanks you
dond@lune.u-strasbg.fr
Technical Details
Message-ID: <6ucvem$l3n@news.u-strasbg.fr>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1138df,e7fb770ebbd2d886,start
X-Google-Attributes: gid1138df,public
X-Google-Thread: 1053e6,e7fb770ebbd2d886,start
X-Google-Attributes: gid1053e6,public
X-Google-Thread: f7033,e7fb770ebbd2d886,start
X-Google-Attributes: gidf7033,public
From: "dond" <dond@lune.u-strasbg.fr>
Subject: Problems with GETDIBCOLORTABLE and SETDIBCOLORTABLE
Date: 1998/09/24
Message-ID: <6ucvem$l3n@news.u-strasbg.fr>
X-Deja-AN: 394299438
Organization: LSIIT/GRTS
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Newsgroups: comp.os.ms-windows.programmer.controls,comp.os.ms-windows.programmer.tools.mfc,fr.comp.os.ms-windows.programmation