- the text snapshot function now uses the standard save file dialog box on win32

if the config interface is not wx.
This commit is contained in:
Volker Ruppert 2003-05-25 13:35:39 +00:00
parent 4ccaddc32d
commit 906ac57dc9
4 changed files with 68 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.66 2003-05-24 10:51:00 vruppert Exp $
// $Id: gui.cc,v 1.67 2003-05-25 13:35:39 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -429,7 +429,17 @@ bx_gui_c::snapshot_handler(void)
return;
}
} else {
#ifdef WIN32
int ret = SIM->ask_filename (filename, sizeof(filename),
"Save snapshot as...", "snapshot.txt",
bx_param_string_c::SAVE_FILE_DIALOG);
if (ret < 0) { // cancelled
free(text_snapshot);
return;
}
#else
strcpy (filename, "snapshot.txt");
#endif
}
FILE *fp = fopen(filename, "wb");
fwrite(text_snapshot, 1, len, fp);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: textconfig.cc,v 1.9 2003-05-21 20:33:24 vruppert Exp $
// $Id: textconfig.cc,v 1.10 2003-05-25 13:35:39 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// This is code for a text-mode configuration interfac. Note that this file
@ -665,6 +665,10 @@ int log_action_n_choices = 4 + (BX_DEBUGGER?1:0);
BxEvent *
config_interface_notify_callback (void *unused, BxEvent *event)
{
#ifdef WIN32
bx_param_filename_c *param;
int opts;
#endif
event->retcode = -1;
switch (event->type)
{
@ -672,6 +676,14 @@ config_interface_notify_callback (void *unused, BxEvent *event)
event->retcode = 0;
return event;
case BX_SYNC_EVT_ASK_PARAM:
#ifdef WIN32
param = (bx_param_filename_c*)event->u.param.param;
opts = param->get_options()->get();
if (opts & bx_param_filename_c::IS_FILENAME) {
event->retcode = AskFilename(param);
return event;
}
#endif
event->u.param.param->text_ask (stdin, stderr);
return event;
case BX_SYNC_EVT_LOG_ASK:

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32dialog.cc,v 1.1 2003-05-21 20:33:24 vruppert Exp $
// $Id: win32dialog.cc,v 1.2 2003-05-25 13:35:39 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
#ifdef WIN32
@ -68,4 +68,45 @@ void LogAskDialog(BxEvent *event)
(DLGPROC)LogAskProc, (LPARAM)event);
}
int AskFilename(bx_param_filename_c *param)
{
const PCHAR Filter = "Text files (*.txt)\0*.txt\0All files (*.*)\0*.*\0";
const PCHAR Ext = "txt";
OPENFILENAME ofn;
int ret;
char filename[MAX_PATH];
param->get(filename, MAX_PATH);
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = GetBochsWindow();
ofn.hInstance = NULL;
ofn.lpstrFilter = Filter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = filename;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = param->get_description();
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = Ext;
ofn.lCustData = 0;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
if (param->get_options()->get() & bx_param_filename_c::SAVE_FILE_DIALOG) {
ofn.Flags |= OFN_OVERWRITEPROMPT;
ret = GetSaveFileName(&ofn);
} else {
ofn.Flags |= OFN_FILEMUSTEXIST;
ret = GetOpenFileName(&ofn);
}
param->set(filename);
if (ret == 0) ret = -1;
return ret;
}
#endif // WIN32

View File

@ -1,9 +1,10 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32dialog.h,v 1.1 2003-05-21 20:33:24 vruppert Exp $
// $Id: win32dialog.h,v 1.2 2003-05-25 13:35:39 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
#ifdef WIN32
void LogAskDialog(BxEvent *event);
int AskFilename(bx_param_filename_c *param);
#endif