Ver Mensaje Individual
  #1  
Antiguo 30-07-2008
MON___ MON___ is offline
Miembro
 
Registrado: abr 2007
Ubicación: Salamanca (España)
Posts: 84
Reputación: 20
MON___ Va por buen camino
¿Por qué no se me abre el DIALOGBOX?

En un "TBitBtn" de la "Form" principal llamo a una función que debe abrir una ventana modal, mediante el API de Windows (DialogBox). La función requiere (entre otros parámetros) el HANDLE de la ventana que hace la llamada (en este caso, Form3->Handle), pero no se me muestra el cuadro de diálogo definido en el archivo de recursos correspondiente.
¿Alguién me puede indicar dónde tengo el error? Os transcribo el código fuente, tanto el del archivo de recursos como el de la implementación de la función.

Tengo el siguiente "resource.h"
Código:
#define DLG_BUSCAR 101
#define BTN_ACEPTAR 102
#define BTN_CANCELAR 103
#define LABEL_FIJO 104
#define COMBO_BUSCAR 105
En el *.rc correspondiente:
Código:
DLG_BUSCAR DIALOGEX 0, 0, 237, 79
STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_CAPTION
CAPTION "Buscar"
FONT 8, "MS Shell Dlg"
BEGIN
    LTEXT           "Valor de búsqueda:",LABEL_FIJO,7,10,63,8
    COMBOBOX        COMBO_BUSCAR,7,22,222,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
    PUSHBUTTON      "&Aceptar",BTN_ACEPTAR,109,54,58,14,WS_DISABLED
    PUSHBUTTON      "&Cancelar",BTN_CANCELAR,171,54,58,14
END
En "buscar.h" (declaración de la función)
Código:
#include <windows.h>
#include "resource.h"
bool BuscarValor(HWND hwnd, char * buffer, unsigned int size, bool upper);
Y en la implementación (buscar.cpp)
Código:
#include "buscar.h"
char * str;
HWND hwndCOMBO;
LRESULT CALLBACK WndProcedure(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam);
//-----------------------------------------------------------------------------------

bool BuscarValor(HWND hwnd, char * buffer, unsigned int size, bool upper)
{
    if(NULL == buffer) buffer = new char[size + 1];
    str = buffer;
    DialogBox(NULL, MAKEINTRESOURCE(DLG_BUSCAR), hwnd, reinterpret_cast<DLGPROC>(WndProcedure));
    return FALSE;
}

LRESULT CALLBACK WndProcedure(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
    switch(Msg)
    {
        case WM_INITDIALOG:
            hwndCOMBO = GetDlgItem(hwnd, COMBO_BUSCAR);
            return TRUE;
        case WM_COMMAND:
            switch(wParam)
            {
                case BTN_ACEPTAR:
                    EndDialog(hwnd, 0);
                    return TRUE;
                case BTN_CANCELAR:
                    EndDialog(hwnd, 0);
                    return FALSE;
            }
    }
    return FALSE;
}
Gracias y saludos a todos

Última edición por MON___ fecha: 30-07-2008 a las 21:35:59.
Responder Con Cita