Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/12/2006, 16:17
nostromo_
 
Fecha de Ingreso: diciembre-2004
Ubicación: Iquique, Chile
Mensajes: 150
Antigüedad: 20 años, 2 meses
Puntos: 0
Manejo Evento Paint en Win32

Holas;

Tengo la siguiente duda, manejo las funciones TextOut, FrameRect y fillRect, estos dos últimos los utilizo para el fondo a modo de presentación.

Tengo dos botnoes, en el primero escribo un string "123123" y el segundo borro ese string.

Ahora, luego de borrar, no es posible escribir nada en las coordenadas que especfico en RECT, les coloco el código para que vean lo que trato de hacer, perfectamente puedo utilizar static con SetBkMode a TRANSPARENT y ajustando su posición con el fondo de colores de acuerdo al tipo de resultado, pero quiero disminuir código hecho. Esta realizado con Dev-C++, SO XP.

Código PHP:
#include <windows.h>
//
    
HWND hwnd;
    
HINSTANCE inst;
//
LRESULT CALLBACK WindowProcedure (HWNDUINTWPARAMLPARAM);
void fondo(HDCHWND);
void ver(HDCHWND);
void borrar(HDCHWND);

char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    
HINSTANCE hPrevInstanceLPSTR lpszArgumentint nFunsterStil)
{
    
HWND hwndMSG messagesWNDCLASSEX wincl;
    
//
    
wincl.hInstance hThisInstance;
    
wincl.lpszClassName szClassName;
    
wincl.lpfnWndProc WindowProcedure;      /* This function is called by windows */
    
wincl.style CS_DBLCLKS;                 /* Catch double-clicks */
    
wincl.cbSize sizeof (WNDCLASSEX);
    
//
    
wincl.hIcon LoadIcon (NULLIDI_APPLICATION);
    
wincl.hIconSm LoadIcon (NULLIDI_APPLICATION);
    
wincl.hCursor LoadCursor (NULLIDC_ARROW);
    
wincl.lpszMenuName NULL;                 /* No menu */
    
wincl.cbClsExtra 0;                      /* No extra bytes after the window class */
    
wincl.cbWndExtra 0;                      /* structure or the window instance */
    //
    
wincl.hbrBackground = (HBRUSHGetStockObject(WHITE_BRUSH);
    if (!
RegisterClassEx (&wincl))
        return 
0;

    
/* The class is registered, let's create the program*/
    
hwnd CreateWindowEx (
           
0,                   /* Extended possibilites for variation */
           
szClassName,         /* Classname */
           
"Windows App",       /* Title Text */
           
WS_VISIBLE|WS_SYSMENU|WS_CAPTION|WS_MINIMIZEBOX,
           
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 */
           
HWND_DESKTOP,        /* The window is a child-window to desktop */
           
NULL,                /* No menu */
           
hThisInstance,       /* Program Instance handler */
           
NULL                 /* No Window Creation data */
           
);
    
ShowWindow (hwndnFunsterStil);
    while (
GetMessage (&messagesNULL00))
    {
        
TranslateMessage(&messages);
        
DispatchMessage(&messages);
    }
    return 
messages.wParam;
}
//
    
HWND boton,goma,lblBOOL resp,eraser;
    
HBRUSH hbrushhcuadrohfondo1;
    
COLORREF cfondo1 RGB(173,202,241);
    
COLORREF cfondo2 RGB(221,236,255);
    
RECT rect3 = {170,249,404,269};
    
RECT rect31 = {171,250,403,268};
    
char *str "123123";
    
RECT r = {172,251,402,267};
//
LRESULT CALLBACK WindowProcedure (HWND hwndUINT messageWPARAM wParamLPARAM lParam)
{
    switch (
message)
    {
        case 
WM_CREATE:
             
boton CreateWindowEx(0,"button","Ver",WS_VISIBLE|WS_CHILD,10,10,
             
120,20,hwnd,(HMENU)100,inst,NULL);
             
goma CreateWindowEx(0,"button","Borrar",WS_VISIBLE|WS_CHILD,140,10,
             
120,20,hwnd,(HMENU)120,inst,NULL);
             
/*lbl = CreateWindowEx(0,"static","",WS_VISIBLE|WS_CHILD,171,250,100,19,
             hwnd,(HMENU)0,inst,NULL);*/
             
break;
        case 
WM_COMMAND:
             switch (
LOWORD(wParam))
             {
                    case 
100:
                         
resp true;
                         
GetClientRect(hwnd, &r);
                         
InvalidateRect(hwnd, &rTRUE);
                         break;
                    case 
120:
                         
eraser true;
                         
GetClientRect(hwnd,&r);
                         
InvalidateRect(hwnd,&r,TRUE);
                         break;
                    }
             break;
        case 
WM_PAINT:
             
HDC hdcPAINTSTRUCT ps;
             
hdc BeginPaint(hwnd,&ps);
                 
fondo(hdc,hwnd);
                 if(
resp) { ver(hdc,hwnd); }
                 if(
eraser) { borrar(hdc,hwnd); }
             
EndPaint(hwnd,&ps);
             break;
        case 
WM_DESTROY:
            
PostQuitMessage (0);
            break;
        default:
            return 
DefWindowProc (hwndmessagewParamlParam);
    }

    return 
0;
}
/*----------------- FUNCIONES ----------------------------*/
void fondo(HDC hdcHWND hwnd)
{
     
hbrush CreateSolidBrush(RGB(151,190,245));
     
hcuadro CreateSolidBrush(cfondo2);
     
hfondo1 CreateSolidBrush(cfondo1);
     
//dibujar formas
     
FrameRect(hdc,&rect3,hbrush);
     
FillRect(hdc,&rect31,hfondo1);
     
SelectObject(hdc,hbrush); DeleteObject(hbrush);
     
SelectObject(hdc,hfondo1); DeleteObject(hfondo1);
     }
//------
void ver(HDC hdcHWND hwnd)
{
     
SetTextColor(hdc,RGB(0,0,0));
     
SetBkMode(hdc,TRANSPARENT);
     
TextOut(hdc,172,251,str,strlen(str));
     }
//-------
void borrar(HDC hdcHWND hwnd)
{
     
/*char *str1 = "             ";
     SetBkColor(hdc,cfondo2);
     TextOut(hdc,174,251,str1,strlen(str1));*/
     
hfondo1 CreateSolidBrush(cfondo1);
     
FillRect(hdc,&rect31,hfondo1);
     
SelectObject(hdc,hfondo1); DeleteObject(hfondo1);
     } 
Les agradesco cualquier ayuda.