if (cmd) {
if (topic) { char *cmd = dupprintf("JI(`',`%s')", topic);
static int CALLBACK KeyListProc(HWND hwnd, UINT msg,				WPARAM wParam, LPARAM lParam){    struct RSAKey *rkey;    struct ssh2_userkey *skey;    switch (msg) {      case WM_INITDIALOG:	/*	 * Centre the window.	 */	{			       /* centre the window */	    RECT rs, rd;	    HWND hw;	    hw = GetDesktopWindow();	    if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))		MoveWindow(hwnd,			   (rs.right + rs.left + rd.left - rd.right) / 2,			   (rs.bottom + rs.top + rd.top - rd.bottom) / 2,			   rd.right - rd.left, rd.bottom - rd.top, TRUE);	}        if (help_path)            SetWindowLong(hwnd, GWL_EXSTYLE,                          GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);        else {            HWND item = GetDlgItem(hwnd, 103);   /* the Help button */            if (item)                DestroyWindow(item);        }        requested_help = FALSE;	keylist = hwnd;	{	    static int tabs[] = { 35, 60, 210 };	    SendDlgItemMessage(hwnd, 100, LB_SETTABSTOPS,			       sizeof(tabs) / sizeof(*tabs),			       (LPARAM) tabs);	}	keylist_update();	return 0;      case WM_COMMAND:	switch (LOWORD(wParam)) {	  case IDOK:	  case IDCANCEL:	    keylist = NULL;	    DestroyWindow(hwnd);	    return 0;	  case 101:		       /* add key */	    if (HIWORD(wParam) == BN_CLICKED ||		HIWORD(wParam) == BN_DOUBLECLICKED) {		if (passphrase_box) {		    MessageBeep(MB_ICONERROR);		    SetForegroundWindow(passphrase_box);		    break;		}		prompt_add_keyfile();	    }	    return 0;	  case 102:		       /* remove key */	    if (HIWORD(wParam) == BN_CLICKED ||		HIWORD(wParam) == BN_DOUBLECLICKED) {		int i;		int rCount, sCount;		int *selectedArray;				/* our counter within the array of selected items */		int itemNum;				/* get the number of items selected in the list */		int numSelected = 			SendDlgItemMessage(hwnd, 100, LB_GETSELCOUNT, 0, 0);				/* none selected? that was silly */		if (numSelected == 0) {		    MessageBeep(0);		    break;		}		/* get item indices in an array */		selectedArray = snewn(numSelected, int);		SendDlgItemMessage(hwnd, 100, LB_GETSELITEMS,				numSelected, (WPARAM)selectedArray);				itemNum = numSelected - 1;		rCount = count234(rsakeys);		sCount = count234(ssh2keys);				/* go through the non-rsakeys until we've covered them all, 		 * and/or we're out of selected items to check. note that		 * we go *backwards*, to avoid complications from deleting		 * things hence altering the offset of subsequent items		 */	    for (i = sCount - 1; (itemNum >= 0) && (i >= 0); i--) {			skey = index234(ssh2keys, i);						if (selectedArray[itemNum] == rCount + i) {				del234(ssh2keys, skey);				skey->alg->freekey(skey->data);				sfree(skey);			   	itemNum--; 			}		}				/* do the same for the rsa keys */		for (i = rCount - 1; (itemNum >= 0) && (i >= 0); i--) {			rkey = index234(rsakeys, i);			if(selectedArray[itemNum] == i) {				del234(rsakeys, rkey);				freersakey(rkey);				sfree(rkey);				itemNum--;			}		}		sfree(selectedArray); 		keylist_update();	    }	    return 0;	  case 103:		       /* help */            if (HIWORD(wParam) == BN_CLICKED ||                HIWORD(wParam) == BN_DOUBLECLICKED) {                if (help_path) {                    WinHelp(main_hwnd, help_path, HELP_COMMAND,                            (DWORD)"JI(`',`pageant.general')");                    requested_help = TRUE;                }            }	    return 0;	}	return 0;      case WM_HELP:        if (help_path) {            int id = ((LPHELPINFO)lParam)->iCtrlId;            char *cmd = NULL;            switch (id) {              case 100: cmd = "JI(`',`pageant.keylist')"; break;              case 101: cmd = "JI(`',`pageant.addkey')"; break;              case 102: cmd = "JI(`',`pageant.remkey')"; break;            }            if (cmd) {                WinHelp(main_hwnd, help_path, HELP_COMMAND, (DWORD)cmd);                requested_help = TRUE;            } else {                MessageBeep(0);            }        }        break;      case WM_CLOSE:	keylist = NULL;	DestroyWindow(hwnd);	return 0;    }    return 0;}