dlgWndPinpadInfo::dlgWndPinpadInfo( unsigned long ulHandle, DlgPinUsage PinPusage, DlgPinOperation operation, const std::wstring & csReader, const std::wstring & PinName, const std::wstring & Message, HWND Parent) :Win32Dialog(L"WndPinpadInfo") { m_szHeader=NULL; m_szMessage=NULL; m_ModalHold = false; m_szMessage = _wcsdup( Message.c_str() ); m_ulHandle = ulHandle; std::wstring tmpTitle = L""; tmpTitle += GETSTRING_DLG(PinpadInfo); if (PinPusage == DLG_PIN_AUTH) m_szHeader = _wcsdup( L"Pin da Autenticação" ); else m_szHeader = _wcsdup( PinName.c_str() ); if(!csReader.empty()) { tmpTitle += L" - "; tmpTitle += csReader; } if( CreateWnd( tmpTitle.c_str() , 420, 280, 0, Parent ) ) { if( PinPusage == DLG_PIN_SIGN ) ImagePIN = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_BITMAP2) ); else ImagePIN = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_BITMAP1) ); CreateBitapMask( ImagePIN, ImagePIN_Mask ); TextFont = CreateFont( 16, 0, 0, 0, FW_DONTCARE, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial" ); SendMessage( Parent, WM_SETFONT, (WPARAM)TextFont, 0 ); } }
dlgWndBadPIN::dlgWndBadPIN( std::wstring & PINName, unsigned long RemainingTries, HWND Parent ) :Win32Dialog(L"WndBadPIN") { std::wstring tmpTitle = L""; if(wcscmp(L"nl",langbad.c_str())==0) tmpTitle += (L"Atenção"); else tmpTitle += GETSTRING_DLG(Notification); tmpTitle += L": "; tmpTitle += GETSTRING_DLG(Bad); tmpTitle += L" "; if ( wcsstr(const_cast<wchar_t*>( PINName.c_str()), (L"PIN da Autentica")) != 0) tmpTitle += (L"Pin da Autenticação"); else tmpTitle += PINName; wchar_t tmpBuf[128]; std::wstring tmpStr = L""; _itow_s( RemainingTries, tmpBuf, 128, 10 ); szHeader = new wchar_t[128]; szBody = L""; tmpStr = GETSTRING_DLG(Bad); tmpStr += L" \""; if ( wcsstr(const_cast<wchar_t*>( PINName.c_str()), (L"PIN da Autentica")) != 0) tmpStr += (L"Pin da Autenticação"); else tmpStr += PINName; tmpStr += L"\": "; tmpStr += tmpBuf; tmpStr += L" "; tmpStr += GETSTRING_DLG(RemainingAttempts); wcscpy_s( szHeader, 128, tmpStr.c_str() ); if( RemainingTries == 0 ) { if ( wcsstr(const_cast<wchar_t*>( PINName.c_str()), (L"PIN da Autentica")) != 0) tmpTitle += (L"Pin da Autenticação"); else tmpTitle += PINName; tmpStr += L" "; tmpStr = GETSTRING_DLG(PinBlocked); szBody = tmpStr.c_str(); } else { szBody = GETSTRING_DLG(TryAgainOrCancel); } if( CreateWnd( tmpTitle.c_str() , 280, 230, 0, Parent ) ) { RECT clientRect; GetClientRect( m_hWnd, &clientRect ); TextFont = CreateFont( 16, 0, 0, 0, FW_DONTCARE, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"MS Shell Dlg" ); if( RemainingTries == 0 ) { HWND hOkButton = CreateWindow( L"BUTTON", GETSTRING_DLG(Ok), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, clientRect.right - 160, clientRect.bottom - 36, 72, 24, m_hWnd, (HMENU)IDB_OK, m_hInstance, NULL ); SendMessage( hOkButton, WM_SETFONT, (WPARAM)TextFont, 0 ); } else { HWND hRetryButton = CreateWindow( L"BUTTON", GETSTRING_DLG(Retry), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, clientRect.right - 160, clientRect.bottom - 36, 72, 24, m_hWnd, (HMENU)IDB_RETRY, m_hInstance, NULL ); SendMessage( hRetryButton, WM_SETFONT, (WPARAM)TextFont, 0 ); HWND hCancelButton = CreateWindow( L"BUTTON", GETSTRING_DLG(Cancel), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_TEXT, clientRect.right - 80, clientRect.bottom - 36, 72, 24, m_hWnd, (HMENU)IDB_CANCEL, m_hInstance, NULL ); SendMessage( hCancelButton, WM_SETFONT, (WPARAM)TextFont, 0 ); } HWND hStaticText = CreateWindow( L"STATIC", szBody, WS_CHILD | WS_VISIBLE | SS_CENTER, 0, clientRect.bottom - 76, clientRect.right, 22, m_hWnd, (HMENU)IDC_STATIC, m_hInstance, NULL ); SendMessage( hStaticText, WM_SETFONT, (WPARAM)TextFont, 0 ); ImagePIN = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_PIN) ); CreateBitapMask( ImagePIN, ImagePIN_Mask ); } }
dlgWndAskPIN::dlgWndAskPIN( DlgPinInfo pinInfo, DlgPinUsage PinPusage, std::wstring & Header, std::wstring & PINName, bool UseKeypad, HWND Parent ) :Win32Dialog(L"WndAskPIN") { m_UseKeypad = UseKeypad; PinResult[0] = ' '; PinResult[1] = (char)0; std::wstring tmpTitle = L""; if( PinPusage == DLG_PIN_SIGN ) tmpTitle += GETSTRING_DLG(SigningWith); else tmpTitle += GETSTRING_DLG(Asking); tmpTitle += L" "; tmpTitle += PINName; m_ulPinMinLen = pinInfo.ulMinLen; m_ulPinMaxLen = pinInfo.ulMaxLen; szHeader = Header.c_str(); szPIN = PINName.c_str(); int Height = 280; if( m_UseKeypad ) Height = 480; if( CreateWnd( tmpTitle.c_str() , 480, Height, 0, Parent ) ) { RECT clientRect; GetClientRect( m_hWnd, &clientRect ); TextFont = CreateFont( 16, 0, 0, 0, FW_DONTCARE, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"MS Shell Dlg" ); //OK Button HWND hOkButton = CreateWindow( L"BUTTON", GETSTRING_DLG(Ok), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, clientRect.right - 160, clientRect.bottom - 36, 72, 24, m_hWnd, (HMENU)IDB_OK, m_hInstance, NULL ); EnableWindow( hOkButton, false ); //Cancel Button HWND hCancelButton = CreateWindow( L"BUTTON", GETSTRING_DLG(Cancel), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_TEXT, clientRect.right - 80, clientRect.bottom - 36, 72, 24, m_hWnd, (HMENU)IDB_CANCEL, m_hInstance, NULL ); m_KeypadHeight=0; //Virtual Keypad if( m_UseKeypad ) { int top = 60; int hMargin = 12; int vMargin = 12; int btnwidth = 48; int btnheight = 48; int totwidth = btnwidth*3 + 2*hMargin; int totheight = btnheight*4 +3*vMargin; int left = (clientRect.right - clientRect.left - totwidth)/2; m_KeypadHeight = top + totheight + 8; for( int i = 0; i < 4; i++ ) { for( int j = 0; j < 3; j++ ) { if( i == 3 && j == 0 ) continue; HWND hOkButton = CreateWindow( L"BUTTON", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_OWNERDRAW, //BS_FLAT, left + ( btnwidth + hMargin )* j, top + ( btnheight + vMargin ) * i, btnwidth, btnheight, m_hWnd, (HMENU)(long long)(IDB_KeypadStart + 3*i + j ), m_hInstance, NULL ); } } ImageKP_BTN[0] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_0) ); ImageKP_BTN[1] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_1) ); ImageKP_BTN[2] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_2) ); ImageKP_BTN[3] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_3) ); ImageKP_BTN[4] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_4) ); ImageKP_BTN[5] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_5) ); ImageKP_BTN[6] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_6) ); ImageKP_BTN[7] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_7) ); ImageKP_BTN[8] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_8) ); ImageKP_BTN[9] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_9) ); ImageKP_BTN[10] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_CE) ); ImageKP_BTN[11] = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_KP_BTN) ); CreateBitapMask( ImageKP_BTN[11], ImageKP_BTN_Mask ); //MWLOG(LEV_DEBUG, MOD_DLG, L" dlgWndAskPIN : Virtual pinpad - LoadBitmap"); } DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_PASSWORD; if( pinInfo.ulFlags & PIN_FLAG_DIGITS ) dwStyle |= ES_NUMBER; LONG pinTop=0; LONG pinLeft=clientRect.right/2 - 100 + 40; if( m_UseKeypad ) pinTop = clientRect.top + 20; else pinTop = clientRect.bottom - 80; HWND hTextEdit = CreateWindowEx( WS_EX_CLIENTEDGE, L"EDIT", L"", dwStyle, pinLeft, pinTop, 160, 26, m_hWnd, (HMENU)IDC_EDIT, m_hInstance, NULL ); SendMessage( hTextEdit, EM_LIMITTEXT, m_ulPinMaxLen, 0 ); HWND hStaticText = CreateWindow( L"STATIC", szPIN, WS_CHILD | WS_VISIBLE | SS_RIGHT, pinLeft-100, pinTop +4 , 96, 22, m_hWnd, (HMENU)IDC_STATIC, m_hInstance, NULL ); SendMessage( hStaticText, WM_SETFONT, (WPARAM)TextFont, 0 ); SendMessage( hOkButton, WM_SETFONT, (WPARAM)TextFont, 0 ); SendMessage( hCancelButton, WM_SETFONT, (WPARAM)TextFont, 0 ); if( PinPusage == DLG_PIN_SIGN ) ImagePIN = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_PINSIGN) ); else ImagePIN = LoadBitmap( m_hInstance, MAKEINTRESOURCE(IDB_PIN) ); CreateBitapMask( ImagePIN, ImagePIN_Mask ); SetFocus(GetDlgItem( m_hWnd, IDC_EDIT )); } }