Mercurial > vba-linux
view src/win32/GSACodeSelect.cpp @ 3:b05d00f19d80
fix some formatting
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:33:11 -0600 |
parents | f9f4f1b99eed |
children |
line wrap: on
line source
1 // GSACodeSelect.cpp : implementation file2 //4 #include "stdafx.h"5 #include "resource.h"6 #include "GSACodeSelect.h"8 /////////////////////////////////////////////////////////////////////////////9 // GSACodeSelect dialog11 GSACodeSelect::GSACodeSelect(FILE *file, CWnd*pParent /*=NULL*/)12 : CDialog(GSACodeSelect::IDD, pParent)13 {14 //{{AFX_DATA_INIT(GSACodeSelect)15 // NOTE: the ClassWizard will add member initialization here16 //}}AFX_DATA_INIT17 m_file = file;18 }20 void GSACodeSelect::DoDataExchange(CDataExchange*pDX)21 {22 CDialog::DoDataExchange(pDX);23 //{{AFX_DATA_MAP(GSACodeSelect)24 DDX_Control(pDX, IDC_GAME_LIST, m_games);25 //}}AFX_DATA_MAP26 }28 BEGIN_MESSAGE_MAP(GSACodeSelect, CDialog)29 //{{AFX_MSG_MAP(GSACodeSelect)30 ON_BN_CLICKED(ID_OK, OnOk)31 ON_LBN_SELCHANGE(IDC_GAME_LIST, OnSelchangeGameList)32 ON_BN_CLICKED(ID_CANCEL, OnCancel)33 //}}AFX_MSG_MAP34 END_MESSAGE_MAP()36 /////////////////////////////////////////////////////////////////////////////37 // GSACodeSelect message handlers39 void GSACodeSelect::OnCancel()40 {41 EndDialog(-1);42 }44 void GSACodeSelect::OnOk()45 {46 EndDialog(m_games.GetCurSel());47 }49 void GSACodeSelect::OnSelchangeGameList()50 {51 int item = m_games.GetCurSel();52 CWnd *ok = GetDlgItem(ID_OK);54 ok->EnableWindow(item != -1);55 }57 BOOL GSACodeSelect::OnInitDialog()58 {59 CDialog::OnInitDialog();61 char buffer[1024];63 FILE *f = m_file;64 int games = 0;65 int len = 0;66 fseek(f, -4, SEEK_CUR);67 fread(&games, 1, 4, f);68 while (games > 0)69 {70 fread(&len, 1, 4, f);71 fread(buffer, 1, len, f);72 buffer[len] = 0;73 m_games.AddString(buffer);74 int codes = 0;75 fread(&codes, 1, 4, f);77 while (codes > 0)78 {79 fread(&len, 1, 4, f);80 fseek(f, len, SEEK_CUR);81 fread(&len, 1, 4, f);82 fseek(f, len, SEEK_CUR);83 fseek(f, 4, SEEK_CUR);84 fread(&len, 1, 4, f);85 fseek(f, len*12, SEEK_CUR);86 codes--;87 }88 games--;89 }90 GetDlgItem(ID_OK)->EnableWindow(FALSE);91 CenterWindow();93 return TRUE; // return TRUE unless you set the focus to a control94 // EXCEPTION: OCX Property Pages should return FALSE95 }