Foro de elhacker.net

Programación => ASM => Mensaje iniciado por: Riki_89D en 25 Diciembre 2009, 19:55 pm



Título: Creacion de controles Personalizados? (ASM 32 Bits)
Publicado por: Riki_89D en 25 Diciembre 2009, 19:55 pm
Es posible crear por ejemplo un boton distino a los estandares dw Windows,por ejemplo un boton de forma triangular?? oseacrear un control personalizado,programo con Ensamblador de 32 bits (utilizo las API de windows) como puedo crear mis propios controles?


:S

salu2


Título: Re: Creacion de controles Personalizados? (ASM 32 Bits)
Publicado por: Eternal Idol en 25 Diciembre 2009, 20:15 pm
Si, owner drawn, de la MSDN (no lo encuentre on-line  :():

Using Owner Drawn Buttons
The parent window of an owner-drawn button typically responds to at least three messages for the button:

WM_INITDIALOG
WM_COMMAND
WM_DRAWITEM
When you must paint an owner-drawn button, the system sends the parent window a WM_DRAWITEM message whose lParam parameter is a pointer to a DRAWITEMSTRUCT structure. Use this structure with all owner-drawn controls to provide the application with the information it requires to paint the control. The itemAction and itemState members of the DRAWITEMSTRUCT structure define how to paint an owner-drawn button.

The following example shows how to process WM_INITDIALOG, WM_DRAWITEM, and WM_COMMAND messages for owner-drawn buttons. This example demonstrates how to draw one of two bitmaps for a control, depending on whether the control is selected. You would typically use the wParam parameter of the WM_DRAWITEM message to identify the control; in this example, only one control is assumed.

Código
  1. BOOL CALLBACK OwnDrawProc(HWND hDlg, UINT message, WPARAM wParam,
  2.                          LPARAM lParam)
  3. {
  4.    HDC hdcMem;
  5.    LPDRAWITEMSTRUCT lpdis;
  6.  
  7.    switch (message)
  8.    {
  9.        case WM_INITDIALOG:
  10.  
  11.            // hinst, hbm1 and hbm2 are defined globally.
  12.            hbm1 = LoadBitmap((HANDLE) hinst, "OwnBit1");
  13.            hbm2 = LoadBitmap((HANDLE) hinst, "OwnBit2");
  14.            return TRUE;
  15.  
  16.        case WM_DRAWITEM:
  17.            lpdis = (LPDRAWITEMSTRUCT) lParam;
  18.            hdcMem = CreateCompatibleDC(lpdis->hDC);
  19.  
  20.            if (lpdis->itemState & ODS_SELECTED)  // if selected
  21.                SelectObject(hdcMem, hbm2);
  22.            else
  23.                SelectObject(hdcMem, hbm1);
  24.  
  25.            // Destination
  26.            StretchBlt(
  27.                lpdis->hDC,         // destination DC
  28.                lpdis->rcItem.left, // x upper left
  29.                lpdis->rcItem.top,  // y upper left
  30.  
  31.                // The next two lines specify the width and
  32.                // height.
  33.                lpdis->rcItem.right - lpdis->rcItem.left,
  34.                lpdis->rcItem.bottom - lpdis->rcItem.top,
  35.                hdcMem,    // source device context
  36.                0, 0,      // x and y upper left
  37.                32,        // source bitmap width
  38.                32,        // source bitmap height
  39.                SRCCOPY);  // raster operation
  40.  
  41.            DeleteDC(hdcMem);
  42.            return TRUE;
  43.  
  44.        case WM_COMMAND:
  45.            if (wParam == IDOK
  46.                || wParam == IDCANCEL)
  47.            {
  48.                EndDialog(hDlg, TRUE);
  49.                return TRUE;
  50.            }
  51.            if (HIWORD(wParam) == BN_CLICKED)
  52.            {
  53.                switch (LOWORD(wParam))
  54.                {
  55.                    case IDC_OWNERDRAW:
  56.  
  57.                        // application-defined processing
  58.  
  59.                        break;
  60.                }
  61.            }
  62.            break;
  63.  
  64.        case WM_DESTROY:
  65.            DeleteObject(hbm1);  // delete bitmaps
  66.            DeleteObject(hbm2);
  67.  
  68.            break;
  69.  
  70.    }
  71.    return FALSE;
  72.        UNREFERENCED_PARAMETER(lParam);
  73. }


Título: Re: Creacion de controles Personalizados? (ASM 32 Bits)
Publicado por: Debci en 27 Diciembre 2009, 21:02 pm
eso es asm? parece C++ xD
O quizas parece mi in-experiencia.

Saludos


Título: Re: Creacion de controles Personalizados? (ASM 32 Bits)
Publicado por: Eternal Idol en 27 Diciembre 2009, 21:57 pm
eso es asm? parece C++ xD
O quizas parece mi in-experiencia.

Es C ... ya podrias haber puesto algun ejemplo del tema en assembly  :rolleyes:


Título: Re: Creacion de controles Personalizados? (ASM 32 Bits)
Publicado por: Debci en 27 Diciembre 2009, 22:33 pm
eso es asm? parece C++ xD
O quizas parece mi in-experiencia.

Es C ... ya podrias haber puesto algun ejemplo del tema en assembly  :rolleyes:
No pillo la ironia pero weno xDDD

Saludos