示例#1
0
LOCAL void ListBox_OnKeyDown(HWND hWindow, UINT vk, BOOL fDown, int cRepeat, UINT flags)
/***********************************************************************/
{
// get the listbox data pointer
LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	{
	FORWARD_WM_KEYDOWN(hWindow, vk, cRepeat, flags, ListBox_CallWindowProc);
	return;
	}
if (lpData->iSelectDir)
	Select_OnKeyDown(hWindow, vk, fDown, cRepeat, flags);
else
	FORWARD_WM_KEYDOWN(hWindow, vk, cRepeat, flags, ListBox_CallWindowProc);
}
示例#2
0
static void Video_OnPaint(HWND hWindow)
/***********************************************************************/
{
	LPVIDEO lpVideo;
	HDC hDC;
	PAINTSTRUCT ps;

	if ( !(lpVideo = (LPVIDEO)GetWindowLong( hWindow, GWL_DATAPTR )) )
		return;
	hDC = BeginPaint( hWindow, &ps );
	MCIUpdate( lpVideo->hDevice, hDC );
	EndPaint( hWindow, &ps );
	if ( !lpVideo->bAutoplayUsed )
	{
		lpVideo->bAutoplayUsed = YES;
		if ( GetSwitchValue( 'a', lpVideo->lpSwitches ) )
			FORWARD_WM_KEYDOWN( hWindow, 'P', 0/*cRepeat*/, 0/*flags*/, SendMessage);
		Video_DrawProcInstall( hWindow, VDP_HotspotSet, VDP_HotspotDraw, 33 );
	}
}
示例#3
0
LOCAL void Select_OnKeyDown(HWND hWindow, UINT vk, BOOL fDown, int cRepeat, UINT flags)
/***********************************************************************/
{
int iCaretIndex, iTopItem, nItems;

// get the listbox data pointer
LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	{
	FORWARD_WM_KEYDOWN(hWindow, vk, cRepeat, flags, ListBox_CallWindowProc);
	}
else
if (vk == VK_UP)
	{
	iTopItem = ListBox_GetTopIndex(hWindow);
	iCaretIndex = ListBox_GetCaretIndex(hWindow);
	--iCaretIndex;
	if (iCaretIndex < 0)
		return;
	// make sure the new top item is selected
	SelectItems(hWindow, iCaretIndex);
	// scroll the listbox and make sure it gets repainted
	if (iCaretIndex < iTopItem)
		ListBox_SetTopIndex(hWindow, iCaretIndex);
	UpdateWindow(hWindow);
	FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow),
					hWindow, LBN_SELCHANGE, SendMessage);
	}
else
if (vk == VK_DOWN)
	{
	RECT rect;
	int iItemHeight, iVisible;

	iTopItem = ListBox_GetTopIndex(hWindow);
	iCaretIndex = ListBox_GetCaretIndex(hWindow);
	++iCaretIndex;
	nItems = ListBox_GetCount(hWindow);
	if (iCaretIndex >= nItems)
		return;
	// make sure the new top item is selected
	SelectItems(hWindow, iCaretIndex);

	// get the client area
	GetClientRect(hWindow, &rect);        
  
	// the height of each item   
	iItemHeight = ListBox_GetItemHeight(hWindow, 0);          

	// the number of visible items                  
	iVisible = (rect.bottom - rect.top) / iItemHeight;

	// see if there is anything to scroll
	if (iCaretIndex >= (iTopItem+iVisible))	
		{
		++iTopItem;
		ListBox_SetTopIndex(hWindow, iTopItem);
		}
	UpdateWindow(hWindow);
	FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow),
					hWindow, LBN_SELCHANGE, SendMessage);
	}
// ignore all other keystrokes
}
示例#4
0
//***********************************************************************
void CJungleScene::HandlePuzzle1Buttons( HWND hWnd, ITEMID id )
//***********************************************************************
{
	int iSndID = GetWindowWord( GetDlgItem(hWnd, id), GWW_ICONID );
	if ( !iSndID )
		iSndID = id;

	// Get the current shot info from the video
	LPVIDEO lpVideo = (LPVIDEO)GetWindowLong( GetDlgItem(hWnd, IDC_VIDEO_GAME), GWL_DATAPTR );
	if ( !lpVideo)
		return;
	LPSHOT lpShot =  &lpVideo->lpAllShots [lpVideo->lCurrentShot - 1];
	if (!lpShot)
		return;

	// Extract the shot number
	int iShotNum = (int)(lpShot->lFlags & A_VALUE_BITS);
	// How many items in the list?
	int nItems = sizeof(m_PuzzleInfo) / sizeof(VRECOINFO);
	// Get the index of the item matching the shot
	for ( int idx = 0; idx < nItems; idx++ )
	{
		if ( iShotNum == m_PuzzleInfo[idx].iShotNum )
			break;
	}

	if ( idx == nItems )
		return; // Couldn't find the shot in the list

	int iNxtSyllable = m_PuzzleInfo[idx].iSyllables[nMatches];
	int iNumSyllables = m_PuzzleInfo[idx].sNumSyllables;

	// Does the button match the next syllable?
	if (iSndID == iNxtSyllable)
	{
//		int iState = GetWindowWord( GetDlgItem(hWnd, id), GWW_STATE );
//		SendMessage( GetDlgItem(hWnd, id), SM_SETSTATE, !iState, 0L);
		SendMessage( GetDlgItem(hWnd, id), SM_SETSTATE, 1, 0L);

		// Give them instinct points
		ChangeInstinctMeter (hWnd, GOOD_RESPONSE);
		// Set progress meter
		nMatches++;
		long lProgress = (METER_MAX * nMatches) / (long)iNumSyllables;
		SendMessage( GetDlgItem(hWnd, IDC_PUZ_PROGRESS), SM_SETPOSITION, 0, lProgress );
		// Is this the last syllable?
		if (nMatches >= iNumSyllables)
		{
			// Delay so the progress meter is shown
			Delay( 1500 );
			// Simulate an EVENT_DOWN (good response) to the video control
			FORWARD_WM_KEYDOWN (GetDlgItem(hWnd, IDC_VIDEO_GAME), VK_DOWN,
				0/*cRepeat*/, 0/*flags*/, SendMessage);
		}
		return;
	}

	// It is not a match

	// Take instinct points away
	ChangeInstinctMeter (hWnd, BAD_RESPONSE);

//	// Simulate a wrong button pressed
//	FORWARD_WM_KEYDOWN (GetDlgItem(hWnd, IDC_VIDEO_GAME), VK_UP,
//		0/*cRepeat*/, 0/*flags*/, SendMessage);
}