Hi,

Can someone help me with this question..

I have a FLTK app, this APP do a load library (DLL) and call a DLL function.

The DLL have a FLTK interface too, but when I call show method from DLL 
interface it no painted, the operation occur correctly but the interface isn't 
painted.

If I use a Windows APP the DLL interface appear ok.

Below a got part of the code that I use.

I'm using a thread because I have to access a biometric device.

I don't known what I'm doing wrong..

Thanks for help.

//############# APP CODE ##################

#include <stdlib.h>
#include <stdio.h>
#include <FL2/run.h>
#include <FL2/Window.H>
#include <FL2/Button.H>
#include <FL2/Input.H>
#include <FL2/ask.H>
#include <FL2/StatusBarGroup.h>
#include "mfbiodemo.h"
using namespace fltk;

Window *window;
Input *txtFkCapt;
Button *btnCapture;
Button *btnVerify;
Input *txtFkVerify;
Input *txtFkResult;
StatusBarGroup *statusbar;

void LoadHW()
{
        char cDLL[256];
#ifndef _DEBUG
        sprintf(cDLL, "%s", NITGEN_DLL);
#else
        sprintf(cDLL, "..\\..\\%s\\Debug\\%s","Nitgen", NITGEN_DLL);
#endif
        hLib = LoadLibrary(cDLL);

        if(!hLib)
        {
                fltk::alert("DLL NITGEN(NBioBSP.dll) não encontrada.");
                return;
        }

        BioCapture = (Bio_Capture_Ptr)GetProcAddress(hLib,"FK_Capture");
}

void initCapture(Widget *w, void *p) {
        char *cCapture = NULL;
        Input *txt = (Input *)p;
        if(BioCapture)
        {
                BioFkType(2);
                cCapture = BioCapture(NULL,1);
                txt->value(cCapture);
        }
}

void exitcb(Widget *, void *) {
        exit(0);
}

int Bio_UI()
{
        window = new Window(500,300, "Demo");
        window->begin();

        txtFkCapt = NULL;
        btnCapture = new Button(20,20, 80, 25, "&Capturar");
        txtFkCapt   = new Input(150,50,300,25, "Digital Capturada: ");
        btnCapture->callback(initCapture, (void*)txtFkCapt);

        txtFkVerify = new Input(150,80,300,25, "Digital Verificar: ");
        txtFkResult = new Input(150,110,100,25, "Resultado: ");
        Button *btnExit = new Button(220,20, 80, 25, "Sai&r");
        btnExit->callback(exitcb,0);

        statusbar = new StatusBarGroup();

        window->end();
        window->show();
        return run();
}
//############# APP CODE ##################

int main(int argc, char ** argv) {
        LoadHW();
        return Bio_UI();
}


################# DLL CODE ###########################
void __EventLoop(void* obj)
{
        fltk::run();
}

void cb_Cancel(Widget *w, void* o)
{
        bKeepRunning = false;
        ((Window*)w)->hide();
        return;
}

Window* __WindowStatus(char* ModuleName, LPBIOUI BioInterface)
{
        int x   = 0;
        int y   = 0;
        int w   = 0;
        int h   = 0;
        int err = -1;
        int iWidth  = GetSystemMetrics (SM_CXSCREEN);
        int iHeight = GetSystemMetrics (SM_CYSCREEN);
        StatusBarGroup *hwndMsg    = NULL;
        Button* hwndCancel = NULL;
        Window* hwndFinger = NULL;
        Button* hwndLogo   = NULL;
        Button* hwndVer    = NULL;
        Window *hwndStatus = NULL;
        Input *input;
        HWND hwnd;
        w = 500;
        h = 500;
        x = iWidth/2 - w/2;
        y = iHeight/2 - h/2;

        hwndStatus = new Window(x,y,w,h,"BIO");
        hwndStatus->begin();
        hwndMsg = new StatusBarGroup();
        //hwndFinger = new Window(0,0, "FINGER");
        input = new Input(70,20,300,23,"Normal");
        hwndCancel = new Button(420,20, 80, 25, "&Cancelar");
        hwndStatus->end();
        hwndStatus->set_modal();

        BioInterface->hwndVer    = hwndVer;
        BioInterface->hwndMsg    = hwndMsg;
        BioInterface->hwndStatus = hwndStatus;
        //BioInterface->hwndFinger = hwndFinger;
        BioInterface->hwndLogo   = input;
        BioInterface->hwndCancel = hwndCancel;

        hwndCancel->callback(cb_Cancel, (void*)BioInterface);
        return hwndStatus;
}

void* EnrollThread(LPVOID pParam)
{
        ////////// THIS IS A TEST FUNCTION ////////////
        LPBIOPERPARAMS             lpbop;
        bool ret = true;
        lpbop = (LPBIOPERPARAMS)pParam;

        fltk::lock();
        lpbop->BioUi->hwndMsg->label(lpbop->msg);
        lpbop->BioUi->hwndStatus->draw();
        fltk::unlock();
        fltk::awake();

        int i = 0;
        char msg[32];
        for(i=1;i<=5;i++)
        {
                sprintf(msg, "%d", i);
                fltk::lock();
                ((Input*)lpbop->BioUi->hwndLogo)->value(msg);
                fltk::unlock();
                fltk::awake();
                Sleep(1000);
        }

        fltk::lock();
        lpbop->BioUi->hwndStatus->hide();
        fltk::unlock();
        fltk::awake();
        return &ret;
}

char* FK_Capture(void* h, int iOper)
{
        Window *hWnd;
        Thread mainThread;
        int imainThread = 0;
        LPBIOPERPARAMS bop;
        BIOUI BioInterface;
        BIORS BioResponse;

        // Inicializacao de Estruturas
        bop = (LPBIOPERPARAMS)malloc(sizeof(BIOPERPARAMS));
        memset(bop, 0x00, sizeof(BIOPERPARAMS));

        memset(&BioInterface, 0x00, sizeof(BioInterface));

        memset(&BioResponse, 0x00, sizeof(BioResponse));
        BioResponse.msg = (char*)malloc(ONEKB);
        memset(BioResponse.msg, 0x00, ONEKB);

        memset(msg, 0x00, HALFKB);

        // Tipo da Operacao
        BioResponse.iOperation = BIO_CAPTURE;

        bop->BioUi = &BioInterface;
        bop->BioRs = &BioResponse;

        // Inicializa o Dispositivo
        if(FK_Init(true, bop))
                goto EndDevice;

        if (m_hBSP == NULL)
        {
                BioResponse.ErrCode = BIOERROR_FK_CAPTURE;
                BioResponse.bOpSuccess = false;
                sprintf(BioResponse.msg, "ERROR - Device not initialized.");
                goto EndDevice; // Dispositivo não iniciado
        }

        // Interface de Controle
        hWnd = __WindowStatus(DLLNAME, &BioInterface);
        sprintf(bop->msg, "%s", BIOMSG_FINGERON);

        fltk::lock();
        BioInterface.hwndMsg->label(bop->msg);
        hWnd->show();
        imainThread = create_thread(mainThread, EnrollThread, bop);
        __EventLoop((void*)hWnd);

        if (!BioResponse.bOpSuccess)
                goto EndDevice;
        else
            /// Success

EndDevice:

        if(retzip)
                free(retzip);

        if(ToEncode)
                free(ToEncode);

        // Finaliza o Dispositivo
        FK_Close(deviceID);

        if(!BioResponse.bOpSuccess)
        {
                if(!ret64)
                {
                        ret64 = (char*)malloc(HALFKB);
                        memset(ret64, 0x00, HALFKB);
                }
                memcpy(ret64, BioResponse.msg, strlen(BioResponse.msg));
        }

        if(bop)
        {
                if(bop->BioRs && bop->BioRs->msg)
                {
                        free(bop->BioRs->msg);
                        bop->BioRs->msg = NULL;
                }

                free(bop);
                bop = NULL;
        }

        // Retorna valor da variável de controle do EvenLoop
        bKeepRunning = true;

        return ret64;
}
################# DLL CODE ###########################
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to