/* * StatsListChangeStat: Redisplay current statistic, whose value has changed. * Requires that s is a list type stat in the current group. */ void StatsListChangeStat(Statistic *s) { int index, top; if (s->num < 0 || s->num > ListBox_GetCount(hList)) { debug(("StatListChangeList got illegal stat #%d\n", (int) s->num)); return; } top = ListBox_GetTopIndex(hList); index = StatListFindItem(s->num); if (index == -1) { debug(("StatListChangeList got illegal stat #%d\n", (int) s->num)); return; } WindowBeginUpdate(hList); ListBox_DeleteString(hList, index); index = ListBox_AddString(hList, LookupNameRsc(s->name_res)); ListBox_SetItemData(hList, index, s); ListBox_SetTopIndex(hList, top); WindowEndUpdate(hList); }
LOCAL void Select_OnMouseMove(HWND hWindow, int x, int y, UINT keyFlags) /***********************************************************************/ { RECT rect; LPLISTBOXDATA lpData = ListBox_GetData(hWindow); if (!lpData) return; // if we are above or below the list box, then we are scrolling it, and // we shouldn't be drawing here GetClientRect(hWindow, &rect); // see if we are outside the listbox if ( y < rect.top) y = rect.top; else if (y >= rect.bottom) y = rect.bottom - 1; // new position changes half way thru items int iSelect = y / lpData->iItemHeight; // add top index to get a real index iSelect += ListBox_GetTopIndex(hWindow); SelectItems(hWindow, iSelect); UpdateWindow(hWindow); }
/* * StatsListVScroll: User did something with stats list scroll bar. */ void StatsListVScroll(HWND hwnd, HWND hwndCtl, UINT code, int pos) { int old_top; // Current top row index int new_top; // New top row index int num_items; old_top = ListBox_GetTopIndex(hwnd); num_items = ListBox_GetCount(hwnd); switch (code) { case SB_LINEUP: new_top = old_top - 1; break; case SB_LINEDOWN: new_top = old_top + 1; break; case SB_PAGEUP: new_top = old_top - num_visible; break; case SB_PAGEDOWN: new_top = old_top + num_visible; break; case SB_THUMBPOSITION: new_top = pos; break; case SB_THUMBTRACK: new_top = pos; break; case SB_BOTTOM: new_top = num_items - num_visible; break; case SB_TOP: new_top = 0; break; default: // Pointless "SB_ENDSCROLL" added recently return; } new_top = max(new_top, 0); new_top = min(new_top, num_items - num_visible); if (new_top != old_top) { SetScrollPos(hwnd, SB_VERT, new_top, TRUE); WindowBeginUpdate(hwnd); ListBox_SetTopIndex(hwnd, new_top); WindowEndUpdate(hwnd); } }
LOCAL void DragEnd(HWND hWindow) /***********************************************************************/ { // get the listbox data pointer, if we don't have one, get out LPLISTBOXDATA lpData = ListBox_GetData(hWindow); if (!lpData) return; // see if we ever started dragging if (lpData->fDragging) { // if we had a cursor, reset it if (lpData->hCursor) SetCursor(lpData->hOldCursor); // do the move if we successfully dragged if (lpData->fSuccess) { int nItem, iTopItem; TCHAR szString[256]; // save the top index, so we can reset it iTopItem = ListBox_GetTopIndex(hWindow); // turn of painting while working with list SetWindowRedraw(hWindow, FALSE); // save text of item ListBox_GetText(hWindow, lpData->iOldPos, szString); // delete the item ListBox_DeleteString(hWindow, lpData->iOldPos); // adjust index because of DeleteString int iNewPos = lpData->iNewPos; if (iNewPos > lpData->iOldPos) iNewPos--; // add the new string at the right spot nItem = ListBox_InsertString(hWindow, iNewPos, szString); // select the item we moved DWORD dwStyle = GetWindowLong(hWindow, GWL_STYLE); if (dwStyle & (LBS_MULTIPLESEL, LBS_EXTENDEDSEL)) ListBox_SetSel(hWindow, TRUE, nItem); else ListBox_SetCurSel(hWindow, nItem); // reset the top index ListBox_SetTopIndex(hWindow, iTopItem); // turn drawing back on SetWindowRedraw(hWindow, TRUE); // inform the dialog of the move FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow), hWindow, LBN_MOVEITEM, SendMessage); } } // turn off dragging lpData->fDragging = FALSE; KillTimer(hWindow, lpData->idTimer); }
/* * LookDialogProc: Dialog procedure for user looking at a list of objects, and * selecting one or more. * Places a list of the objects selected ( or NULL if none ) into the global * variable LookDialogRetval. This value is valid only if the return value * of the dialog is IDOK (i.e. the user hit OK) * lParam of the WM_INITDIALOG message should be a pointer to a LookDialogStruct. */ BOOL CALLBACK LookDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam) { int index1,index2; switch (message) { HANDLE_MSG(hDlg, WM_INITDIALOG, LookInitDialog); HANDLE_MSG(hDlg, WM_VKEYTOITEM, LookVkeyToItem); HANDLE_MSG(hDlg, WM_COMMAND, LookCommand); case WM_COMPAREITEM: return ItemListCompareItem(hDlg, (const COMPAREITEMSTRUCT *) lParam); case WM_MEASUREITEM: ItemListMeasureItem(hDlg, (MEASUREITEMSTRUCT *) lParam); return TRUE; case WM_DRAWITEM: /* Cheat--if item is about to be drawn, then perhaps list has been scrolled. * Tell ourselves to realign list boxes after we've finished drawing */ PostMessage(hDlg, BK_ALIGNDLGS, 0, 0); return ItemListDrawItem(hDlg, (const DRAWITEMSTRUCT *)(lParam)); HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORDLG, DialogCtlColor); case BK_ALIGNDLGS: /* Ensure that cost list shows same index at top that item list does */ index1 = ListBox_GetTopIndex(info->hwndListBox); index2 = ListBox_GetTopIndex(info->hwndQuanList); if (index1 != index2) { ListBox_SetTopIndex(info->hwndQuanList, index1); } return TRUE; case WM_DESTROY: hwndLookDialog = NULL; return TRUE; } return FALSE; }
/* * StatsListLButton: User clicked left button on stats list. */ void StatsListLButton(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) { int index; SetFocus(hwnd); index = y / ListBox_GetItemHeight(hwnd, 0) + ListBox_GetTopIndex(hwnd); if (index >= ListBox_GetCount(hwnd)) return; ListBox_SetCurSel(hwnd, index); }
LOCAL void Drag_OnTimer(HWND hWindow, UINT id) /***********************************************************************/ { POINT pt; int iTopItem; RECT rect; LPLISTBOXDATA lpData = ListBox_GetData(hWindow); if (!lpData) return; GetCursorPos(&pt); // convert the point to client coordinates ScreenToClient(hWindow, &pt); iTopItem = ListBox_GetTopIndex(hWindow); GetClientRect(hWindow, &rect); if (pt.y < rect.top) // scroll up { if (iTopItem > 0) { iTopItem--; // undraw the bar before we scroll up DrawBar(hWindow, lpData->iCurPos); // scroll the listbox and make sure it gets repainted ListBox_SetTopIndex(hWindow, iTopItem); UpdateWindow(hWindow); // draw the new one at y = 0 lpData->iCurPos = 0; DrawBar(hWindow, lpData->iCurPos); } } else if (pt.y > rect.bottom) // scroll down { // see if there is anything to scroll if (lpData->iVisible + iTopItem < lpData->iCount) { // undraw the bar before we scroll down DrawBar(hWindow, lpData->iCurPos); // scroll down and make sure it gets repainted iTopItem++; ListBox_SetTopIndex(hWindow, iTopItem); UpdateWindow(hWindow); // always place the bar at the bottom when we scroll down lpData->iCurPos = lpData->iVisible; // draw the new one DrawBar(hWindow, lpData->iCurPos); } } }
/* * GetAmountListBox: If appropriate, display amount dialog to get amount * of object at given index in given list box. * Return True iff item should be selected (i.e. user entered valid #) */ Bool GetAmountListBox(HWND hList, int index) { object_node *obj; MEASUREITEMSTRUCT m; /* See if item requires an amount */ obj = (object_node *) ListBox_GetItemData(hList, index); if (obj == NULL || !IsNumberObj(obj->id)) return True; /* Place amount dialog just beneath selected item */ ItemListMeasureItem(hList, &m); return GetAmount(GetParent(hList), hList, obj, 0, (index - ListBox_GetTopIndex(hList) + 1) * (m.itemHeight - 1)); }
LOCAL void Select_OnTimer(HWND hWindow, UINT id) /***********************************************************************/ { POINT pt; int iTopItem; RECT rect; LPLISTBOXDATA lpData = ListBox_GetData(hWindow); if (!lpData) return; GetCursorPos(&pt); // convert the point to client coordinates ScreenToClient(hWindow, &pt); iTopItem = ListBox_GetTopIndex(hWindow); GetClientRect(hWindow, &rect); if (pt.y < rect.top) // scroll up { if (iTopItem > 0) { iTopItem--; // make sure the new top item is selected SelectItems(hWindow, iTopItem); // scroll the listbox and make sure it gets repainted ListBox_SetTopIndex(hWindow, iTopItem); UpdateWindow(hWindow); } } else if (pt.y > rect.bottom) // scroll down { // see if there is anything to scroll if (lpData->iVisible + iTopItem < lpData->iCount) { // scroll down and make sure it gets repainted iTopItem++; // make sure the new bottom item is selected SelectItems(hWindow, iTopItem+lpData->iVisible-1); // scroll the listbox and make sure it gets repainted ListBox_SetTopIndex(hWindow, iTopItem); UpdateWindow(hWindow); } } }
/* * StatsListRButton: User clicked right button on stats list. */ void StatsListRButton(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) { int index; Statistic *s; SetFocus(hwnd); index = y / ListBox_GetItemHeight(hwnd, 0) + ListBox_GetTopIndex(hwnd); if (index >= ListBox_GetCount(hwnd)) return; ListBox_SetCurSel(hwnd, index); s = (Statistic *) ListBox_GetItemData(hwnd, index); if (s == NULL) return; SetDescParams(cinfo->hMain, DESC_NONE); RequestLook(s->list.id); }
/* Give a mouse coordinate, this function returns the index of * the item under the mouse cursor. */ int FASTCALL ItemFromPoint( HWND hwndList, short x, short y ) { int cVisibleItems; int nItemHeight; int nTopIndex; /* Get the height of each item in the list box. This assumes that * each item the listbox is the same height. It will fail if the listbox * has the LBS_OWNERDRAWVARIABLE style. */ nItemHeight = ListBox_GetItemHeight( hwndList, 0 ); if( 0 == nItemHeight ) return( LB_ERR ); /* We're now sure that the cursor is in the listbox, so compute the index * of the item under the cursor. */ nTopIndex = ListBox_GetTopIndex( hwndList ); cVisibleItems = ListBox_GetCount( hwndList ) - nTopIndex; return( min( y / nItemHeight, cVisibleItems - 1 ) + nTopIndex ); }
/* * StatsListLButtonDblClk: User double-clicked left button on stats list. ajw */ void StatsListLButtonDblClk(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) { char pszLabel[256]; char pszCommand[256]; int iLabelLen; int index = y / ListBox_GetItemHeight(hwnd, 0) + ListBox_GetTopIndex(hwnd); if (index >= ListBox_GetCount(hwnd)) return; if ((GetPlayerInfo()->viewID != 0) && (GetPlayerInfo()->viewID != GetPlayerInfo()->id)) { if (!(GetPlayerInfo()->viewFlags & REMOTE_VIEW_CAST)) return; } ListBox_SetCurSel(hwnd, index); iLabelLen = ListBox_GetTextLen( hwnd, index ); if( ListBox_GetText( hwnd, index, pszLabel ) != LB_ERR ) { if( StatsGetCurrentGroup() == STATS_SPELLS ) { strcpy( pszCommand, "zaubern " ); } else if (StatsGetCurrentGroup() == STATS_SKILLS) { strcpy( pszCommand, "perform " ); return; // not implimented yet } else { return; // not going to do anything for non skills/stats } strcat( pszCommand, pszLabel ); PerformAction( A_GOTOMAIN, NULL ); // For targeting icon to appear, focus must be on main view window. PerformAction( A_TEXTCOMMAND, pszCommand ); } }
/* * StatsListResize: Called when main window resized. */ void StatsListResize(list_type stats) { AREA stats_area; int y; StatsGetArea(&stats_area); y = StatsGetButtonBorder(); MoveWindow(hList, 0, y, stats_area.cx, stats_area.cy - y, TRUE); // Hide scrollbar if not needed num_visible = (stats_area.cy - y) / max(ListBox_GetItemHeight(hList, 0), 1); if (num_visible >= ListBox_GetCount(hList)) SetScrollRange(hList, SB_VERT, 0, 0, TRUE); else { SetScrollRange(hList, SB_VERT, 0, ListBox_GetCount(hList) - num_visible, TRUE); SetScrollPos(hList, SB_VERT, ListBox_GetTopIndex(hList), TRUE); } if( StatsGetCurrentGroup() != STATS_INVENTORY ) // ajw ShowWindow(hList, SW_NORMAL); }
LOCAL void Drag_OnLButtonUp(HWND hWindow, int x, int y, UINT keyFlags) /***********************************************************************/ { int iTopItem; // End of Drag LPLISTBOXDATA lpData = ListBox_GetData(hWindow); if (!lpData) return; iTopItem = ListBox_GetTopIndex(hWindow); if (lpData->fDragging) { // undraw the bar DrawBar(hWindow, lpData->iCurPos); lpData->iNewPos = lpData->iCurPos + iTopItem; // the old position can't equal the new one if (lpData->iNewPos != lpData->iOldPos) lpData->fSuccess = TRUE; } // turn off the mouse capture ReleaseCapture(); lpData->fCapture = FALSE; }
LOCAL void Drag_OnMouseMove(HWND hWindow, int x, int y, UINT keyFlags) /***********************************************************************/ { RECT rect; LPLISTBOXDATA lpData = ListBox_GetData(hWindow); if (!lpData) return; if (!lpData->fDragging) { // Check if the user has moved out of the Drag rect. // in the vertical direction. This indicates that // the drag has started. if ((y > lpData->rDragCheck.bottom) || (y < lpData->rDragCheck.top)) { if (lpData->hCursor) lpData->hOldCursor = SetCursor(lpData->hCursor); lpData->fDragging = TRUE; // Drag has started } } if (lpData->fDragging) { if (lpData->hCursor) SetCursor(lpData->hCursor); // if we are above or below the list box, then we are scrolling it, and // we shouldn't be drawing here GetClientRect(hWindow, &rect); // see if we are outside the listbox if ( y < rect.top) { // see if it's possible to scroll up int iTopItem = ListBox_GetTopIndex(hWindow); // if it's not possible, enable a new position to be set if (iTopItem == 0) y = rect.top; } else if (y > rect.bottom) { // see if it's possible to scroll down int iTopItem = ListBox_GetTopIndex(hWindow); // if it's not possible, enable a new position to be set if ((lpData->iVisible + iTopItem) >= lpData->iCount) y = rect.bottom; } if ((y >= rect.top) && (y <= rect.bottom)) { // new position changes half way thru items int iNewPos = (y + (lpData->iItemHeight/2)) / lpData->iItemHeight; if (iNewPos < 0) iNewPos = 0; // can never be greater than 1 more the last item if (iNewPos > lpData->iCount) iNewPos = lpData->iCount; // if it is a new item // and we are not past the end in a listbox with scrollbars if ( (lpData->iCurPos != iNewPos) && ( (iNewPos < lpData->iCount + 1) || (lpData->iVisible >= lpData->iCount) ) ) { if (lpData->iCurPos != -1) { // erase the old one DrawBar(hWindow, lpData->iCurPos); } lpData->iCurPos = iNewPos; DrawBar(hWindow, lpData->iCurPos); } } } }
VOID ViewNoises_OnCommand( HWND hwnd, INT id, HWND hwndCtrl, UINT codeNotify ) { INT i, j; HWND hwndList; LRESULT lResult; switch(id) { case IDC_NOISE_LIST: if (codeNotify == LBN_SELCHANGE) { ViewNoises_NoiseChanged(hwnd); } break; case IDC_NOISE_NEW: i = po->nNoises; if (i == MAX_NOISES) { MsgBox( hwnd, MB_ICONEXCLAMATION, "The limit of %d noises has been reached.", MAX_NOISES ); break; } _fmemset(szNewNoiseName, 0, sizeof(szNewNoiseName)); wNewFlags = 0; nNewSoundIndex = -1; dNewRadius = 1000.0; dNewHeight = 3000.0; nNewDelay = 0; if (EditNoiseDialog(hwnd) == IDCANCEL) { break; } hwndList = GetDlgItem(hwnd, IDC_NOISE_LIST); ListBox_AddString(hwndList, szNewNoiseName); _fmemset(&po->pNoiseData[i], 0, sizeof(NOISE_DATA)); _fstrcpy(po->pNoiseData[i].noise_name, szNewNoiseName); po->pNoiseData[i].flags = wNewFlags; po->pNoiseData[i].sound_index = nNewSoundIndex; po->pNoiseData[i].radius = (float)dNewRadius; po->pNoiseData[i].height = (float)dNewHeight; po->pNoiseData[i].delay = nNewDelay; ++po->nNoises; ListBox_SetCurSel(hwndList, i); ViewNoises_NoiseChanged(hwnd); bChange = TRUE; break; case IDC_NOISE_DELETE: hwndList = GetDlgItem(hwnd, IDC_NOISE_LIST); lResult = ListBox_GetCurSel(hwndList); if (lResult >= 0 && lResult < po->nNoises) { i = (INT)lResult; Object_DeleteNoise(po, i); ListBox_DeleteString(hwndList, i); if (i == 0) ListBox_SetCurSel(hwndList, 0); else ListBox_SetCurSel(hwndList, i - 1); ViewNoises_NoiseChanged(hwnd); bChange = TRUE; } break; case IDC_NOISE_EDIT: hwndList = GetDlgItem(hwnd, IDC_NOISE_LIST); lResult = ListBox_GetCurSel(hwndList); if (lResult >= 0 && lResult < po->nNoises) { i = (INT)lResult; _fstrcpy(szNewNoiseName, po->pNoiseData[i].noise_name); wNewFlags = po->pNoiseData[i].flags; nNewSoundIndex = po->pNoiseData[i].sound_index; dNewRadius = (double)po->pNoiseData[i].radius; dNewHeight = (double)po->pNoiseData[i].height; nNewDelay = po->pNoiseData[i].delay; if (EditNoiseDialog(hwnd) == IDCANCEL) { break; } if (!szNewNoiseName[0]) { MsgBox( hwnd, MB_ICONEXCLAMATION, "The noise must be given a name." ); break; } _fmemset(&po->pNoiseData[i], 0, sizeof(NOISE_DATA)); _fstrcpy(po->pNoiseData[i].noise_name, szNewNoiseName); po->pNoiseData[i].flags = wNewFlags; po->pNoiseData[i].sound_index = nNewSoundIndex; po->pNoiseData[i].radius = (float)dNewRadius; po->pNoiseData[i].height = (float)dNewHeight; po->pNoiseData[i].delay = nNewDelay; j = ListBox_GetTopIndex(hwndList); ListBox_ResetContent(hwndList); for(i = 0; i < po->nNoises; ++i) { ListBox_AddString(hwndList, po->pNoiseData[i].noise_name); } ListBox_SetTopIndex(hwndList, j); ListBox_SetCurSel(hwndList, (INT)lResult); ViewNoises_NoiseChanged(hwnd); bChange = TRUE; } break; case IDOK: case IDCANCEL: if ( hPalCommon ) { DeleteObject( hPalCommon ); hPalCommon = NULL; } EndDialog( hwnd, IDOK ); break; } } // ViewNoises_OnCommand
VOID ViewTriggers_OnCommand( HWND hwnd, INT id, HWND hwndCtrl, UINT codeNotify ) { INT i, j; HWND hwndList; LRESULT lResult; switch(id) { case IDC_TRIGGER_LIST: if ( codeNotify == LBN_SELCHANGE ) { ViewTriggers_TriggerChanged( hwnd ); } break; case IDC_TRIGGER_NEW: i = pLevel->nTriggers; if (i == MAX_TRIGGERS) { MsgBox( hwnd, MB_ICONEXCLAMATION, "The limit of %d triggers has been reached.", MAX_TRIGGERS ); break; } _fmemset(szNewTriggerName, 0, sizeof(szNewTriggerName)); dNewRadius = 1000.0; dNewHeight = 3000.0; nNewItemType = -1; nNewSoundIndex = -1; wNewFlags = TF_USER_TRIGGER; if (EditTriggerDialog(hwnd) == IDCANCEL) { break; } hwndList = GetDlgItem(hwnd, IDC_TRIGGER_LIST); ListBox_AddString(hwndList, szNewTriggerName); _fmemset(&pLevel->pTriggerData[i], 0, sizeof(TRIGGER)); _fstrcpy(pLevel->pTriggerData[i].trigger_name, szNewTriggerName); pLevel->pTriggerData[i].radius = (float)dNewRadius; pLevel->pTriggerData[i].height = (float)dNewHeight; pLevel->pTriggerData[i].flags = wNewFlags; pLevel->pTriggerData[i].item_type = nNewItemType; pLevel->pTriggerData[i].sound_index = nNewSoundIndex; ++pLevel->nTriggers; ListBox_SetCurSel(hwndList, i); ViewTriggers_TriggerChanged(hwnd); bChange = TRUE; break; case IDC_TRIGGER_DELETE: hwndList = GetDlgItem( hwnd, IDC_TRIGGER_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < pLevel->nTriggers ) { i = (INT)lResult; DeleteTrigger( pLevel, i ); ListBox_DeleteString( hwndList, i ); if ( i == 0 ) ListBox_SetCurSel( hwndList, 0 ); else ListBox_SetCurSel( hwndList, i - 1 ); ViewTriggers_TriggerChanged( hwnd ); bChange = TRUE; } break; case IDC_TRIGGER_EDIT: hwndList = GetDlgItem( hwnd, IDC_TRIGGER_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < pLevel->nTriggers ) { i = (INT)lResult; _fstrcpy( szNewTriggerName, pLevel->pTriggerData[i].trigger_name ); dNewRadius = (double)pLevel->pTriggerData[i].radius; dNewHeight = (double)pLevel->pTriggerData[i].height; wNewFlags = pLevel->pTriggerData[i].flags; nNewItemType = pLevel->pTriggerData[i].item_type; nNewSoundIndex = pLevel->pTriggerData[i].sound_index; if ( EditTriggerDialog( hwnd ) == IDCANCEL ) { break; } if ( !szNewTriggerName[0] ) { MsgBox( hwnd, MB_ICONEXCLAMATION, "The trigger must be given a name." ); break; } _fmemset( &pLevel->pTriggerData[i], 0, sizeof(TRIGGER) ); _fstrcpy( pLevel->pTriggerData[i].trigger_name, szNewTriggerName ); pLevel->pTriggerData[i].radius = (float)dNewRadius; pLevel->pTriggerData[i].height = (float)dNewHeight; pLevel->pTriggerData[i].flags = wNewFlags; pLevel->pTriggerData[i].item_type = nNewItemType; pLevel->pTriggerData[i].sound_index = nNewSoundIndex; j = ListBox_GetTopIndex(hwndList); ListBox_ResetContent(hwndList); for( i = 0; i < pLevel->nTriggers; ++i ) { ListBox_AddString( hwndList, pLevel->pTriggerData[i].trigger_name ); } ListBox_SetTopIndex( hwndList, j ); ListBox_SetCurSel( hwndList, (INT)lResult ); ViewTriggers_TriggerChanged( hwnd ); bChange = TRUE; } break; case IDOK: case IDCANCEL: if ( hPalCommon ) { DeleteObject( hPalCommon ); hPalCommon = NULL; } EndDialog( hwnd, IDOK ); break; } } // ViewTriggers_OnCommand
VOID ViewItems_OnCommand( HWND hwnd, INT id, HWND hwndCtrl, UINT codeNotify ) { INT i, j, n; CHAR szBuf[128]; HWND hwndList; LRESULT lResult; switch(id) { case IDC_ITEM_LIST: if ( codeNotify == LBN_SELCHANGE ) { ViewItems_ItemChanged( hwnd ); } break; case IDC_ITEM_RESOURCES: if ( codeNotify == LBN_SELCHANGE ) { lResult = ListBox_GetCurSel( hwndCtrl ); if ( lResult != LB_ERR ) { ListBox_GetText( hwndCtrl, lResult, szBuf ); for( j = 0; j < po->nBitmaps; ++j ) { if ( !_fstricmp( szBuf, po->pBitmapData[j].bitmap_name ) ) { break; } } if ( j < po->nBitmaps ) { PreviewBitmap( hwnd, IDC_ITEM_BITMAP_PREVIEW, IDC_ITEM_BITMAP_SIZE, &po->pBitmapData[j], po->pPalette ); } else { PreviewBitmap( hwnd, IDC_ITEM_BITMAP_PREVIEW, IDC_ITEM_BITMAP_SIZE, NULL, NULL ); } } } break; case IDC_ITEM_PIXEL_SIZE: if ( codeNotify == EN_CHANGE ) { lResult = ListBox_GetCurSel( GetDlgItem( hwnd, IDC_ITEM_LIST ) ); if ( lResult >= 0 && lResult < po->nItems ) { i = (INT)lResult; SendMessage( hwndCtrl, WM_GETTEXT, (WPARAM)sizeof(szBuf), (LPARAM)((LPSTR)szBuf) ); po->pItemData[i].pixel_size = (float)atof( szBuf ); bChange = TRUE; } } break; case IDC_ITEM_NEW: i = po->nItems; if (i == MAX_ITEMS) { MsgBox( hwnd, MB_ICONEXCLAMATION, "The limit of %d items has been reached.", MAX_ITEMS ); break; } _fmemset( szNewItemName, 0, sizeof(szNewItemName) ); _fmemset( nNewIndex, 0, sizeof(nNewIndex) ); nNewItemType = -1; dNewPixelSize = 15.62; for(j = 0; j < MAX_ELEMENTS; ++j) { nNewIndex[j] = -1; } if (EditItemDialog(hwnd) == IDCANCEL) { break; } hwndList = GetDlgItem(hwnd, IDC_ITEM_LIST); ListBox_AddString(hwndList, szNewItemName); _fmemset(&po->pItemData[i], 0, sizeof(ITEM_DATA)); _fstrcpy(po->pItemData[i].item_name, szNewItemName); po->pItemData[i].pixel_size = (float)dNewPixelSize; po->pItemData[i].item_type = nNewItemType; n = GetNumItemElements(nNewItemType); for(j = 0; j < n; ++j) { po->pItemData[i].index[j] = nNewIndex[j]; } ++po->nItems; ListBox_SetCurSel(hwndList, i); ViewItems_ItemChanged(hwnd); bChange = TRUE; break; case IDC_ITEM_DELETE: hwndList = GetDlgItem( hwnd, IDC_ITEM_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < po->nItems ) { i = (INT)lResult; Object_DeleteItem( po, i ); ListBox_DeleteString( hwndList, i ); if ( i == 0 ) ListBox_SetCurSel( hwndList, 0 ); else ListBox_SetCurSel( hwndList, i - 1 ); ViewItems_ItemChanged( hwnd ); bChange = TRUE; } break; case IDC_ITEM_EDIT: hwndList = GetDlgItem( hwnd, IDC_ITEM_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < po->nItems ) { i = (INT)lResult; _fstrcpy( szNewItemName, po->pItemData[i].item_name ); dNewPixelSize = (double)po->pItemData[i].pixel_size; nNewItemType = po->pItemData[i].item_type; n = GetNumItemElements( nNewItemType ); for( j = 0; j < n; ++j ) { nNewIndex[j] = po->pItemData[i].index[j]; } if ( EditItemDialog( hwnd ) == IDCANCEL ) { break; } if ( !szNewItemName[0] ) { MsgBox( hwnd, MB_ICONEXCLAMATION, "The item must be given a name." ); break; } _fmemset( &po->pItemData[i], 0, sizeof(ITEM_DATA) ); _fstrcpy( po->pItemData[i].item_name, szNewItemName ); po->pItemData[i].pixel_size = (float)dNewPixelSize; po->pItemData[i].item_type = nNewItemType; n = GetNumItemElements( nNewItemType ); for( j = 0; j < n; ++j ) { po->pItemData[i].index[j] = nNewIndex[j]; } j = ListBox_GetTopIndex(hwndList); ListBox_ResetContent(hwndList); for( i = 0; i < po->nItems; ++i ) { ListBox_AddString( hwndList, po->pItemData[i].item_name ); } ListBox_SetTopIndex( hwndList, j ); ListBox_SetCurSel( hwndList, (INT)lResult ); ViewItems_ItemChanged( hwnd ); bChange = TRUE; } break; case IDOK: case IDCANCEL: if ( hPalCommon ) { DeleteObject( hPalCommon ); hPalCommon = NULL; } EndDialog( hwnd, IDOK ); break; } } // ViewItems_OnCommand
/* * LookCommand: Handle WM_COMMAND messages. */ void LookCommand(HWND hDlg, int ctrl_id, HWND hwndCtl, UINT codeNotify) { int index, num_entries, i, amount, currentAmount; list_type selection; object_node *obj; char buf[MAXNAME + 1], temp[16]; switch(ctrl_id) { case IDC_ITEMFIND: if (codeNotify == EN_UPDATE) { /* Go to object in list that user has named */ Edit_GetText(info->hwndFind, buf, MAXNAME); index = ListBox_FindString(info->hwndListBox, -1, buf); if (index != LB_ERR) if (info->flags & LD_MULTIPLESEL) ListBox_SetCaretIndex(info->hwndListBox, index); else ListBox_SetCurSel(info->hwndListBox, index); } break; case IDC_ALL: /* In multiple selection box only, select all objects. If we require that * user give amounts, don't select amount objects */ num_entries = ListBox_GetCount(info->hwndListBox); ListBox_SetSel(info->hwndListBox, TRUE, -1); WindowBeginUpdate(info->hwndQuanList); // Select all for number items for (i=0; i < num_entries; i++) { info->selected[i] = True; obj = (object_node *) ListBox_GetItemData(info->hwndListBox, i); if (IsNumberObj(obj->id)) amount = obj->amount; else amount = 1; obj->temp_amount = amount; ListBox_DeleteString(info->hwndQuanList,i); sprintf(temp, "%d", amount); ListBox_InsertString(info->hwndQuanList,i,temp); ListBox_SetItemData(info->hwndQuanList,i,amount); } WindowEndUpdate(info->hwndQuanList); break; case IDC_ITEMLIST: switch (codeNotify) { case LBN_DBLCLK: /* Look at item */ index = ListBox_GetCaretIndex(info->hwndListBox); if (index != LB_ERR) { obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index); RequestLook(obj->id); SetDescParams(hDlg, DESC_NONE); ListBox_SetSel(info->hwndListBox, FALSE, index); info->selected[index] = False; } break; case LBN_SELCHANGE: #if 0 LookSelChange(hwndCtl); #else index = ListBox_GetCurSel(info->hwndListBox); obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index); WindowBeginUpdate(info->hwndQuanList); ListBox_DeleteString(info->hwndQuanList,index); if (ListBox_GetSel(info->hwndListBox,index)) { if (IsNumberObj(obj->id)) amount = obj->amount; else amount = 1; sprintf(temp, "%d", amount); } else { amount = 0; strcpy(temp," "); } ListBox_InsertString(info->hwndQuanList,index,temp); ListBox_SetItemData(info->hwndQuanList,index,amount); ListBox_SetSel(info->hwndListBox,amount > 0,index); info->selected[index] = (amount > 0); obj->temp_amount = amount; ListBox_SetSel(info->hwndQuanList,FALSE,index); WindowEndUpdate(info->hwndQuanList); #endif break; } break; case IDC_QUANLIST: if (codeNotify == LBN_SELCHANGE) { char temp[16]; index = (int)ListBox_GetCurSel(info->hwndQuanList); obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index); currentAmount = (int)ListBox_GetItemData(info->hwndQuanList, index); amount = currentAmount; if (ListBox_GetItemData(info->hwndQuanList, index) > 0) { if (IsNumberObj(obj->id)) { MEASUREITEMSTRUCT m; int startAmount = currentAmount; if (currentAmount == 0) startAmount = obj->amount; /* Place amount dialog just beneath selected item */ ItemListMeasureItem(info->hwndQuanList, &m); // Force highlight on (we are editing it) ListBox_SetSel(info->hwndListBox,TRUE,index); if(InputNumber(hDlg,info->hwndQuanList, 0,(index - ListBox_GetTopIndex(info->hwndQuanList) + 1) * (m.itemHeight - 1), &amount,startAmount,1,obj->amount)) { ListBox_DeleteString(info->hwndQuanList,index); if (amount > 0) { sprintf(temp, "%d", amount); ListBox_InsertString(info->hwndQuanList, index, temp); } else { ListBox_InsertString(info->hwndQuanList,index," "); } ListBox_SetItemData(info->hwndQuanList, index, amount); } else amount = currentAmount; // reset highlight based on quantity - off if zero, on otherwise ListBox_SetSel(info->hwndListBox, (ListBox_GetItemData(info->hwndQuanList,index) > 0), index); } else { ListBox_DeleteString(info->hwndQuanList,index); if (currentAmount == 0) { amount = 1; strcpy(temp,"1"); } else { amount = 0; strcpy(temp," "); } ListBox_InsertString(info->hwndQuanList,index,temp); ListBox_SetItemData(info->hwndQuanList,index,amount); } } ListBox_SetSel(info->hwndListBox,amount > 0,index); info->selected[index] = (amount > 0); obj->temp_amount = amount; ListBox_SetCurSel(info->hwndQuanList,-1); } break; case IDOK: /* Get user's selection(s) */ num_entries = ListBox_GetCount(info->hwndListBox); selection = NULL; for (i = 0; i < num_entries; i++) { /* If item is selected, add to selection list, else free */ obj = (object_node *) ListBox_GetItemData(info->hwndListBox, i); if (ListBox_GetSel(info->hwndListBox, i) > 0) selection = list_add_item(selection, obj); else ObjectDestroyAndFree(obj); } LookDialogRetval = selection; EndDialog(hDlg, IDOK); break; case IDCANCEL: LookListFreeContents(info->hwndListBox); LookDialogRetval = NULL; EndDialog(hDlg, IDCANCEL); break; } }
LOCAL void Select_OnKeyDown(HWND hWindow, UINT vk, BOOL fDown, int cRepeat, UINT flags) /***********************************************************************/ { int iCaretIndex, iTopItem, nItems; // get the listbox data pointer LPLISTBOXDATA lpData = ListBox_GetData(hWindow); if (!lpData) { FORWARD_WM_KEYDOWN(hWindow, vk, cRepeat, flags, ListBox_CallWindowProc); } else if (vk == VK_UP) { iTopItem = ListBox_GetTopIndex(hWindow); iCaretIndex = ListBox_GetCaretIndex(hWindow); --iCaretIndex; if (iCaretIndex < 0) return; // make sure the new top item is selected SelectItems(hWindow, iCaretIndex); // scroll the listbox and make sure it gets repainted if (iCaretIndex < iTopItem) ListBox_SetTopIndex(hWindow, iCaretIndex); UpdateWindow(hWindow); FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow), hWindow, LBN_SELCHANGE, SendMessage); } else if (vk == VK_DOWN) { RECT rect; int iItemHeight, iVisible; iTopItem = ListBox_GetTopIndex(hWindow); iCaretIndex = ListBox_GetCaretIndex(hWindow); ++iCaretIndex; nItems = ListBox_GetCount(hWindow); if (iCaretIndex >= nItems) return; // make sure the new top item is selected SelectItems(hWindow, iCaretIndex); // get the client area GetClientRect(hWindow, &rect); // the height of each item iItemHeight = ListBox_GetItemHeight(hWindow, 0); // the number of visible items iVisible = (rect.bottom - rect.top) / iItemHeight; // see if there is anything to scroll if (iCaretIndex >= (iTopItem+iVisible)) { ++iTopItem; ListBox_SetTopIndex(hWindow, iTopItem); } UpdateWindow(hWindow); FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow), hWindow, LBN_SELCHANGE, SendMessage); } // ignore all other keystrokes }
/* * StatListKey: User pressed a key on stat list box. * Return True iff key should NOT be passed on to Windows for default processing. */ Bool StatListKey(HWND hwnd, UINT key, Bool fDown, int cRepeat, UINT flags) { Bool held_down = (flags & 0x4000) ? True : False; /* Is key being held down? */ int old_top, new_top, old_pos, new_pos; UserDidSomething(); old_pos = ListBox_GetCurSel(hwnd); new_top = old_top = ListBox_GetTopIndex(hwnd); // Handle keys manually to prevent Windows from copying list box background, which would // cause background to flash when it's redrawn in the correct location. switch (key) { case VK_UP: WindowBeginUpdate(hwnd); new_pos = max(0, old_pos - 1); if (new_pos < old_top) new_top = new_pos; ListBox_SetTopIndex(hwnd, new_top); ListBox_SetCurSel(hwnd, new_pos); SetScrollPos(hwnd, SB_VERT, new_top, TRUE); WindowEndUpdate(hwnd); return True; case VK_DOWN: WindowBeginUpdate(hwnd); new_pos = min(old_pos + 1, ListBox_GetCount(hwnd) - 1); if (new_pos > old_top + num_visible) new_top = new_pos - num_visible; ListBox_SetTopIndex(hwnd, new_top); ListBox_SetCurSel(hwnd, new_pos); SetScrollPos(hwnd, SB_VERT, new_top, TRUE); WindowEndUpdate(hwnd); return True; case VK_PRIOR: WindowBeginUpdate(hwnd); new_pos = max(0, old_pos - num_visible); new_top = new_pos; ListBox_SetTopIndex(hwnd, new_top); ListBox_SetCurSel(hwnd, new_pos); SetScrollPos(hwnd, SB_VERT, new_top, TRUE); WindowEndUpdate(hwnd); return True; case VK_NEXT: WindowBeginUpdate(hwnd); new_pos = min(old_pos + num_visible, ListBox_GetCount(hwnd) - 1); new_top = new_pos - num_visible; ListBox_SetTopIndex(hwnd, new_top); ListBox_SetCurSel(hwnd, new_pos); SetScrollPos(hwnd, SB_VERT, new_top, TRUE); WindowEndUpdate(hwnd); return True; case VK_RETURN: // ajw { int iLabelLen = ListBox_GetTextLen( hwnd, old_pos ); char* pszLabel = (char*)SafeMalloc( ( iLabelLen + 1 ) * sizeof( char ) ); if( ListBox_GetText( hwnd, old_pos, pszLabel ) != LB_ERR ) { // ajwxxx Hard-coded group number constants for spells list. There may be a var that could be used instead. char* pszCommand; if( StatsGetCurrentGroup() == STATS_SPELLS ) { pszCommand = (char*)SafeMalloc( ( iLabelLen + 6 ) * sizeof( char ) ); strcpy( pszCommand, "zaubern " ); } else { pszCommand = (char*)SafeMalloc( ( iLabelLen + 9 ) * sizeof( char ) ); strcpy( pszCommand, "perform " ); } strcat( pszCommand, pszLabel ); PerformAction( A_GOTOMAIN, NULL ); // For targeting icon to appear, focus must be on main view window. PerformAction( A_TEXTCOMMAND, pszCommand ); SafeFree( pszCommand ); } SafeFree( pszLabel ); } return True; } return StatInputKey(hwnd, key, fDown, cRepeat, flags); }
VOID ViewMarks_OnCommand( HWND hwnd, INT id, HWND hwndCtrl, UINT codeNotify ) { INT i, j; HWND hwndList; LRESULT lResult; switch(id) { case IDC_MARK_LIST: if ( codeNotify == LBN_SELCHANGE ) { lResult = ListBox_GetCurSel( hwndCtrl ); if ( lResult >= 0 && lResult < pLevel->nMarks ) { pLevel->nLastMark = (INT)lResult; } } break; case IDC_NEW_MARK: i = pLevel->nMarks; if (i == MAX_MARKS) { MsgBox( hwnd, MB_ICONEXCLAMATION, "The limit of %d marks has been reached.", MAX_MARKS ); break; } szMarkName[0] = '\0'; wsprintf(szMarkX, "%ld", pLevel->view_x); wsprintf(szMarkY, "%ld", pLevel->view_y); wsprintf(szMarkZ, "%ld", pLevel->view_z); DoubleToString(szMarkRotation, pLevel->view_rotation * 180.0 / PI, 2); DoubleToString(szMarkElevation, pLevel->view_elevation * 180.0 / PI, 2); if (EditMarkDialog(hwnd) == IDCANCEL) { break; } if (!szMarkName[0]) { break; } hwndList = GetDlgItem(hwnd, IDC_MARK_LIST); ListBox_AddString(hwndList, szMarkName); _fstrcpy(pLevel->pMarkData[i].mark_name, szMarkName); pLevel->pMarkData[i].x = atol(szMarkX); pLevel->pMarkData[i].y = atol(szMarkY); pLevel->pMarkData[i].z = atol(szMarkZ); pLevel->pMarkData[i].rotation = atof(szMarkRotation) * PI / 180.0; pLevel->pMarkData[i].elevation = atof(szMarkElevation) * PI / 180.0; ++pLevel->nMarks; ListBox_SetCurSel(hwndList, i); pLevel->nLastMark = i; bChange = TRUE; break; case IDC_DELETE_MARK: hwndList = GetDlgItem( hwnd, IDC_MARK_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < pLevel->nMarks ) { i = (INT)lResult; DeleteMark( pLevel, i ); ListBox_DeleteString( hwndList, i ); if ( i == 0 ) ListBox_SetCurSel( hwndList, 0 ); else ListBox_SetCurSel( hwndList, i - 1 ); bChange = TRUE; } break; case IDC_EDIT_MARK: hwndList = GetDlgItem( hwnd, IDC_MARK_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < pLevel->nMarks ) { i = (INT)lResult; _fstrcpy(szMarkName, pLevel->pMarkData[i].mark_name); wsprintf(szMarkX, "%ld", pLevel->pMarkData[i].x); wsprintf(szMarkY, "%ld", pLevel->pMarkData[i].y); wsprintf(szMarkZ, "%ld", pLevel->pMarkData[i].z); DoubleToString(szMarkRotation, pLevel->pMarkData[i].rotation * 180.0 / PI, 2); DoubleToString(szMarkElevation, pLevel->pMarkData[i].elevation * 180.0 / PI, 2); if ( EditMarkDialog( hwnd ) == IDCANCEL ) { break; } if ( !szMarkName[0] ) { break; } _fstrcpy( pLevel->pMarkData[i].mark_name, szMarkName ); pLevel->pMarkData[i].x = atol(szMarkX); pLevel->pMarkData[i].y = atol(szMarkY); pLevel->pMarkData[i].z = atol(szMarkZ); pLevel->pMarkData[i].rotation = atof(szMarkRotation) * PI / 180.0; pLevel->pMarkData[i].elevation = atof(szMarkElevation) * PI / 180.0; j = ListBox_GetTopIndex(hwndList); ListBox_ResetContent(hwndList); for( i = 0; i < pLevel->nMarks; ++i ) { ListBox_AddString( hwndList, pLevel->pMarkData[i].mark_name ); } ListBox_SetTopIndex( hwndList, j ); ListBox_SetCurSel( hwndList, (INT)lResult ); bChange = TRUE; } break; case IDC_GO_TO_MARK: hwndList = GetDlgItem( hwnd, IDC_MARK_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < pLevel->nMarks ) { i = (INT)lResult; pLevel->view_x = pLevel->pMarkData[i].x; pLevel->view_y = pLevel->pMarkData[i].y; pLevel->view_z = pLevel->pMarkData[i].z; pLevel->view_rotation = pLevel->pMarkData[i].rotation; pLevel->view_elevation = pLevel->pMarkData[i].elevation; Object_ViewStatusUpdate(hParent, po); Object_ViewChanged(hParent, po); bChange = TRUE; } break; case IDOK: case IDCANCEL: if ( hPalCommon ) { DeleteObject( hPalCommon ); hPalCommon = NULL; } EndDialog( hwnd, id ); break; } } // ViewMarks_OnCommand
VOID ViewSounds_OnCommand( HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify ) { INT i, j; HWND hwndList; CHAR szBuf[80]; LRESULT lResult; switch(id) { case IDC_SOUND_LIST: if ( codeNotify == LBN_SELCHANGE ) { lResult = ListBox_GetCurSel( hwndCtl ); if ( lResult >= 0 && lResult < po->nSounds ) { wsprintf( szBuf, "%ld", po->pSoundData[lResult].length ); } else { _fstrcpy( szBuf, "0" ); } Edit_SetText( GetDlgItem( hwnd, IDC_SOUND_LENGTH ), szBuf ); } else if ( codeNotify == LBN_DBLCLK ) { lResult = ListBox_GetCurSel( hwndCtl ); if ( lResult >= 0 && lResult < po->nSounds ) { PlaySound( hwnd, po, (INT)lResult ); } } break; case IDC_PLAY_SOUND: hwndList = GetDlgItem( hwnd, IDC_SOUND_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < po->nSounds ) { PlaySound( hwnd, po, (INT)lResult ); } break; case IDC_RELOAD_SOUND: hwndList = GetDlgItem( hwnd, IDC_SOUND_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < po->nSounds ) { ReloadSound( hwnd, po, (INT)lResult ); j = ListBox_GetTopIndex(hwndList); ListBox_ResetContent(hwndList); for( i = 0; i < po->nSounds; ++i ) { ListBox_AddString( hwndList, po->pSoundData[i].sound_name ); } ListBox_SetTopIndex( hwndList, j ); ListBox_SetCurSel( hwndList, (INT)lResult ); SendMessage( hwnd, WM_COMMAND, (WPARAM)IDC_SOUND_LIST, (LPARAM)(MAKELONG(hwndList,LBN_SELCHANGE)) ); bChange = TRUE; } break; case IDC_IMPORT_SOUND: if ( po->nSounds == MAX_SOUNDS ) { MsgBox( hwnd, MB_ICONEXCLAMATION, "The limit of %d sounds has been reached.", MAX_SOUNDS ); } else { if ( ImportSound( hwnd, po ) ) { i = po->nSounds - 1; hwndList = GetDlgItem( hwnd, IDC_SOUND_LIST ); ListBox_AddString( hwndList, (LPSTR)po->pSoundData[i].sound_name ); ListBox_SetCurSel( hwndList, i ); SendMessage( hwnd, WM_COMMAND, (WPARAM)IDC_SOUND_LIST, (LPARAM)(MAKELONG(hwndList,LBN_SELCHANGE)) ); bChange = TRUE; } } break; case IDC_EXPORT_SOUND: hwndList = GetDlgItem( hwnd, IDC_SOUND_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < po->nSounds ) { ExportSound( hwnd, po, (INT)lResult ); } break; case IDC_DELETE_SOUND: hwndList = GetDlgItem( hwnd, IDC_SOUND_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < po->nSounds ) { i = (INT)lResult; Object_DeleteSound(po, i); ListBox_DeleteString( hwndList, i ); if ( i == 0 ) ListBox_SetCurSel( hwndList, 0 ); else ListBox_SetCurSel( hwndList, i - 1 ); SendMessage( hwnd, WM_COMMAND, (WPARAM)IDC_SOUND_LIST, (LPARAM)(MAKELONG(hwndList,LBN_SELCHANGE)) ); bChange = TRUE; } break; case IDOK: case IDCANCEL: if ( hPalCommon ) { DeleteObject( hPalCommon ); hPalCommon = NULL; } EndDialog( hwnd, IDOK ); break; } } // ViewSounds_OnCommand