IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C++ Discussion :

error C3861 identifier not found


Sujet :

C++

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre habitué
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2014
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Israël

    Informations professionnelles :
    Activité : Administrateur de base de données

    Informations forums :
    Inscription : Mai 2014
    Messages : 9
    Par défaut error C3861 identifier not found
    Pouvez-vous aider à éliminer l'erreur?
    capture.cpp(71): error C3861: 'GdipCreateBitmapFromHBITMAP': identifier not found

    stdafx.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
     
     
     
     
    #include "stdafx.h"
    #pragma once
    #include "targetver.h"
    #include <stdio.h>
    #include <tchar.h>
    #include <windows.h>
    #include <fstream>
    #include <stdio.h>
     
    #include <wingdi.h>
    // GDI Plus
    #include <gdiplus.h>
    #include <Gdiplusflat.h> // Gdiplusflat.h
     
    #include <ostream>
    capture.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
     
     
     
     
     
     
    #define SCREENWIDTH GetSystemMetrics(SM_CXSCREEN)
    #define SCREENHEIGHT GetSystemMetrics(SM_CYSCREEN)
     
    // HBITMAP g_hDeskBmp;
    HDC g_hMemDC;
    int g_nDCdata;
     
    int main()
    {
     // get desktop window handle (but can be handle of any window)
     HWND HCapture = FindWindow(NULL, _T("Map Viewer") );
    //	HWND HCapture = GetDesktopWindow();
     if(!IsWindow(HCapture)) return 1;
     
    /*
     BOOL PrintWindow(
      HWND hwnd, // A handle to the window that will be copied.
      HDC hdcBlt, // A handle to the device context.
      UINT nFlags // The drawing options: PW_CLIENTONLY
                            //     Only the client area of the window is copied to hdcBlt. By default, the entire window is copied.
    );
    */
     
     // get window dimensions
     RECT rect;
     GetWindowRect(HCapture, &rect);
     
     size_t dx = rect.right - rect.left;
     size_t dy = rect.bottom - rect.top;
     
     // create BITMAPINFO structure
     // used by CreateDIBSection
     BITMAPINFO info;
     info.bmiHeader.biSize          = sizeof(BITMAPINFOHEADER);
     info.bmiHeader.biWidth         = dx;
     info.bmiHeader.biHeight        = dy;
     info.bmiHeader.biPlanes        = 1;
     info.bmiHeader.biBitCount      = 24;
     info.bmiHeader.biCompression   = BI_RGB;
     info.bmiHeader.biSizeImage     = 0;
     info.bmiHeader.biXPelsPerMeter = 0;
     info.bmiHeader.biYPelsPerMeter = 0;
     info.bmiHeader.biClrUsed       = 0;
     info.bmiHeader.biClrImportant  = 0;
     
     // a bitmap handle and a pointer its bit data
     HBITMAP HBitmap = 0;
     BYTE*   memory = 0;
     
     /** We should create Bitmap first and then Device Context,
         however when I want to create snapshot of window, I need to use
             fnc PrintWindow to copy the visual window to Device Context.
             So I need to create DC first. The DC will be compatible with
             current screen.
     */
     
     // 1. FIRST we need to Create DC for PrintWindow function
     // HDC device = GetDC(HCapture);
     HDC device = CreateCompatibleDC(NULL);
     
     // 2. SECOND we need to CREATE BITMAP (Device Independent Bitmap)
     // bitmap = CreateDIBSection(device, &info, DIB_RGB_COLORS, (void**)&memory, 0, 0);
     unsigned int * pBitmap;
     
     if (!PrintWindow(HCapture, device, PW_CLIENTONLY)) return 2;
     HBitmap = GdipCreateBitmapFromHBITMAP(HBitmap, 0, pBitmap);
     ReleaseDC(HCapture, device);
     if(!HBitmap || !memory) return 1;
     
     // blit the contents of the desktop (winDC)
     // to the bitmap (selected in memDC)
     HDC winDC = GetWindowDC(HCapture);
     HDC memDC = CreateCompatibleDC(winDC);
     SelectObject(memDC, HBitmap);
     BitBlt(memDC, 0, 0, dx, dy, winDC, 0, 0, SRCCOPY);
     DeleteDC(memDC);
     ReleaseDC(HCapture, winDC);
     
     /** THIS IS WRONG! VARIABLE CANNOT POINT TO NOWHERE!*/
     // char *buffer; // First set the type and range and then make pointer:
      char *buffer = new char[50]; // RIGHT DECLARATION
     sprintf(buffer,"capture%d%d.bmp",dx,dy);
     // create bitmap file
     std::basic_ofstream <char> file(buffer, std::ios::binary);
     if(!file) { DeleteObject(HBitmap); return 1; }
     
     // initialize bitmap file headers
     BITMAPFILEHEADER fileHeader;
     BITMAPINFOHEADER infoHeader;
     
     fileHeader.bfType      = 0x4d42;
     fileHeader.bfSize      = 0;
     fileHeader.bfReserved1 = 0;
     fileHeader.bfReserved2 = 0;
     fileHeader.bfOffBits   = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
     
     infoHeader.biSize          = sizeof(infoHeader);
     infoHeader.biWidth         = dx;
     infoHeader.biHeight        = dy;
     infoHeader.biPlanes        = 1;
     infoHeader.biBitCount      = 24;
     infoHeader.biCompression   = BI_RGB;
     infoHeader.biSizeImage     = 0;
     infoHeader.biXPelsPerMeter = 0;
     infoHeader.biYPelsPerMeter = 0;
     infoHeader.biClrUsed       = 0;
     infoHeader.biClrImportant  = 0;
     
     // save file headers
     file.write((char*)&fileHeader, sizeof(fileHeader));
     file.write((char*)&infoHeader, sizeof(infoHeader));
     
     // save 24-bit bitmap data
     int wbytes = (((24*dx + 31) & (~31))/8);
     int tbytes = (((24*dx + 31) & (~31))/8)*dy;
     file.write((char*)memory, tbytes);
     // delete bitmap
     DeleteObject(HBitmap);
     HBitmap = 0;
     memory = 0;
    return 0;
    //......................................................................................
    }

  2. #2
    Rédacteur/Modérateur


    Homme Profil pro
    Network game programmer
    Inscrit en
    Juin 2010
    Messages
    7 147
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Canada

    Informations professionnelles :
    Activité : Network game programmer

    Informations forums :
    Inscription : Juin 2010
    Messages : 7 147
    Billets dans le blog
    4
    Par défaut
    Où est déclaré GdipCreateBitmapFromHBITMAP ?
    Pensez à consulter la FAQ ou les cours et tutoriels de la section C++.
    Un peu de programmation réseau ?
    Aucune aide via MP ne sera dispensée. Merci d'utiliser les forums prévus à cet effet.

  3. #3
    Membre habitué
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2014
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Israël

    Informations professionnelles :
    Activité : Administrateur de base de données

    Informations forums :
    Inscription : Mai 2014
    Messages : 9
    Par défaut
    Citation Envoyé par Bousk Voir le message
    Où est déclaré GdipCreateBitmapFromHBITMAP ?
    Ici:

    http://msdn.microsoft.com/en-us/libr.../ms533971.aspx

    C'est la fonction de GDI + plat Api

  4. #4
    Membre habitué
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2014
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Israël

    Informations professionnelles :
    Activité : Administrateur de base de données

    Informations forums :
    Inscription : Mai 2014
    Messages : 9
    Par défaut
    Citation Envoyé par Bousk Voir le message
    Où est déclaré GdipCreateBitmapFromHBITMAP ?
    GdiPlusFlat.h:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    GdipCreateBitmapFromHBITMAP(HBITMAP hbm,
                                HPALETTE hpal,
                                GpBitmap** bitmap);
    Mais je ne peux pas trouver un fichier de définition

  5. #5
    Rédacteur/Modérateur


    Homme Profil pro
    Network game programmer
    Inscrit en
    Juin 2010
    Messages
    7 147
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Canada

    Informations professionnelles :
    Activité : Network game programmer

    Informations forums :
    Inscription : Juin 2010
    Messages : 7 147
    Billets dans le blog
    4
    Par défaut
    Et où se trouve l'include du fichier en question ?
    Ton code cpp ne contient aucun include.
    Pensez à consulter la FAQ ou les cours et tutoriels de la section C++.
    Un peu de programmation réseau ?
    Aucune aide via MP ne sera dispensée. Merci d'utiliser les forums prévus à cet effet.

  6. #6
    Membre habitué
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2014
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Israël

    Informations professionnelles :
    Activité : Administrateur de base de données

    Informations forums :
    Inscription : Mai 2014
    Messages : 9
    Par défaut
    Citation Envoyé par Bousk Voir le message
    Et où se trouve l'include du fichier en question ?
    Ton code cpp ne contient aucun include.
    J'ai actualisé le premier post. C'est, # include "stdafx.h"

  7. #7
    Membre habitué
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Mai 2014
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Israël

    Informations professionnelles :
    Activité : Administrateur de base de données

    Informations forums :
    Inscription : Mai 2014
    Messages : 9
    Par défaut Résumé
    (Update)

    staafx.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    #pragma once
    #include "targetver.h"
    #include <stdio.h>
    #include <tchar.h>
    #include <windows.h>
    #include <fstream>
    #include <stdio.h>
     
    #include <wingdi.h>
    // GDI Plus
    #include <gdiplus.h>
    //#include <Gdiplusflat.h> // Gdiplusflat.h
    //#include <GdiPlusBitmap.h>
    #include <ostream>
    capture.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
     
    /*Window capture example*/
    #include "stdafx.h"
    using namespace Gdiplus;
    // using namespace GdiPlus; 
     
    #define SCREENWIDTH GetSystemMetrics(SM_CXSCREEN)
    #define SCREENHEIGHT GetSystemMetrics(SM_CYSCREEN)
     
    // HBITMAP g_hDeskBmp;
    HDC g_hMemDC;
    int g_nDCdata;
     
    int main()
    {
     // get desktop window handle (but can be handle of any window)
     HWND HCapture = FindWindow(NULL, _T("Map Viewer") );
    //	HWND HCapture = GetDesktopWindow();
     if(!IsWindow(HCapture)) return 1;
     
    /*
     BOOL PrintWindow(
      HWND hwnd, // A handle to the window that will be copied.
      HDC hdcBlt, // A handle to the device context.
      UINT nFlags // The drawing options: PW_CLIENTONLY
                            //     Only the client area of the window is copied to hdcBlt. By default, the entire window is copied.
    );
    */
     
     // get window dimensions
     RECT rect;
     GetWindowRect(HCapture, &rect);
     
     size_t dx = rect.right - rect.left;
     size_t dy = rect.bottom - rect.top;
     
     // create BITMAPINFO structure
     // used by CreateDIBSection
     BITMAPINFO info;
     info.bmiHeader.biSize          = sizeof(BITMAPINFOHEADER);
     info.bmiHeader.biWidth         = dx;
     info.bmiHeader.biHeight        = dy;
     info.bmiHeader.biPlanes        = 1;
     info.bmiHeader.biBitCount      = 24;
     info.bmiHeader.biCompression   = BI_RGB;
     info.bmiHeader.biSizeImage     = 0;
     info.bmiHeader.biXPelsPerMeter = 0;
     info.bmiHeader.biYPelsPerMeter = 0;
     info.bmiHeader.biClrUsed       = 0;
     info.bmiHeader.biClrImportant  = 0;
     
     // a bitmap handle and a pointer its bit data
     HBITMAP HBitmap = 0;
     BYTE*   memory = 0;
     
     /** We should create Bitmap first and then Device Context,
         however when I want to create snapshot of window, I need to use
             fnc PrintWindow to copy the visual window to Device Context.
             So I need to create DC first. The DC will be compatible with
             current screen.
     */
     
     // 1. FIRST we need to Create DC for PrintWindow function
     // HDC device = GetDC(HCapture);
     HDC device = CreateCompatibleDC(NULL);
     
     // 2. SECOND we need to CREATE BITMAP (Device Independent Bitmap)
     // bitmap = CreateDIBSection(device, &info, DIB_RGB_COLORS, (void**)&memory, 0, 0);
     unsigned int * pBitmap;
     
     if (!PrintWindow(HCapture, device, PW_CLIENTONLY)) return 2;
     HBitmap = GdipCreateBitmapFromHBITMAP(HBitmap, 0, pBitmap);
     ReleaseDC(HCapture, device);
     if(!HBitmap || !memory) return 1;
     
     // blit the contents of the desktop (winDC)
     // to the bitmap (selected in memDC)
     HDC winDC = GetWindowDC(HCapture);
     HDC memDC = CreateCompatibleDC(winDC);
     SelectObject(memDC, HBitmap);
     BitBlt(memDC, 0, 0, dx, dy, winDC, 0, 0, SRCCOPY);
     DeleteDC(memDC);
     ReleaseDC(HCapture, winDC);
     
     /** THIS IS WRONG! VARIABLE CANNOT POINT TO NOWHERE!*/
     // char *buffer; // First set the type and range and then make pointer:
      char *buffer = new char[50]; // RIGHT DECLARATION
     sprintf(buffer,"capture%d%d.bmp",dx,dy);
     // create bitmap file
     std::basic_ofstream <char> file(buffer, std::ios::binary);
     if(!file) { DeleteObject(HBitmap); return 1; }
     
     // initialize bitmap file headers
     BITMAPFILEHEADER fileHeader;
     BITMAPINFOHEADER infoHeader;
     
     fileHeader.bfType      = 0x4d42;
     fileHeader.bfSize      = 0;
     fileHeader.bfReserved1 = 0;
     fileHeader.bfReserved2 = 0;
     fileHeader.bfOffBits   = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
     
     infoHeader.biSize          = sizeof(infoHeader);
     infoHeader.biWidth         = dx;
     infoHeader.biHeight        = dy;
     infoHeader.biPlanes        = 1;
     infoHeader.biBitCount      = 24;
     infoHeader.biCompression   = BI_RGB;
     infoHeader.biSizeImage     = 0;
     infoHeader.biXPelsPerMeter = 0;
     infoHeader.biYPelsPerMeter = 0;
     infoHeader.biClrUsed       = 0;
     infoHeader.biClrImportant  = 0;
     
     // save file headers
     file.write((char*)&fileHeader, sizeof(fileHeader));
     file.write((char*)&infoHeader, sizeof(infoHeader));
     
     // save 24-bit bitmap data
     int wbytes = (((24*dx + 31) & (~31))/8);
     int tbytes = (((24*dx + 31) & (~31))/8)*dy;
     file.write((char*)memory, tbytes);
     // delete bitmap
     DeleteObject(HBitmap);
     HBitmap = 0;
     memory = 0;
    return 0;
    //......................................................................................
    }
    ------ Rebuild All started: Project: capture3, Configuration: Debug Win32 ------
    stdafx.cpp
    capture.cpp
    capture.cpp(71): error C3861: 'GdipCreateBitmapFromHBITMAP': identifier not found
    Generating Code...
    ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Discussions similaires

  1. Réponses: 9
    Dernier message: 12/01/2011, 12h18
  2. [Error C3861] '_strdup': identifier not found
    Par stilgar_karas dans le forum Dev-C++
    Réponses: 4
    Dernier message: 26/11/2009, 10h04
  3. [Error C3861] '_strdup': identifier not found
    Par stilgar_karas dans le forum wxWidgets
    Réponses: 2
    Dernier message: 25/11/2009, 16h46
  4. Réponses: 2
    Dernier message: 07/05/2009, 11h38
  5. [VB6]Error 76: path not found
    Par riesseg dans le forum VB 6 et antérieur
    Réponses: 29
    Dernier message: 29/05/2006, 22h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo