Ir para conteúdo
Fórum Script Brasil
  • 0

Capturar valor da tela


lorenzi

Pergunta

Bom tarde,

Pessoal tenho um novo problema, estou desenvolvolvendo um projeto pra smart device

e tenho um campo text na tela o nome dele é IDC_EDIT_LEN

gostaria de saber como consigo pegar a informação digitada neste campo tentei de varias formas mas não funciona:

wsprintf(szLen , TEXT("%d"),(IDC_EDIT_LEN));

hctl_length = GetDlgItem(hwnd,IDC_EDIT_LEN);

camara são variaveis do tipo LPTSTR se informa no campo 5555 ou retorna ??? ou retorna 1001:

camara = (LPTSTR) (hctl_length, szLen); /* retorna 1001*/

camara1 = (LPTSTR) (szLen); /* retorna 1001*/

camara2 = (LPTSTR) hctl_length; /* retorna ????*/

camara3 = (LPTSTR) GetDlgItem(hwnd,IDC_EDIT_LEN); /* retorna ????*/

camara4 = (hctl_length, szLen); /* retorna 1001 */

dados = (LPTSTR)SCNBUF_GETDATA(lpScanBuffer);

ponto = (LPTSTR)";";

lfp = fopen("transf.txt","a");

if(lfp)

{

fwprintf(lfp,camara);

fwprintf(lfp,ponto);

fwprintf(lfp,camara1);

fwprintf(lfp,ponto);

fwprintf(lfp,camara2);

fwprintf(lfp,ponto);

fwprintf(lfp,camara3);

fwprintf(lfp,ponto);

fwprintf(lfp,camara4);

fwprintf(lfp,ponto);

fwprintf(lfp,dados);

fwprintf(lfp,ponto);

fclose(lfp);

}

Grato se alguém puder me ajudar.

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0
cara....

não manjo muito de smart não....

mas se tu manda o codigo agente pode dar uma olhada

abrass

opa o valor que eu preciso recuperar da tela e este campo IDC_EDIT_LEN

#include <windows.h>

#include <windowsx.h>

#include <ScanCAPI.h>

#include <stdlib.h>

#include <math.h>

#include <stdio.h>

#include <string.h>

#include <strsafe.h>

#include <windows.h>

#include <tchar.h>

#include "resource.h"

#define countof(x) sizeof(x)/sizeof(x[0])

// Define user messages

enum tagUSERMSGS

{

UM_SCAN = WM_USER + 0x200,

UM_STARTSCANNING,

UM_STOPSCANNING

};

// Global variables

HINSTANCE hInst = NULL;

HANDLE hScanner = NULL;

LPSCAN_BUFFER lpScanBuffer = NULL;

TCHAR szScannerName[MAX_PATH] = TEXT("SCN1:"); // default scanner name

DWORD dwScanSize = 7095; // default scan buffer size

DWORD dwScanTimeout = 2000; // default timeout value (0 means no timeout)

BOOL bUseText = TRUE;

BOOL bTriggerFlag = FALSE;

BOOL bRequestPending = FALSE;

BOOL bStopScanning = FALSE;

BOOL bContinuousMode = FALSE;

LPTSTR dados;

LPTSTR ponto;

LPTSTR camara;

LPTSTR camara1;

LPTSTR camara2;

LPTSTR camara3;

LPTSTR camara4;

LPTSTR camara5;

LPTSTR camara6;

TCHAR szBuffer[256];

int teste;

// Forward declarations

LRESULT CALLBACK BasicScanProc(HWND,UINT,WPARAM,LPARAM);

void ErrorExit(HWMD, UINT, LPTSTR);

LPTSTR LoadMsg(UINT, LPTSTR, int);

//----------------------------------------------------------------------------

//

// FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

//

// PURPOSE: Entry point function, initializes the application, instance,

// and then launches the message loop.

//

// PARAMETERS:

// hInstance - handle that uniquely identifies this instance of the

// application

// hPrevInstance - always zero in Win32

// lpszCmdLine - any command line arguements pass to the program

// nCmdShow - the state which the application shows itself on

// startup

//

// RETURN VALUE:

// (int) Returns the value from PostQuitMessage().

//

//----------------------------------------------------------------------------

int WINAPI WinMain(HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPWSTR lpszCmdLine,

int nCmdShow)

{

int nResult;

hInst = hInstance; // save the instance handle to a global variable

nResult = DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_SSCAN), NULL,

BasicScanProc);

return nResult;

}

//----------------------------------------------------------------------------

//

// FUNCTION: BasicScanProc(HINSTANCE, HINSTANCE, LPSTR, int)

//

// PURPOSE: Application-defined callback function that processes messages

// sent to BasicScan dialog.

//

// PARAMETERS:

// hwnd - handle to the dialog box.

// uMsg - specifies the message.

// wParam - specifies additional message-specific information.

// lParam - specifies additional message-specific information.

//

// RETURN VALUE:

// (BOOL) return TRUE if it processed the message, and FALSE if it did not.

//

//----------------------------------------------------------------------------

LRESULT CALLBACK BasicScanProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)

{

DWORD dwResult;

TCHAR szLabelType[10];

TCHAR szLen[MAX_PATH];

TCHAR szMsgBuf[256];

LPSCAN_BUFFER lpScanBuf;

HWND hctl_data, hctl_length, hctl_type;

/*cria e abre o arquivo*/

FILE *lfp;

lfp = fopen("transf.txt","a");

switch(uMsg)

{

case WM_INITDIALOG:

PostMessage(hwnd,UM_STARTSCANNING,0,0L);

break;

case UM_STARTSCANNING:

// Open scanner, prepare for scanning,

// and submit the first read request

dwResult = SCAN_Open(szScannerName, &hScanner);

if ( dwResult != E_SCN_SUCCESS )

{

ErrorExit(hwnd, IDS_FAILURE, TEXT("SCAN_Open"));

break;

}

dwResult = SCAN_Enable(hScanner);

if ( dwResult != E_SCN_SUCCESS )

{

ErrorExit(hwnd, IDS_FAILURE, TEXT("SCAN_Enable"));

break;

}

lpScanBuffer = SCAN_AllocateBuffer(bUseText, dwScanSize);

if (lpScanBuffer == NULL)

{

ErrorExit(hwnd, IDS_FAILURE, TEXT("SCAN_AllocateBuffer"));

return TRUE;

}

dwResult = SCAN_ReadLabelMsg(hScanner,

lpScanBuffer,

hwnd,

UM_SCAN,

dwScanTimeout,

NULL);

if ( dwResult != E_SCN_SUCCESS )

ErrorExit(hwnd, IDS_FAILURE, TEXT("SCAN_ReadLabelMsg"));

else

bRequestPending = TRUE;

break;

return TRUE;

case UM_STOPSCANNING:

// We stop scanning in two steps: first, cancel any pending read

// request; second, after there is no more pending request, disable

// and close the scanner. We may need to do the second step after

// a UM_SCAN message told us that the cancellation was completed.

if (!bStopScanning && bRequestPending)

SCAN_Flush(hScanner);

if (!bRequestPending)

{

SCAN_Disable(hScanner);

if (lpScanBuffer)

SCAN_DeallocateBuffer(lpScanBuffer);

SCAN_Close(hScanner);

EndDialog(hwnd, 0);

}

bStopScanning = TRUE;

return TRUE;

case WM_ACTIVATE:

// In foreground scanning mode, we need to cancel read requests

// when the application is deactivated, and re-submit read request

// when the application is activated again.

switch(LOWORD(wParam))

{

case WA_INACTIVE:

hctl_data = GetDlgItem(hwnd,IDC_EDIT_DATA);

hctl_length = GetDlgItem(hwnd,IDC_EDIT_LEN);

hctl_type = GetDlgItem(hwnd,IDC_EDIT_TYPE);

Edit_SetText(hctl_data, LoadMsg(IDS_INACTIVE,

szMsgBuf, countof(szMsgBuf)));

Edit_SetText(hctl_length, TEXT(""));

Edit_SetText(hctl_type, TEXT(""));

// Cancel any pending request since we are going to lose focus

if (bRequestPending)

dwResult = SCAN_Flush(hScanner);

// Do not set bRequestPending to FALSE until

// we get the UM_SCAN message

break;

default: // activating

hctl_data = GetDlgItem(hwnd,IDC_EDIT_DATA);

Edit_SetText(hctl_data, LoadMsg(IDS_READY,

szMsgBuf, countof(szMsgBuf)));

if (!bRequestPending && lpScanBuffer != NULL && !bStopScanning)

{

// Submit a read request if no request pending

dwResult = SCAN_ReadLabelMsg(hScanner,

lpScanBuffer,

hwnd,

UM_SCAN,

dwScanTimeout,

NULL);

if ( dwResult != E_SCN_SUCCESS )

ErrorExit(hwnd, IDS_FAILURE, TEXT("SCAN_ReadLabelMsg"));

else

bRequestPending = TRUE;

}

break;

}

break;

case UM_SCAN:

bRequestPending = FALSE;

// Clear the soft trigger

bTriggerFlag = FALSE;

SCAN_SetSoftTrigger(hScanner,&bTriggerFlag);

// Get scan result from the scan buffer, and display it

lpScanBuf = (LPSCAN_BUFFER)lParam;

if ( lpScanBuf == NULL )

ErrorExit(hwnd, IDS_ERR_BUF, 0);

hctl_data = GetDlgItem(hwnd,IDC_EDIT_DATA);

hctl_length = GetDlgItem(hwnd,IDC_EDIT_LEN);

hctl_type = GetDlgItem(hwnd,IDC_EDIT_TYPE);

switch (SCNBUF_GETSTAT(lpScanBuf))

{

case E_SCN_DEVICEFAILURE:

Edit_SetText(hctl_data, LoadMsg(IDS_DEVICE_FAILURE,

szMsgBuf, countof(szMsgBuf)));

break;

case E_SCN_READPENDING:

Edit_SetText(hctl_data, LoadMsg(IDS_READ_PENDING,

szMsgBuf, countof(szMsgBuf)));

break;

case E_SCN_READCANCELLED:

if (bStopScanning)

{ // complete the second step of UM_STOPSCANNING

SendMessage(hwnd,UM_STOPSCANNING,0,0L);

return TRUE;

}

if (!GetFocus())

break; // Do nothing if read was cancelled while deactivation

Edit_SetText(hctl_data, LoadMsg(IDS_READ_CANCELLED,

szMsgBuf, countof(szMsgBuf)));

break;

case E_SCN_READTIMEOUT:

if(bContinuousMode)

PostMessage(hwnd,WM_COMMAND,IDC_BUTTON_SOFTTRIGGER,0L);

break;

case E_SCN_SUCCESS:

/*mostra o codigo lido pelo leitor na tela*/

Edit_SetText(hctl_data, (LPTSTR)SCNBUF_GETDATA(lpScanBuffer));

/*armazena o que foi lido na variavel dados para direcionar para o arquivo*/

dados = (LPTSTR)SCNBUF_GETDATA(lpScanBuffer);

ponto = (LPTSTR)";";

/*Gero a saida para o arquivo neste ponto*/

hctl_length = GetDlgItem(hwnd,IDC_EDIT_LEN);

wsprintf(szLen, TEXT("0x%x"), GetDlgItem(hwnd,IDC_EDIT_LEN) );

wsprintf(szBuffer, L"%o", GetDlgItemText(hwnd,IDC_EDIT_LEN));

camara = (LPTSTR) "";

camara1 = (LPTSTR) szLen;

camara2 = (LPTSTR) szLen; /*????*/

camara3 = (LPTSTR) szBuffer;

camara4 = (LPTSTR) szLen; /*1001 */

lfp = fopen("transf.txt","a");

if(lfp)

{

fwprintf(lfp,camara);

fwprintf(lfp,ponto);

fwprintf(lfp,camara1);

fwprintf(lfp,ponto);

fwprintf(lfp,camara2);

fwprintf(lfp,ponto);

fwprintf(lfp,camara3);

fwprintf(lfp,ponto);

fwprintf(lfp,camara4);

fwprintf(lfp,ponto);

fwprintf(lfp,dados);

fwprintf(lfp,ponto);

fclose(lfp);

}

// Format label type as a hex constant for display

wsprintf(szLabelType, TEXT("0x%.2X"), SCNBUF_GETLBLTYP(lpScanBuf));

Edit_SetText(hctl_type, szLabelType);

/*wsprintf(szLen, TEXT("%d"), SCNBUF_GETLEN(lpScanBuf));

Edit_SetText(hctl_length, szLen);

*/

if(bContinuousMode)

PostMessage(hwnd,WM_COMMAND,IDC_BUTTON_SOFTTRIGGER,0L);

break;

}

// Submit next read request if we are foreground

if (GetFocus())

{

dwResult = SCAN_ReadLabelMsg(hScanner,

lpScanBuffer,

hwnd,

uMsg,

dwScanTimeout,

NULL);

if ( dwResult != E_SCN_SUCCESS )

ErrorExit(hwnd, IDS_FAILURE, TEXT("SCAN_ReadLabelMsg"));

else

bRequestPending = TRUE;

}

return TRUE;

case WM_COMMAND:

switch (LOWORD(wParam))

{

case IDC_BUTTON_SOFTTRIGGER:

// Clear the state first before we set it to TRUE

bTriggerFlag = FALSE;

SCAN_SetSoftTrigger(hScanner,&bTriggerFlag);

bTriggerFlag = TRUE;

SCAN_SetSoftTrigger(hScanner,&bTriggerFlag);

break;

case IDC_CONTINUOUS: //Check for Continuous Scan Mode

bContinuousMode = !bContinuousMode;

if(bContinuousMode)

PostMessage(hwnd,WM_COMMAND,IDC_BUTTON_SOFTTRIGGER,0L);

break;

case IDOK: // fall through

case IDCANCEL:

SendMessage(hwnd,UM_STOPSCANNING,0,0L);

break;

}

return TRUE;

}

return FALSE;

}

//----------------------------------------------------------------------------

//

// FUNCTION: ErrorExit(HWND, UINT, LPTSTR)

//

// PURPOSE: Handle critical errors and exit dialog.

//

// PARAMETERS:

// hwnd - handle to the dialog box.

// uID - ID of the message string to be displayed

// szFunc - function name if it's an API function failure

//

// RETURN VALUE:

// None.

//

//----------------------------------------------------------------------------

void ErrorExit(HWND hwnd, UINT uID, LPTSTR szFunc)

{

TCHAR szMsg[256];

TCHAR szBuf[256];

if (szFunc == NULL)

wcscpy(szMsg, LoadMsg(uID, szBuf, countof(szBuf)));

else

wsprintf(szMsg, TEXT("%s %s"), szFunc,

LoadMsg(uID, szBuf, countof(szBuf)));

MessageBox(NULL, szMsg, NULL, MB_OK);

SendMessage(hwnd,UM_STOPSCANNING,0,0L);

}

//----------------------------------------------------------------------------

//

// FUNCTION: LoadMsg(UINT, LPTSTR, int)

//

// PURPOSE: Load a message string for the string table

//

// PARAMETERS:

// uID - ID of the message string to be loaded

// lpBuffer - buffer to hold the message string

// nBufSize - size of lpBuffer

//

// RETURN VALUE:

// (LPTSTR) pointer to lpBuffer

//

//----------------------------------------------------------------------------

LPTSTR LoadMsg(UINT uID, LPTSTR lpBuffer, int nBufSize)

{

if (!LoadString(hInst, uID, lpBuffer, nBufSize))

wcscpy(lpBuffer, TEXT(""));

return lpBuffer;

}

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,8k
×
×
  • Criar Novo...