LOCAL BOOL ComputeDIBControlSize( HWND hControl, LPINT lpDX, LPINT lpDY ) /***********************************************************************/ { int iWidth, iHeight; // Make sure that the DIB is uncompressed PPUZZLE pPuzzle = GetPuzzle(hControl); if (pPuzzle && pPuzzle->GetSize(&iWidth, &iHeight)) { DWORD dwStyle = GetWindowLong(hControl, GWL_STYLE); if (dwStyle & WS_BORDER) { iWidth += 2; iHeight += 2; } if ( lpDX ) *lpDX = iWidth; if ( lpDY ) *lpDY = iHeight; } else { if ( lpDX ) *lpDX = 1; if ( lpDY ) *lpDY = 1; } return( YES ); }
LOCAL void Puzzle_OnMouseMove(HWND hWindow, int x, int y, UINT keyFlags) /***********************************************************************/ { PPUZZLE pPuzzle = GetPuzzle(hWindow); if (!pPuzzle) return; pPuzzle->OnMouseMove(hWindow, x, y, keyFlags); }
LOCAL void Puzzle_OnSize(HWND hWindow, UINT state, int cx, int cy) /***********************************************************************/ { PPUZZLE pPuzzle = GetPuzzle(hWindow); if (pPuzzle) pPuzzle->Resize(); FORWARD_WM_SIZE(hWindow, state, cx, cy, DefWindowProc); }
LOCAL void Puzzle_OnLButtonDown(HWND hWindow, BOOL fDoubleClick, int x, int y, UINT keyFlags) /***********************************************************************/ { PPUZZLE pPuzzle = GetPuzzle(hWindow); if (!pPuzzle) return; pPuzzle->OnLButtonDown(hWindow, fDoubleClick, x, y, keyFlags); }
LOCAL void Puzzle_OnPaint(HWND hWindow) /***********************************************************************/ { PAINTSTRUCT ps; HDC hDC; if (hDC = BeginPaint( hWindow, &ps ) ) { PPUZZLE pPuzzle = GetPuzzle(hWindow); if (pPuzzle) pPuzzle->OnDraw(hDC, &ps.rcPaint, !pPuzzle->IsSolved()); EndPaint( hWindow, &ps ); } }
LOCAL void Puzzle_OnDestroy(HWND hWindow) /***********************************************************************/ { PPUZZLE pPuzzle = GetPuzzle(hWindow); if (pPuzzle) { if ( pPuzzle->GetTracking() ) { ReleaseCapture(); pPuzzle->SetTracking(NO); } delete pPuzzle; SetPuzzle(hWindow, NULL); } }
BOOL CPuzzleScene::OnInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam) /************************************************************************/ { // call base class on init first CScene::OnInitDialog(hWnd, hWndFocus, lParam); SetDlgItemInt(hWnd, IDC_SKILL, m_iSkill, FALSE); CheckDlgButton(hWnd, IDC_HINTMODE, m_bHintMode); if (GetDlgItem(hWnd, IDC_PUZZLE)) { PPUZZLE lpPuzzle = GetPuzzle(GetDlgItem(hWnd, IDC_PUZZLE)); if (lpPuzzle) { lpPuzzle->Init(m_iSkill, m_iSkill); lpPuzzle->SetHintMode(m_bHintMode); } } return( TRUE ); }
//************************************************************************ void CPuzzleScene::OnCommand(HWND hWnd, int id, HWND hControl, UINT codeNotify) //************************************************************************ { BOOL Bool; int iSkill; switch (id) { case IDC_NEXTPUZZLE: { id = IDC_PUZZLE; if (GetDlgItem(hWnd, IDC_PUZZLE)) { PPUZZLE lpPuzzle = GetPuzzle(GetDlgItem(hWnd, IDC_PUZZLE)); if (lpPuzzle) id = lpPuzzle->NextPuzzle(); } if (GetDlgItem(hWnd, IDC_PUZZLEVIEW)) { SetWindowWord(GetDlgItem(hWnd, IDC_PUZZLEVIEW), GWW_ICONID, id-IDC_PUZZLE1+IDC_PUZZLEVIEW1); InvalidateRect(GetDlgItem(hWnd, IDC_PUZZLEVIEW), NULL, TRUE); } break; } case IDC_HINTMODE: { m_bHintMode = !m_bHintMode; CheckDlgButton(hWnd, id, m_bHintMode); if (GetDlgItem(hWnd, IDC_PUZZLE)) { PPUZZLE lpPuzzle = GetPuzzle(GetDlgItem(hWnd, IDC_PUZZLE)); if (lpPuzzle) lpPuzzle->SetHintMode(m_bHintMode); } break; } case IDC_SKILL: { if (GetFocus() != GetDlgItem(hWnd, id)) break; if (codeNotify != EN_CHANGE) break; iSkill = GetDlgItemInt(hWnd, id, &Bool, NO); if (iSkill <= 0) break; m_iSkill = iSkill; if (GetDlgItem(hWnd, IDC_PUZZLE)) { PPUZZLE lpPuzzle = GetPuzzle(GetDlgItem(hWnd, IDC_PUZZLE)); if (lpPuzzle) lpPuzzle->Init(m_iSkill, m_iSkill); } break; } case IDC_MAINMENU: { break; } case IDC_BACK: { GetApp()->GotoScene(hWnd, m_nNextSceneNo); break; } default: break; } }