Mercurial > vba-clojure
diff src/win32/GSACodeSelect.cpp @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/GSACodeSelect.cpp Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,96 @@ 1.4 +// GSACodeSelect.cpp : implementation file 1.5 +// 1.6 + 1.7 +#include "stdafx.h" 1.8 +#include "resource.h" 1.9 +#include "GSACodeSelect.h" 1.10 + 1.11 +///////////////////////////////////////////////////////////////////////////// 1.12 +// GSACodeSelect dialog 1.13 + 1.14 +GSACodeSelect::GSACodeSelect(FILE *file, CWnd*pParent /*=NULL*/) 1.15 + : CDialog(GSACodeSelect::IDD, pParent) 1.16 +{ 1.17 + //{{AFX_DATA_INIT(GSACodeSelect) 1.18 + // NOTE: the ClassWizard will add member initialization here 1.19 + //}}AFX_DATA_INIT 1.20 + m_file = file; 1.21 +} 1.22 + 1.23 +void GSACodeSelect::DoDataExchange(CDataExchange*pDX) 1.24 +{ 1.25 + CDialog::DoDataExchange(pDX); 1.26 + //{{AFX_DATA_MAP(GSACodeSelect) 1.27 + DDX_Control(pDX, IDC_GAME_LIST, m_games); 1.28 + //}}AFX_DATA_MAP 1.29 +} 1.30 + 1.31 +BEGIN_MESSAGE_MAP(GSACodeSelect, CDialog) 1.32 +//{{AFX_MSG_MAP(GSACodeSelect) 1.33 +ON_BN_CLICKED(ID_OK, OnOk) 1.34 +ON_LBN_SELCHANGE(IDC_GAME_LIST, OnSelchangeGameList) 1.35 +ON_BN_CLICKED(ID_CANCEL, OnCancel) 1.36 +//}}AFX_MSG_MAP 1.37 +END_MESSAGE_MAP() 1.38 + 1.39 +///////////////////////////////////////////////////////////////////////////// 1.40 +// GSACodeSelect message handlers 1.41 + 1.42 +void GSACodeSelect::OnCancel() 1.43 +{ 1.44 + EndDialog(-1); 1.45 +} 1.46 + 1.47 +void GSACodeSelect::OnOk() 1.48 +{ 1.49 + EndDialog(m_games.GetCurSel()); 1.50 +} 1.51 + 1.52 +void GSACodeSelect::OnSelchangeGameList() 1.53 +{ 1.54 + int item = m_games.GetCurSel(); 1.55 + CWnd *ok = GetDlgItem(ID_OK); 1.56 + 1.57 + ok->EnableWindow(item != -1); 1.58 +} 1.59 + 1.60 +BOOL GSACodeSelect::OnInitDialog() 1.61 +{ 1.62 + CDialog::OnInitDialog(); 1.63 + 1.64 + char buffer[1024]; 1.65 + 1.66 + FILE *f = m_file; 1.67 + int games = 0; 1.68 + int len = 0; 1.69 + fseek(f, -4, SEEK_CUR); 1.70 + fread(&games, 1, 4, f); 1.71 + while (games > 0) 1.72 + { 1.73 + fread(&len, 1, 4, f); 1.74 + fread(buffer, 1, len, f); 1.75 + buffer[len] = 0; 1.76 + m_games.AddString(buffer); 1.77 + int codes = 0; 1.78 + fread(&codes, 1, 4, f); 1.79 + 1.80 + while (codes > 0) 1.81 + { 1.82 + fread(&len, 1, 4, f); 1.83 + fseek(f, len, SEEK_CUR); 1.84 + fread(&len, 1, 4, f); 1.85 + fseek(f, len, SEEK_CUR); 1.86 + fseek(f, 4, SEEK_CUR); 1.87 + fread(&len, 1, 4, f); 1.88 + fseek(f, len*12, SEEK_CUR); 1.89 + codes--; 1.90 + } 1.91 + games--; 1.92 + } 1.93 + GetDlgItem(ID_OK)->EnableWindow(FALSE); 1.94 + CenterWindow(); 1.95 + 1.96 + return TRUE; // return TRUE unless you set the focus to a control 1.97 + // EXCEPTION: OCX Property Pages should return FALSE 1.98 +} 1.99 +