- // dialog_save.cpp 
-   
- #include "../common.h" 
-   
-   
- // global variables used in this module only 
- static wchar_t ofn_customfilter[256] = L""; 
- static wchar_t saveposition_pathname[MAX_PATH]; 
-   
-   
- // local prototypes 
- static void StartThread_ThisDialog (void *thread_parms); 
-   
-   
- void DialogBox_SavePosition (void) 
- { 
-    // helper function to fire up the modeless Save dialog box 
-   
-    _beginthread (StartThread_ThisDialog, 0, NULL); // fire up a new one 
-   
-    return; // return as soon as the thread is fired up 
- } 
-   
-   
- void DialogBox_SavePosition_Validated (void) 
- { 
-    // callback function called by the main game thread when the dialog box is validated 
-   
-    // remember this callback is no longer to be called 
-    is_dialogbox_saveposition_validated = false; 
-   
-    // save the requested FEN file 
-    if (!FENFile_Save (saveposition_pathname, the_board.moves[the_board.viewed_move].fen_string)) 
-    { 
-       messagebox.hWndParent = hMainWnd; 
-       wcscpy_s (messagebox.title, WCHAR_SIZEOF (messagebox.title), LOCALIZE (L"ImportantMessage")); 
-       wcscpy_s (messagebox.text, WCHAR_SIZEOF (messagebox.text), LOCALIZE (L"Error_SaveFailed")); 
-       messagebox.flags = MB_ICONWARNING | MB_OK; 
-       DialogBox_Message (&messagebox); // on error, display a modeless error message box 
-    } 
-   
-    return; // finished, FEN position has been saved 
- } 
-   
-   
- static void StartThread_ThisDialog (void *thread_parms) 
- { 
-    // this function runs in a separate thread, for that's the only way (seemingly) 
-    // to implement a non-modal Save dialog box using the Common Controls library. 
-   
-    OPENFILENAME ofn; 
-   
-    // reset and prepare the open file name structure 
-    memset (&ofn, 0, sizeof (ofn)); 
-    ofn.lStructSize = sizeof (ofn); 
-    ofn.hwndOwner = hMainWnd; 
-    ofn.lpstrFilter = LOCALIZE (L"PositionFileFilter"); 
-    ofn.lpstrDefExt = L"fen"; // default extension will be .fen 
-    ofn.nFilterIndex = 1; // first filter (list is 1-based) 
-    ofn.lpstrCustomFilter = ofn_customfilter; 
-    ofn.nMaxCustFilter = WCHAR_SIZEOF (ofn_customfilter); 
-    ofn.lpstrFile = saveposition_pathname; 
-    ofn.nMaxFile = WCHAR_SIZEOF (saveposition_pathname); 
-    ofn.Flags = OFN_ENABLESIZING | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_OVERWRITEPROMPT; 
-   
-    // display the dialog box and get the file name 
-    if (GetSaveFileName (&ofn) != 0) 
-       is_dialogbox_saveposition_validated = true; 
-   
-    return; // _endthread() implied 
- } 
-