X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwgamelist.c;h=5fa191c71a6f69545edea0e34f6d82f15f3d2aee;hb=2380bd9a886c088ba6040d99932c20cdf080fbbb;hp=34339d49c6f7f561ae4ef289af8cde86e31ce873;hpb=3076655d51195e09429c2abde2763e917d3a67a9;p=xboard.git diff --git a/winboard/wgamelist.c b/winboard/wgamelist.c index 34339d4..5fa191c 100644 --- a/winboard/wgamelist.c +++ b/winboard/wgamelist.c @@ -20,7 +20,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * ------------------------------------------------------------------------ */ - #include "config.h" #include /* required for all Windows applications */ @@ -37,6 +36,8 @@ #include "frontend.h" #include "backend.h" +#include "wsnap.h" + /* Module globals */ HWND gameListDialog = NULL; BOOLEAN gameListUp = FALSE; @@ -206,6 +207,7 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) static BOOL filterHasFocus = FALSE; int count; struct GameListStats stats; + static SnapData sd; switch (message) { case WM_INITDIALOG: @@ -269,6 +271,18 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) sizeY = newSizeY; break; + case WM_ENTERSIZEMOVE: + return OnEnterSizeMove( &sd, hDlg, wParam, lParam ); + + case WM_SIZING: + return OnSizing( &sd, hDlg, wParam, lParam ); + + case WM_MOVING: + return OnMoving( &sd, hDlg, wParam, lParam ); + + case WM_EXITSIZEMOVE: + return OnExitSizeMove( &sd, hDlg, wParam, lParam ); + case WM_GETMINMAXINFO: /* Prevent resizing window too small */ mmi = (MINMAXINFO *) lParam; @@ -469,3 +483,56 @@ VOID ShowGameListProc() } } } + +HGLOBAL ExportGameListAsText() +{ + HGLOBAL result = NULL; + LPVOID lpMem = NULL; + ListGame * lg = (ListGame *) gameList.head; + int nItem; + DWORD dwLen = 0; + + if( ! gameFileName || ((ListGame *) gameList.tailPred)->number <= 0 ) { + DisplayError("Game list not loaded or empty", 0); + return NULL; + } + + /* Get list size */ + for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){ + char * st = GameListLineFull(lg->number, &lg->gameInfo); + + dwLen += strlen(st) + 2; /* Add extra characters for "\r\n" */ + + free(st); + lg = (ListGame *) lg->node.succ; + } + + /* Allocate memory for the list */ + result = GlobalAlloc(GHND, dwLen+1 ); + + if( result != NULL ) { + lpMem = GlobalLock(result); + } + + /* Copy the list into the global memory block */ + if( lpMem != NULL ) { + char * dst = (char *) lpMem; + size_t len; + + lg = (ListGame *) gameList.head; + + for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){ + char * st = GameListLineFull(lg->number, &lg->gameInfo); + + len = sprintf( dst, "%s\r\n", st ); + dst += len; + + free(st); + lg = (ListGame *) lg->node.succ; + } + + GlobalUnlock( result ); + } + + return result; +}