static LRESULT CALLBACK hb_gt_wvw_EBProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { HWND hWndParent = GetParent( hWnd ); int nWin; int nCtrlId; WNDPROC OldProc; int nEBType; int iKey; PWVW_GLO wvw = hb_gt_wvw(); PWVW_WIN wvw_win; if( wvw == NULL || hWndParent == NULL ) return DefWindowProc( hWnd, message, wParam, lParam ); for( nWin = 0; nWin < wvw->iNumWindows; nWin++ ) { if( wvw->pWin[ nWin ]->hWnd == hWndParent ) break; } if( nWin >= wvw->iNumWindows ) return DefWindowProc( hWnd, message, wParam, lParam ); wvw_win = wvw->pWin[ nWin ]; nCtrlId = hb_gt_wvw_FindControlId( wvw_win, WVW_CONTROL_EDITBOX, hWnd, &nEBType ); if( nCtrlId == 0 ) { hb_errInternal( 10010, "EditBox: Control ID not found with hb_gt_wvw_FindControlId()", NULL, NULL ); return DefWindowProc( hWnd, message, wParam, lParam ); } OldProc = hb_gt_wvw_GetControlProc( wvw_win, WVW_CONTROL_EDITBOX, hWnd ); if( OldProc == NULL ) { hb_errInternal( 10011, "EditBox: Failed hb_gt_wvw_GetControlProc()", NULL, NULL ); return DefWindowProc( hWnd, message, wParam, lParam ); } iKey = 0; switch( message ) { case WM_KEYDOWN: case WM_SYSKEYDOWN: { HB_BOOL bAlt = GetKeyState( VK_MENU ) & 0x8000; int c = ( int ) wParam; switch( c ) { case VK_F1: iKey = hb_gt_wvw_JustTranslateKey( K_F1, K_SH_F1, K_ALT_F1, K_CTRL_F1 ); break; case VK_F2: iKey = hb_gt_wvw_JustTranslateKey( K_F2, K_SH_F2, K_ALT_F2, K_CTRL_F2 ); break; case VK_F3: iKey = hb_gt_wvw_JustTranslateKey( K_F3, K_SH_F3, K_ALT_F3, K_CTRL_F3 ); break; case VK_F4: if( bAlt ) { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } else iKey = hb_gt_wvw_JustTranslateKey( K_F4, K_SH_F4, K_ALT_F4, K_CTRL_F4 ); break; case VK_F5: iKey = hb_gt_wvw_JustTranslateKey( K_F5, K_SH_F5, K_ALT_F5, K_CTRL_F5 ); break; case VK_F6: iKey = hb_gt_wvw_JustTranslateKey( K_F6, K_SH_F6, K_ALT_F6, K_CTRL_F6 ); break; case VK_F7: iKey = hb_gt_wvw_JustTranslateKey( K_F7, K_SH_F7, K_ALT_F7, K_CTRL_F7 ); break; case VK_F8: iKey = hb_gt_wvw_JustTranslateKey( K_F8, K_SH_F8, K_ALT_F8, K_CTRL_F8 ); break; case VK_F9: iKey = hb_gt_wvw_JustTranslateKey( K_F9, K_SH_F9, K_ALT_F9, K_CTRL_F9 ); break; case VK_F10: iKey = hb_gt_wvw_JustTranslateKey( K_F10, K_SH_F10, K_ALT_F10, K_CTRL_F10 ); break; case VK_F11: iKey = hb_gt_wvw_JustTranslateKey( K_F11, K_SH_F11, K_ALT_F11, K_CTRL_F11 ); break; case VK_F12: iKey = hb_gt_wvw_JustTranslateKey( K_F12, K_SH_F12, K_ALT_F12, K_CTRL_F12 ); break; } break; } case WM_CHAR: { HB_BOOL bCtrl = GetKeyState( VK_CONTROL ) & 0x8000; int iScanCode = HB_LOBYTE( HIWORD( lParam ) ); int c = ( int ) wParam; if( bCtrl && iScanCode == 28 ) iKey = K_CTRL_RETURN; else if( bCtrl && ( c >= 1 && c <= 26 ) ) iKey = s_K_Ctrl[ c - 1 ]; else { switch( c ) { case VK_BACK: iKey = hb_gt_wvw_JustTranslateKey( K_BS, K_SH_BS, K_ALT_BS, K_CTRL_BS ); break; case VK_TAB: iKey = hb_gt_wvw_JustTranslateKey( K_TAB, K_SH_TAB, K_ALT_TAB, K_CTRL_TAB ); break; case VK_RETURN: iKey = hb_gt_wvw_JustTranslateKey( K_RETURN, K_SH_RETURN, K_ALT_RETURN, K_CTRL_RETURN ); break; case VK_ESCAPE: iKey = K_ESC; break; default: #if ! defined( UNICODE ) if( wvw_win->CodePage == OEM_CHARSET ) c = hb_gt_wvw_key_ansi_to_oem( c ); #endif iKey = c; } } break; } case WM_SYSCHAR: { int c, iScanCode = HB_LOBYTE( HIWORD( lParam ) ); switch( iScanCode ) { case 2: c = K_ALT_1; break; case 3: c = K_ALT_2; break; case 4: c = K_ALT_3; break; case 5: c = K_ALT_4; break; case 6: c = K_ALT_5; break; case 7: c = K_ALT_6; break; case 8: c = K_ALT_7; break; case 9: c = K_ALT_8; break; case 10: c = K_ALT_9; break; case 11: c = K_ALT_0; break; case 13: c = K_ALT_EQUALS; break; case 14: c = K_ALT_BS; break; case 16: c = K_ALT_Q; break; case 17: c = K_ALT_W; break; case 18: c = K_ALT_E; break; case 19: c = K_ALT_R; break; case 20: c = K_ALT_T; break; case 21: c = K_ALT_Y; break; case 22: c = K_ALT_U; break; case 23: c = K_ALT_I; break; case 24: c = K_ALT_O; break; case 25: c = K_ALT_P; break; case 30: c = K_ALT_A; break; case 31: c = K_ALT_S; break; case 32: c = K_ALT_D; break; case 33: c = K_ALT_F; break; case 34: c = K_ALT_G; break; case 35: c = K_ALT_H; break; case 36: c = K_ALT_J; break; case 37: c = K_ALT_K; break; case 38: c = K_ALT_L; break; case 44: c = K_ALT_Z; break; case 45: c = K_ALT_X; break; case 46: c = K_ALT_C; break; case 47: c = K_ALT_V; break; case 48: c = K_ALT_B; break; case 49: c = K_ALT_N; break; case 50: c = K_ALT_M; break; default: c = ( int ) wParam; } iKey = c; break; } } if( iKey != 0 ) { HB_BOOL fCodeExec = HB_FALSE; PHB_ITEM pKey = hb_itemPutNI( NULL, iKey ); PHB_ITEM pCodeblock = hb_itemDoC( "SETKEY", 1, pKey ); if( HB_IS_EVALITEM( pCodeblock ) ) { PHB_ITEM pReturn; SetFocus( hWndParent ); pReturn = hb_itemDo( pCodeblock, 0 ); hb_itemRelease( pReturn ); SetFocus( hWnd ); fCodeExec = HB_TRUE; } hb_itemRelease( pCodeblock ); hb_itemRelease( pKey ); if( fCodeExec ) return 0; } switch( message ) { case WM_KEYDOWN: case WM_SYSKEYDOWN: { HB_BOOL bAlt = GetKeyState( VK_MENU ) & 0x8000; HB_BOOL bCtrl = GetKeyState( VK_CONTROL ) & 0x8000; HB_BOOL bShift = GetKeyState( VK_SHIFT ) & 0x8000; int c = ( int ) wParam; HB_BOOL fMultiline; if( ! hb_gt_wvw_BufferedKey( ( int ) wParam ) ) break; fMultiline = ( ( nEBType & WVW_EB_MULTILINE ) == WVW_EB_MULTILINE ); switch( c ) { case VK_F4: if( bAlt ) { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } break; case VK_RETURN: if( fMultiline || bAlt || bShift || bCtrl ) break; else if( ! fMultiline ) { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } case VK_ESCAPE: if( bAlt || bShift || bCtrl ) break; else { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } case VK_UP: case VK_DOWN: case VK_PRIOR: case VK_NEXT: if( fMultiline ) break; else { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } case VK_TAB: if( ! bCtrl && ! bAlt ) { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } break; case VK_BACK: if( ! bAlt ) break; if( SendMessage( hWnd, EM_CANUNDO, 0, 0 ) ) { SendMessage( hWnd, EM_UNDO, 0, 0 ); return 0; } break; } break; } case WM_CHAR: { HB_BOOL bCtrl = GetKeyState( VK_CONTROL ) & 0x8000; switch( ( int ) wParam ) { case VK_TAB: return 0; case 1: if( bCtrl ) { SendMessage( hWnd, EM_SETSEL, 0, ( LPARAM ) -1 ); return 0; } break; } break; } } return CallWindowProc( OldProc, hWnd, message, wParam, lParam ); }
static LRESULT CALLBACK hb_gt_wvw_CBProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { HWND hWndParent = GetParent( hWnd ); int nWin; int nCtrlId; WNDPROC OldProc; int nKbdType; PWVW_GLO wvw = hb_gt_wvw(); PWVW_WIN wvw_win; if( wvw == NULL || hWndParent == NULL ) return DefWindowProc( hWnd, message, wParam, lParam ); for( nWin = 0; nWin < wvw->iNumWindows; nWin++ ) { if( wvw->pWin[ nWin ]->hWnd == hWndParent ) break; } if( nWin >= wvw->iNumWindows ) return DefWindowProc( hWnd, message, wParam, lParam ); wvw_win = wvw->pWin[ nWin ]; nCtrlId = hb_gt_wvw_FindControlId( wvw_win, WVW_CONTROL_COMBOBOX, hWnd, &nKbdType ); if( nCtrlId == 0 ) { hb_errInternal( 10010, "ComboBox: Control ID not found with hb_gt_wvw_FindControlId()", NULL, NULL ); return DefWindowProc( hWnd, message, wParam, lParam ); } OldProc = hb_gt_wvw_GetControlProc( wvw_win, WVW_CONTROL_COMBOBOX, hWnd ); if( OldProc == NULL ) { hb_errInternal( 10011, "ComboBox: Failed hb_gt_wvw_GetControlProc()", NULL, NULL ); return DefWindowProc( hWnd, message, wParam, lParam ); } switch( message ) { case WM_KEYDOWN: case WM_SYSKEYDOWN: { HB_BOOL bAlt = GetKeyState( VK_MENU ) & 0x8000; HB_BOOL bCtrl = GetKeyState( VK_CONTROL ) & 0x8000; HB_BOOL bShift = GetKeyState( VK_SHIFT ) & 0x8000; int c = ( int ) wParam; HB_BOOL fDropped; if( ! hb_gt_wvw_BufferedKey( ( int ) wParam ) ) break; fDropped = ( HB_BOOL ) SendMessage( hWnd, CB_GETDROPPEDSTATE, 0, 0 ); if( nKbdType == WVW_CB_KBD_STANDARD ) { switch( c ) { case VK_F4: if( bAlt ) { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } break; case VK_ESCAPE: if( ! bCtrl && ! bAlt && ! bShift && ! fDropped ) { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } break; case VK_TAB: if( ! bCtrl && ! bAlt ) { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } break; case VK_NEXT: if( fDropped || bAlt || bShift || bCtrl ) break; else { if( ! fDropped ) SendMessage( hWnd, CB_SHOWDROPDOWN, ( WPARAM ) TRUE, 0 ); else { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); } return 0; } case VK_RETURN: if( ! bCtrl && ! bAlt && ! bShift && ! fDropped ) { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } break; } break; } /* WVW_CB_KBD_STANDARD */ else /* assume WVW_CB_KBD_CLIPPER */ { switch( c ) { case VK_F4: if( bAlt ) { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } break; case VK_RETURN: if( fDropped || bAlt || bShift || bCtrl ) break; else { if( ! fDropped ) { SendMessage( hWnd, CB_SHOWDROPDOWN, ( WPARAM ) TRUE, 0 ); return 0; } else { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } } case VK_ESCAPE: if( fDropped || bAlt || bShift || bCtrl ) break; else { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } case VK_UP: case VK_DOWN: case VK_RIGHT: case VK_LEFT: case VK_HOME: case VK_END: case VK_PRIOR: case VK_NEXT: if( fDropped ) break; else { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } case VK_TAB: if( ! bCtrl && ! bAlt ) { SetFocus( hWndParent ); PostMessage( hWndParent, message, wParam, lParam ); return 0; } break; } break; } } } return CallWindowProc( OldProc, hWnd, message, wParam, lParam ); }