Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1582 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  mon compilateur ne connais pas "errhandler"

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

mon compilateur ne connais pas "errhandler"

n°684113
lecoyote
Posté le 25-03-2004 à 17:08:24  profilanswer
 

je fais de la sauvegarde d'image et à ma grande stupeur, errhandler est inconnu lors de la compilation, bien qu'il le soit dans la msdn...
est-ce une librairie/source que je n'aurais pas inclue ?


Message édité par lecoyote le 25-03-2004 à 17:09:27
mood
Publicité
Posté le 25-03-2004 à 17:08:24  profilanswer
 

n°684116
lecoyote
Posté le 25-03-2004 à 17:09:12  profilanswer
 

.


Message édité par lecoyote le 25-03-2004 à 17:09:32
n°684124
HelloWorld
Salut tout le monde!
Posté le 25-03-2004 à 17:13:41  profilanswer
 

Compilo ? bout de code ?


---------------
FAQ fclc++ - FAQ C++ - C++ FAQ Lite
n°684134
blackgodde​ss
vive le troll !
Posté le 25-03-2004 à 17:22:44  profilanswer
 

ce serait avec un goto des fois ton truc ?


---------------
-( BlackGoddess )-
n°684162
lecoyote
Posté le 25-03-2004 à 17:43:26  profilanswer
 

compilo : vc6.0
code :

Code :
  1. PBITMAPINFO CreateBitmapInfoStruct(HWND hwnd, HBITMAP hBmp)
  2. {
  3.     BITMAP bmp;
  4.     PBITMAPINFO pbmi;
  5.     WORD    cClrBits;
  6.     // Retrieve the bitmap color format, width, and height.  
  7.     if (!GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp))
  8.         errhandler("GetObject", hwnd);
  9.     // Convert the color format to a count of bits.  
  10.     cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel);
  11.     if (cClrBits == 1)
  12.         cClrBits = 1;
  13.     else if (cClrBits <= 4)
  14.         cClrBits = 4;
  15.     else if (cClrBits <= 8)
  16.         cClrBits = 8;
  17.     else if (cClrBits <= 16)
  18.         cClrBits = 16;
  19.     else if (cClrBits <= 24)
  20.         cClrBits = 24;
  21.     else cClrBits = 32;
  22.     // Allocate memory for the BITMAPINFO structure. (This structure  
  23.     // contains a BITMAPINFOHEADER structure and an array of RGBQUAD  
  24.     // data structures.)  
  25.      if (cClrBits != 24)
  26.          pbmi = (PBITMAPINFO) LocalAlloc(LPTR,
  27.                     sizeof(BITMAPINFOHEADER) +
  28.                     sizeof(RGBQUAD) * (1<< cClrBits));
  29.      // There is no RGBQUAD array for the 24-bit-per-pixel format.  
  30.      else
  31.          pbmi = (PBITMAPINFO) LocalAlloc(LPTR,
  32.                     sizeof(BITMAPINFOHEADER));
  33.     // Initialize the fields in the BITMAPINFO structure.  
  34.     pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  35.     pbmi->bmiHeader.biWidth = bmp.bmWidth;
  36.     pbmi->bmiHeader.biHeight = bmp.bmHeight;
  37.     pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
  38.     pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel;
  39.     if (cClrBits < 24)
  40.         pbmi->bmiHeader.biClrUsed = (1<<cClrBits);
  41.     // If the bitmap is not compressed, set the BI_RGB flag.  
  42.     pbmi->bmiHeader.biCompression = BI_RGB;
  43.     // Compute the number of bytes in the array of color  
  44.     // indices and store the result in biSizeImage.  
  45.     // For Windows NT, the width must be DWORD aligned unless  
  46.     // the bitmap is RLE compressed. This example shows this.  
  47.     // For Windows 95/98/Me, the width must be WORD aligned unless the  
  48.     // bitmap is RLE compressed.
  49.     pbmi->bmiHeader.biSizeImage = ((pbmi->bmiHeader.biWidth * cClrBits +31) & ~31) /8
  50.                                   * pbmi->bmiHeader.biHeight;
  51.     // Set biClrImportant to 0, indicating that all of the  
  52.     // device colors are important.  
  53.      pbmi->bmiHeader.biClrImportant = 0;
  54.      return pbmi;
  55. }

n°684163
lecoyote
Posté le 25-03-2004 à 17:43:47  profilanswer
 

Code :
  1. void CreateBMPFile(HWND hwnd, LPTSTR pszFile, PBITMAPINFO pbi,
  2.                   HBITMAP hBMP, HDC hDC)
  3. {
  4.      HANDLE hf;                 // file handle  
  5.     BITMAPFILEHEADER hdr;       // bitmap file-header  
  6.     PBITMAPINFOHEADER pbih;     // bitmap info-header  
  7.     LPBYTE lpBits;              // memory pointer  
  8.     DWORD dwTotal;              // total count of bytes  
  9.     DWORD cb;                   // incremental count of bytes  
  10.     BYTE *hp;                   // byte pointer  
  11.     DWORD dwTmp;
  12.     pbih = (PBITMAPINFOHEADER) pbi;
  13.     lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);
  14.     if (!lpBits)
  15.          errhandler("GlobalAlloc", hwnd);
  16.     // Retrieve the color table (RGBQUAD array) and the bits  
  17.     // (array of palette indices) from the DIB.  
  18.     if (!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi,
  19.         DIB_RGB_COLORS))
  20.     {
  21.         errhandler("GetDIBits", hwnd);
  22.     }
  23.     // Create the .BMP file.  
  24.     hf = CreateFile(pszFile,
  25.                    GENERIC_READ | GENERIC_WRITE,
  26.                    (DWORD) 0,
  27.                     NULL,
  28.                    CREATE_ALWAYS,
  29.                    FILE_ATTRIBUTE_NORMAL,
  30.                    (HANDLE) NULL);
  31.     if (hf == INVALID_HANDLE_VALUE)
  32.         errhandler("CreateFile", hwnd);
  33.     hdr.bfType = 0x4d42;        // 0x42 = "B" 0x4d = "M"  
  34.     // Compute the size of the entire file.  
  35.     hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) +
  36.                  pbih->biSize + pbih->biClrUsed
  37.                  * sizeof(RGBQUAD) + pbih->biSizeImage);
  38.     hdr.bfReserved1 = 0;
  39.     hdr.bfReserved2 = 0;
  40.     // Compute the offset to the array of color indices.  
  41.     hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) +
  42.                     pbih->biSize + pbih->biClrUsed
  43.                     * sizeof (RGBQUAD);
  44.     // Copy the BITMAPFILEHEADER into the .BMP file.  
  45.     if (!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER),
  46.         (LPDWORD) &dwTmp,  NULL))
  47.     {
  48.        errhandler("WriteFile", hwnd);
  49.     }
  50.     // Copy the BITMAPINFOHEADER and RGBQUAD array into the file.  
  51.     if (!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER)
  52.                   + pbih->biClrUsed * sizeof (RGBQUAD),
  53.                   (LPDWORD) &dwTmp, ( NULL))
  54.         errhandler("WriteFile", hwnd);
  55.     // Copy the array of color indices into the .BMP file.  
  56.     dwTotal = cb = pbih->biSizeImage;
  57.     hp = lpBits;
  58.     if (!WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp,NULL))
  59.            errhandler("WriteFile", hwnd);
  60.     // Close the .BMP file.  
  61.      if (!CloseHandle(hf))
  62.            errhandler("CloseHandle", hwnd);
  63.     // Free memory.  
  64.     GlobalFree((HGLOBAL)lpBits);
  65. }

n°684600
lecoyote
Posté le 26-03-2004 à 08:51:24  profilanswer
 
n°684611
lecoyote
Posté le 26-03-2004 à 09:03:30  profilanswer
 

ce que je ne comprend pas, c'est qu'il ne me dise à aucun moment d'inclure quoi que ce soit...
:|

n°684638
lecoyote
Posté le 26-03-2004 à 09:24:12  profilanswer
 

en fait, ce que je veux, c'est assez simple :
je recoit une image (bmp) via le rsx que j'affiche à l'écran dans une boite de dialogue.
connaissant toutes les caractérisque de l'image (taille, format, début des coordonnées de l'affichage de l'image et sa fin dans la boite de dialogue via la fonction StretchDIBits()), je pense pouvoir arrivé a sauvegarder ce qui est afficher à l'écran sans devoir passer par une impression d'écran... non ? y a bien une fonction me permettant de le renseigner sur le HDC, les coordonnées.... !!!!!!!

n°685097
blackgodde​ss
vive le troll !
Posté le 26-03-2004 à 15:30:51  profilanswer
 

bin errhanlder tu peux te de faire tout seul :p
 

Code :
  1. void errhandler(const char *text, HWND hwnd)
  2. {
  3.   MessageBox(hwnd, text, "erreur", 0);
  4. }


 
je suppose que c'est à toi de faire ta gestion d'erreurs ?


---------------
-( BlackGoddess )-
mood
Publicité
Posté le 26-03-2004 à 15:30:51  profilanswer
 

n°685115
R3g
fonctionnaire certifié ITIL
Posté le 26-03-2004 à 15:41:04  profilanswer
 

En fait quand tu vois errhandler dans les exemples de la MSDN, il faut comprendre "la fonction qui traite l'erreur" ; à toi de remplacer par le traitement approprié à l'erreur ;)


---------------
Au royaume des sourds, les borgnes sont sourds.
n°686487
lecoyote
Posté le 29-03-2004 à 13:35:27  profilanswer
 

ok, merci, je vien de tilter ! :p


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  mon compilateur ne connais pas "errhandler"

 

Sujets relatifs
Compilateur fortran :(Je recherche un compilateur xml gratuit
VC++ 6.0 et tri de tableau: bug du compilateur???Un bon compilateur Python?????????
[C] CompilateurCompilateur FORTRAN
Emulateur UNIX et compilateur C[Python] "Compilateur" Psyco qui booste le code Python ?
Compilateur/Interpréteur PrologCompilateur Forttran 95 ?
Plus de sujets relatifs à : mon compilateur ne connais pas "errhandler"


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR