static LRESULT CALLBACK hb_gt_wvw_TBProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { HWND hWndParent = GetParent( hWnd ); int nWin; PWVW_GLO wvw = hb_gt_wvw(); PWVW_WIN wvw_win; if( wvw == NULL || hWndParent == NULL ) { hb_errInternal( 10012, "ToolBar: Parent window is missing", NULL, 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 ) { hb_errInternal( 10013, "ToolBar: Invalid parent Window ID", NULL, NULL ); return DefWindowProc( hWnd, message, wParam, lParam ); } wvw_win = wvw->pWin[ nWin ]; switch( message ) { case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: case WM_RBUTTONUP: case WM_LBUTTONUP: case WM_RBUTTONDBLCLK: case WM_LBUTTONDBLCLK: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MBUTTONDBLCLK: case WM_MOUSEMOVE: case WM_MOUSEWHEEL: case WM_NCMOUSEMOVE: if( ! hb_gt_wvw_AcceptingInput() || ( nWin != wvw->iNumWindows - 1 ) ) return 0; hb_gt_wvw_TBMouseEvent( wvw_win, hWnd, message, wParam, lParam ); break; case WM_PAINT: { HGDIOBJ hOldObj; HDC hdc; RECT rTB; int iTop, iRight; CallWindowProc( wvw_win->tbOldProc, hWnd, message, wParam, lParam ); memset( &rTB, 0, sizeof( rTB ) ); GetClientRect( hWnd, &rTB ); iTop = rTB.bottom - 3; iRight = rTB.right; hdc = GetDC( hWnd ); hOldObj = SelectObject( hdc, wvw->a.penWhite ); MoveToEx( hdc, 0, iTop, NULL ); /* Top */ LineTo( hdc, iRight, iTop ); SelectObject( hdc, wvw->a.penBlack ); MoveToEx( hdc, 0, iTop + 2, NULL ); /* Bottom */ LineTo( hdc, iRight, iTop + 2 ); SelectObject( hdc, wvw->a.penDarkGray ); MoveToEx( hdc, 0, iTop + 1, NULL ); /* Middle */ LineTo( hdc, iRight, iTop + 1 ); SelectObject( wvw_win->hdc, hOldObj ); ReleaseDC( hWnd, hdc ); return 0; } } return CallWindowProc( wvw_win->tbOldProc, hWnd, message, wParam, lParam ); }
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 void hb_gt_wvw_TBMouseEvent( PWVW_WIN wvw_win, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { POINT xy, colrow; SHORT keyCode = 0; SHORT keyState = 0; PWVW_GLO wvw = hb_gt_wvw(); HB_SYMBOL_UNUSED( hWnd ); HB_SYMBOL_UNUSED( wParam ); if( message == WM_MOUSEMOVE || message == WM_NCMOUSEMOVE ) { if( ! wvw_win->MouseMove ) return; } xy.x = LOWORD( lParam ); xy.y = HIWORD( lParam ); colrow = hb_gt_wvw_TBGetColRowFromXY( wvw_win, xy.x, xy.y ); hb_gt_wvw_SetMouseX( wvw_win, colrow.x ); hb_gt_wvw_SetMouseY( wvw_win, colrow.y ); switch( message ) { case WM_LBUTTONDBLCLK: keyCode = K_LDBLCLK; break; case WM_RBUTTONDBLCLK: keyCode = K_RDBLCLK; break; case WM_LBUTTONDOWN: { HWND hWndFocus = GetFocus(); if( hb_gt_wvw_GetControlClass( wvw_win, hWndFocus ) > 0 ) SetFocus( hWnd ); keyCode = K_LBUTTONDOWN; break; } case WM_RBUTTONDOWN: keyCode = K_RBUTTONDOWN; break; case WM_LBUTTONUP: keyCode = K_LBUTTONUP; break; case WM_RBUTTONUP: if( wvw_win->hPopup ) { int nPopupRet; GetCursorPos( &xy ); nPopupRet = ( int ) TrackPopupMenu( wvw_win->hPopup, TPM_CENTERALIGN + TPM_RETURNCMD, xy.x, xy.y, 0, hWnd, NULL ); if( nPopupRet ) hb_gt_wvw_AddCharToInputQueue( nPopupRet ); return; } else { keyCode = K_RBUTTONUP; break; } case WM_MBUTTONDOWN: keyCode = K_MBUTTONDOWN; break; case WM_MBUTTONUP: keyCode = K_MBUTTONUP; break; case WM_MBUTTONDBLCLK: keyCode = K_MDBLCLK; break; case WM_MOUSEMOVE: keyState = ( SHORT ) wParam; if( keyState == MK_LBUTTON ) keyCode = K_MMLEFTDOWN; else if( keyState == MK_RBUTTON ) keyCode = K_MMRIGHTDOWN; else if( keyState == MK_MBUTTON ) keyCode = K_MMMIDDLEDOWN; else keyCode = K_MOUSEMOVE; break; case WM_MOUSEWHEEL: keyState = HIWORD( wParam ); if( keyState > 0 ) keyCode = K_MWFORWARD; else keyCode = K_MWBACKWARD; break; case WM_NCMOUSEMOVE: keyCode = K_NCMOUSEMOVE; break; } if( wvw->a.pSymWVW_TBMOUSE && keyCode != 0 && hb_vmRequestReenter() ) { hb_vmPushDynSym( wvw->a.pSymWVW_TBMOUSE ); hb_vmPushNil(); hb_vmPushInteger( wvw_win->nWinId ); hb_vmPushInteger( keyCode ); hb_vmPushInteger( colrow.y ); hb_vmPushInteger( colrow.x ); hb_vmPushInteger( keyState ); hb_vmDo( 5 ); hb_vmRequestRestore(); } hb_gt_wvw_AddCharToInputQueue( keyCode ); }
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 ); }