@@ -54,11 +54,12 @@ void configuration_dialog::open()
5454{
5555 if (!dialog_handle_)
5656 {
57- dialog_handle_ = CreateDialog (
57+ dialog_handle_ = CreateDialogParam (
5858 gModuleInstance ,
5959 MAKEINTRESOURCE (IDD_DIALOG1),
6060 GetActiveWindow (),
61- process_message);
61+ callback_procedure,
62+ reinterpret_cast <LPARAM>(this ));
6263 }
6364
6465 ShowWindow (dialog_handle_, SW_SHOWNORMAL);
@@ -172,59 +173,75 @@ void configuration_dialog::eject_or_select_new_cartridge(size_t slot)
172173 mpi_.build_menu ();
173174}
174175
175- INT_PTR CALLBACK configuration_dialog::process_message (
176+ INT_PTR CALLBACK configuration_dialog::callback_procedure (
176177 HWND hDlg,
177178 UINT message,
178179 WPARAM wParam,
179- LPARAM /* lParam*/ )
180+ LPARAM lParam)
181+ {
182+ if (message == WM_INITDIALOG)
183+ {
184+ SetWindowLongPtr (hDlg, GWLP_USERDATA, lParam);
185+ }
186+
187+ auto dialog (reinterpret_cast <configuration_dialog*>(GetWindowLongPtr (hDlg, GWLP_USERDATA)));
188+
189+ return dialog->process_message (hDlg, message, wParam);
190+ }
191+
192+
193+ INT_PTR configuration_dialog::process_message (
194+ HWND hDlg,
195+ UINT message,
196+ WPARAM wParam)
180197{
181198 switch (message)
182199 {
183200 case WM_CLOSE:
184- gMultiPakInterface .save_configuration ();
201+ mpi_ .save_configuration ();
185202 DestroyWindow (hDlg);
186- gConfigurationDialog . dialog_handle_ = nullptr ;
187- gConfigurationDialog . parent_handle_ = nullptr ;
203+ dialog_handle_ = nullptr ;
204+ parent_handle_ = nullptr ;
188205 return TRUE ;
189206
190207 case WM_INITDIALOG:
191- gConfigurationDialog . dialog_handle_ = hDlg;
192- gConfigurationDialog . parent_handle_ = GetParent (hDlg);
208+ dialog_handle_ = hDlg;
209+ parent_handle_ = GetParent (hDlg);
193210 CenterDialog (hDlg);
194211 for (int slot = 0 ; slot < NUMSLOTS; slot++)
195212 {
196- gConfigurationDialog . update_slot_details (slot);
213+ update_slot_details (slot);
197214 }
198215
199- gConfigurationDialog . set_selected_slot (gMultiPakInterface .selected_switch_slot ());
216+ set_selected_slot (mpi_ .selected_switch_slot ());
200217 return TRUE ;
201218
202219 case WM_COMMAND:
203220 switch (LOWORD (wParam))
204221 {
205222 case IDC_SELECT1:
206- gConfigurationDialog . set_selected_slot (0 );
223+ set_selected_slot (0 );
207224 return TRUE ;
208225 case IDC_SELECT2:
209- gConfigurationDialog . set_selected_slot (1 );
226+ set_selected_slot (1 );
210227 return TRUE ;
211228 case IDC_SELECT3:
212- gConfigurationDialog . set_selected_slot (2 );
229+ set_selected_slot (2 );
213230 return TRUE ;
214231 case IDC_SELECT4:
215- gConfigurationDialog . set_selected_slot (3 );
232+ set_selected_slot (3 );
216233 return TRUE ;
217234 case IDC_INSERT1:
218- gConfigurationDialog . eject_or_select_new_cartridge (0 );
235+ eject_or_select_new_cartridge (0 );
219236 return TRUE ;
220237 case IDC_INSERT2:
221- gConfigurationDialog . eject_or_select_new_cartridge (1 );
238+ eject_or_select_new_cartridge (1 );
222239 return TRUE ;
223240 case IDC_INSERT3:
224- gConfigurationDialog . eject_or_select_new_cartridge (2 );
241+ eject_or_select_new_cartridge (2 );
225242 return TRUE ;
226243 case IDC_INSERT4:
227- gConfigurationDialog . eject_or_select_new_cartridge (3 );
244+ eject_or_select_new_cartridge (3 );
228245 return TRUE ;
229246 } // End switch LOWORD
230247 break ;
0 commit comments