[C con Clase] problema con el WM_PAINT

Antonio antoniof.gimenez en gmail.com
Mie Mar 21 17:11:55 CET 2007


Vereis me he creado una clase con una funcion miembro publica que es la siguiente:

int DllClass::creadlg(HWND dlg,HINSTANCE instancia){
  HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = instancia;
    wincl.lpszClassName = "clase";
    wincl.lpfnWndProc = procdlg;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_DESKTOP;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           wincl.lpszClassName,         /* Classname */
           "Ventana Principal",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           dlg,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           instancia,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );
    /* Make the window visible on the screen */
    ShowWindow (hwnd, SW_SHOW);
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
   
}

// a continuación pongo el procedimiento de ventana

LRESULT CALLBACK procdlg (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){
         static HINSTANCE instancia;
    switch (msg)                  /* handle the messages */
    {
         case WM_PAINT:
                HDC dc;
                dc=GetDC(hwnd);
                HBRUSH brocha;
                brocha=CreateSolidBrush(0xff0000);
                SelectObject(dc,brocha);
                FloodFill(dc,1,1,0xffffff);
                break;

           case WM_CREATE:
                instancia= ((LPCREATESTRUCT)lparam)->hInstance;
               
                break;
           case WM_SHOWWINDOW:
                /*HDC dc;
                dc=GetDC(hwnd);
                HBRUSH brocha;
                brocha=CreateSolidBrush(0xff0000);
                SelectObject(dc,brocha);
                FloodFill(dc,1,1,0xffffff);*/
                break;
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, msg, wparam, lparam);
    }

    return 0;
       
}

Mi pregunta consiste en ¿porque cuando capturo el mensaje WM_PAINT y creo el DC al ejecutar CreateSolidBrush me dice que la funcion no esta definida a pesar de haber incluido el windows.h y el stdio.h. Lo mismo me dice al llamar a SelectObject y a FloodFill? Que diferencia existe al ejecutarlo en el bucle de mensajes del main de un proyecto .exe y en un cpp de una dll sin ser miembro de ninguna clase?

Gracias de antemano, un saludo


Más información sobre la lista de distribución Cconclase