Beispiel #1
0
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);
	  	}
	}               
}
Beispiel #2
0
LRESULT CALLBACK EventDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	HWND hctlListbox;
	
	switch (uMsg)
	{
	case WM_PLEASE_DISPLAY:
		hctlListbox = GetDlgItem(hDlg, IDC_RESULTS);
		ListBox_SetTopIndex(hctlListbox, ListBox_AddString(hctlListbox, lParam));
		break;

	case WM_CLOSE:
		DestroyWindow(hDlg);
		hDlgMain = NULL;
		break;
		
	case WM_DESTROY:
		return TRUE;
		break;
			
	HANDLE_MSG(hDlg, WM_INITDIALOG, EventDlg_OnInitDialog);
	HANDLE_MSG(hDlg, WM_COMMAND, EventDlg_OnCommand);

	default:
		return (FALSE);
	}

	return 0;
}
Beispiel #3
0
/*
 * 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);
}
Beispiel #4
0
/*
 * 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);
   }
}
Beispiel #5
0
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);    
}
Beispiel #6
0
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);
	  	}
	}
}
Beispiel #7
0
void InterfaceCheckChannels()
{
	int num_items;
	channel_buffer_node *cb;
	HWND hwndList;
	
	while (IsNewChannelText())
	{
		cb = GetChannelBuffer();
		switch (cb->channel_id)
		{
		case CHANNEL_L :
			/* show channel text in status window */
			SendDlgItemMessage(hwndMain,IDS_STATUS_WINDOW,SB_SETTEXT,0,(LPARAM)cb->buf);
			if (is_timer_pending)
				KillTimer(hwndMain,WIN_TIMER_ID);
			SetTimer(hwndMain,WIN_TIMER_ID,STATUS_CLEAR_TIME,NULL);
			
			hwndList = GetDlgItem(HWND_CHANNEL,IDC_LOG_LIST);
			break;
		case CHANNEL_E :
			hwndList = GetDlgItem(HWND_CHANNEL,IDC_ERROR_LIST);
			break;
		default:
			hwndList = GetDlgItem(HWND_CHANNEL,IDC_DEBUG_LIST);
			break;
			hwndList = NULL; 
			break;
		}

		SendMessage(hwndList,WM_SETREDRAW,FALSE,0);
		num_items = ListBox_GetCount(hwndList);
		if (num_items >= CHANNEL_INTERFACE_LINES)
			ListBox_DeleteString(hwndList,0);
		ListBox_AddString(hwndList,cb->buf);
		ListBox_SetTopIndex(hwndList,max(0,num_items-1));
		SendMessage(hwndList,WM_SETREDRAW,TRUE,0);
		
		DoneChannelBuffer();
	}
	
	UpdateWindow(GetDlgItem(HWND_CHANNEL,IDC_LOG_LIST));
	UpdateWindow(GetDlgItem(HWND_CHANNEL,IDC_ERROR_LIST));
	UpdateWindow(GetDlgItem(HWND_CHANNEL,IDC_DEBUG_LIST));
}
Beispiel #8
0
/*
 * 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;
}
Beispiel #9
0
void GetFontListAndDisplay(HWND hwnd)
{
	PeripheralFontList2  *lpFontList2;
	DWORD     dBufSize, dwResult;
	int       i;
	int       nIndex;
	HWND      fontListBox;
	HCURSOR   hOldCursor;
   DWORD     segNum;
   BOOL      bFoundOne;


	if (fontListBox = GetDlgItem(hwnd, IDC_FONTLIST))
	   {
	   ListBox_ResetContent(fontListBox);
	   }

	lpFontList2 = (PeripheralFontList2 *)
	             HP_GLOBAL_ALLOC_DLL(sizeof(PeripheralFontList2));
   if(lpFontList2 IS NULL)
      return;


	/* turn hourglass on */
	hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));

   segNum = 0;
   bFoundOne = FALSE;
   while(TRUE)
      {
   	dBufSize = sizeof(PeripheralFontList2);

   	lpFontList2->numFonts = 0;
   	lpFontList2->dwSegNum = segNum;


   	dwResult = PALGetObject(hPeripheral, 
   	                        OT_PERIPHERAL_FONT_LIST2,
	                           0, 
	                           lpFontList2, 
	                           &dBufSize);

      if(dwResult ISNT RC_SUCCESS)
         break;

      if(lpFontList2->numFonts IS 0)
         break;



		for (i = 0; i < (signed long) lpFontList2->numFonts; i++) {
			// add the font name to the font list box
			nIndex = ListBox_AddString(fontListBox,
			                           lpFontList2->fonts[i].globalName);

			// associate the font handle with this font name
			ListBox_SetItemData(fontListBox, nIndex,
			                           (DWORD)lpFontList2->fonts[i].fontHandle);

         bFoundOne = TRUE;
		   } // for...



      if(lpFontList2->numFonts ISNT MAX_FONTLIST2_CNT)
         break;

      ++segNum;
      }

	if(bFoundOne)
      {
	   ListBox_SetTopIndex(fontListBox, 0);
		ListBox_SetCurSel(fontListBox, 0);
      }
	else {
		// no fonts - disable the details and delete buttons
		EnableWindow(GetDlgItem(hDisk, IDC_FONT_DELETE), FALSE);
		EnableWindow(GetDlgItem(hDisk, IDC_FONT_DETAILS), FALSE);
	   }

   /* restore the cursor */
	SetCursor(hOldCursor);

   /* free the used memory */
   HP_GLOBAL_FREE(lpFontList2);

} // GetFontListAndDisplay
Beispiel #10
0
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
Beispiel #11
0
static INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lParam)
{
	static int oldWidth = 0;
	static int loadItem = -1;

	static enum { LOG_NONE, LOG_DEFAULT, LOG_HPP } logType = LOG_NONE;
	static HWND hwndLog = NULL;

	switch (msg) {
	case WM_INITDIALOG:
	{
		oldWidth = 0;
		HWND hwndList = GetDlgItem(hwnd, IDC_POPUP_LIST);
		for (int i = 0; i < arPopupHistory.getCount(); ++i)
			ListBox_SetItemData(hwndList, ListBox_AddString(hwndList, _T("")), 0);
		SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_HISTORY, 0));
		SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_HISTORY, 1));

		if (gbHppInstalled && PopupOptions.UseHppHistoryLog) {
			logType = LOG_HPP;
			ShowWindow(GetDlgItem(hwnd, IDC_POPUP_LIST), SW_HIDE);

			IEVIEWWINDOW ieWindow;
			ieWindow.cbSize = sizeof(IEVIEWWINDOW);
			ieWindow.iType = IEW_CREATE;
			ieWindow.dwFlags = 0;
			ieWindow.dwMode = IEWM_MUCC;
			ieWindow.parent = hwnd;
			ieWindow.x = 0;
			ieWindow.y = 0;
			ieWindow.cx = 100;
			ieWindow.cy = 100;
			CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);
			hwndLog = ieWindow.hwnd;
			ShowWindow(hwndLog, SW_SHOW);

			RECT rcLst; GetWindowRect(hwndList, &rcLst);
			POINT pt;
			pt.x = rcLst.left;
			pt.y = rcLst.top;
			ScreenToClient(hwnd, &pt);

			ieWindow.cbSize = sizeof(IEVIEWWINDOW);
			ieWindow.iType = IEW_SETPOS;
			ieWindow.parent = hwnd;
			ieWindow.hwnd = hwndLog;
			ieWindow.x = pt.x;
			ieWindow.y = pt.y;
			ieWindow.cx = rcLst.right - rcLst.left;
			ieWindow.cy = rcLst.bottom - rcLst.top;
			CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);

			IEVIEWEVENTDATA ieData;

			IEVIEWEVENT ieEvent;
			ieEvent.cbSize = sizeof(ieEvent);
			ieEvent.iType = IEE_LOG_MEM_EVENTS;
			ieEvent.dwFlags = 0;
			ieEvent.hwnd = hwndLog;
			ieEvent.eventData = &ieData;
			ieEvent.count = 1;
			ieEvent.codepage = 0;
			ieEvent.pszProto = NULL;

			for (int i = 0; i < arPopupHistory.getCount(); ++i) {
				POPUPDATA2* ppd = arPopupHistory[i];
				ieData.cbSize = sizeof(ieData);
				ieData.iType = IEED_EVENT_SYSTEM;
				ieData.dwFlags = 0;
				ieData.color = ppd->colorText;
				if (ppd->flags & PU2_UNICODE) {
					ieData.dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK;
					ieData.pszNickW = ppd->lptzTitle;
					ieData.pszTextW = ppd->lptzText;
					ieData.pszText2W = NULL;
				}
				else {
					ieData.dwFlags |= 0;
					ieData.pszNick = ppd->lpzTitle;
					ieData.pszText = ppd->lpzText;
					ieData.pszText2 = NULL;
				}
				ieData.bIsMe = FALSE;
				ieData.time = ppd->dwTimestamp;
				ieData.dwData = 0;
				ieData.next = NULL;
				CallService(MS_HPP_EG_EVENT, 0, (WPARAM)&ieEvent);
			}
		}
		else {
			logType = LOG_DEFAULT;
			hwndLog = hwndList;

			ShowWindow(hwndLog, SW_SHOW);
		}

		Utils_RestoreWindowPosition(hwnd, NULL, MODULNAME, "popupHistory_");

		if (logType == LOG_DEFAULT) {
			SendMessage(hwnd, UM_RESIZELIST, 0, 0);
			ListBox_SetTopIndex(hwndLog, arPopupHistory.getCount() - 1);
		}
	}
	return TRUE;

	case WM_MEASUREITEM:
		if (logType == LOG_DEFAULT) {
			LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
			if (lpmis->itemID == -1)
				return FALSE;
			lpmis->itemHeight = 50;
		}
		return TRUE;

	case WM_DRAWITEM:
		if (logType == LOG_DEFAULT) {
			LPDRAWITEMSTRUCT lpdis;
			lpdis = (LPDRAWITEMSTRUCT)lParam;
			if (lpdis->itemID == -1)
				return FALSE;

			HWND hwndList = GetDlgItem(hwnd, lpdis->CtlID);
			PopupWnd2 *wndPreview = (PopupWnd2 *)ListBox_GetItemData(hwndList, lpdis->itemID);
			if (!wndPreview) {
				RECT rc; GetWindowRect(hwndLog, &rc);

				if (rc.right - rc.left <= 30)
					return FALSE;

				POPUPOPTIONS customOptions = PopupOptions;
				customOptions.DynamicResize = FALSE;
				customOptions.MinimumWidth = customOptions.MaximumWidth = rc.right - rc.left - 30;

				POPUPDATA2 *ppd = arPopupHistory[lpdis->itemID];
				wndPreview = new PopupWnd2(ppd, &customOptions, true);
				wndPreview->buildMText();
				wndPreview->update();

				ListBox_SetItemData(hwndLog, lpdis->itemID, wndPreview);
				ListBox_SetItemHeight(hwndLog, lpdis->itemID, wndPreview->getSize().cy + 6);
			}

			if (wndPreview) {
				if (lpdis->itemState & ODS_SELECTED) {
					HBRUSH hbr = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
					FillRect(lpdis->hDC, &lpdis->rcItem, hbr);
					DeleteObject(hbr);
				}
				else {
					HBRUSH hbr = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
					FillRect(lpdis->hDC, &lpdis->rcItem, hbr);
					DeleteObject(hbr);
				}

				int width = wndPreview->getContent()->getWidth();
				int height = wndPreview->getContent()->getHeight();

				BLENDFUNCTION bf;
				bf.BlendOp = AC_SRC_OVER;
				bf.BlendFlags = 0;
				bf.SourceConstantAlpha = 255;
				bf.AlphaFormat = AC_SRC_ALPHA;
				AlphaBlend(lpdis->hDC, lpdis->rcItem.left + 5, lpdis->rcItem.top + 3, width, height,
					wndPreview->getContent()->getDC(),
					0, 0, width, height, bf);
			}
		}
		return TRUE;

	case WM_DELETEITEM:
		if (logType != LOG_DEFAULT) {
			DELETEITEMSTRUCT *lpdis = (DELETEITEMSTRUCT *)lParam;
			PopupWnd2 *wnd = (PopupWnd2 *)ListBox_GetItemData(lpdis->hwndItem, lpdis->itemID);
			if (wnd)
				delete wnd;
		}
		return TRUE;

	case WM_SIZE:
	{
		RECT rcLst; GetClientRect(hwnd, &rcLst);
		rcLst.left += 10;
		rcLst.top += 10;
		rcLst.right -= 10;
		rcLst.bottom -= 10;
		if (logType == LOG_HPP) {
			SetWindowPos(hwndLog, NULL,
				rcLst.left, rcLst.top, rcLst.right - rcLst.left, rcLst.bottom - rcLst.top,
				SWP_NOZORDER | SWP_DEFERERASE | SWP_SHOWWINDOW);

			IEVIEWWINDOW ieWindow;
			ieWindow.cbSize = sizeof(IEVIEWWINDOW);
			ieWindow.iType = IEW_SETPOS;
			ieWindow.parent = hwnd;
			ieWindow.hwnd = hwndLog;
			ieWindow.x = rcLst.left;
			ieWindow.y = rcLst.top;
			ieWindow.cx = rcLst.right - rcLst.left;
			ieWindow.cy = rcLst.bottom - rcLst.top;
			CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);
		}
		else if (logType == LOG_DEFAULT) {
			SetWindowPos(hwndLog, NULL,
				rcLst.left, rcLst.top, rcLst.right - rcLst.left, rcLst.bottom - rcLst.top,
				SWP_NOZORDER | SWP_DEFERERASE | SWP_SHOWWINDOW);
			if (rcLst.right - rcLst.left != oldWidth) {
				oldWidth = rcLst.right - rcLst.left;
				PostMessage(hwnd, UM_RESIZELIST, 0, 0);
			}
		}
	}
	return TRUE;

	case UM_RESIZELIST:
		if (logType == LOG_DEFAULT) {
			RECT rc;
			GetWindowRect(GetDlgItem(hwnd, IDC_POPUP_LIST), &rc);
			if (rc.right - rc.left <= 30)
				return FALSE;

			for (int i = 0; i < arPopupHistory.getCount(); ++i) {
				PopupWnd2 *wndPreview = (PopupWnd2 *)ListBox_GetItemData(hwndLog, i);
				if (wndPreview)
					delete wndPreview;

				ListBox_SetItemData(hwndLog, i, 0);
				ListBox_SetItemHeight(hwndLog, i, 50);
			}
			ScrollWindow(hwndLog, 0, 100000, NULL, NULL);
			InvalidateRect(hwndLog, NULL, TRUE);
		}
		return TRUE;

	case UM_ADDITEM:
		if (logType == LOG_HPP) {
			POPUPDATA2 *ppd = (POPUPDATA2 *)lParam;

			IEVIEWEVENTDATA ieData;

			IEVIEWEVENT ieEvent;
			ieEvent.cbSize = sizeof(ieEvent);
			ieEvent.iType = IEE_LOG_MEM_EVENTS;
			ieEvent.dwFlags = 0;
			ieEvent.hwnd = hwndLog;
			ieEvent.eventData = &ieData;
			ieEvent.count = 1;
			ieEvent.codepage = 0;
			ieEvent.pszProto = NULL;

			ieData.cbSize = sizeof(ieData);
			ieData.dwFlags = 0;
			ieData.iType = IEED_EVENT_SYSTEM;
			ieData.color = ppd->colorText;
			if (ppd->flags & PU2_UNICODE) {
				ieData.dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK;
				ieData.pszNickW = ppd->lptzTitle;
				ieData.pszTextW = ppd->lptzText;
				ieData.pszText2W = NULL;
			}
			else {
				ieData.dwFlags |= 0;
				ieData.pszNick = ppd->lpzTitle;
				ieData.pszText = ppd->lpzText;
				ieData.pszText2 = NULL;
			}
			ieData.bIsMe = FALSE;
			ieData.time = ppd->dwTimestamp;
			ieData.dwData = 0;
			ieData.next = NULL;
			CallService(MS_HPP_EG_EVENT, 0, (WPARAM)&ieEvent);
		}
		else if (logType == LOG_DEFAULT) {
			if (arPopupHistory.getCount() <= ListBox_GetCount(hwndLog)) {
				loadItem = 0;
				PostMessage(hwnd, UM_RESIZELIST, 0, 0);
				return TRUE;
			}
			ListBox_SetItemData(hwndLog, ListBox_AddString(hwndLog, _T("")), 0);
		}
		return TRUE;

	case WM_CLOSE:
		Utils_SaveWindowPosition(hwnd, NULL, MODULNAME, "popupHistory_");
		DestroyWindow(hwnd);
		hwndHistory = NULL;
		return TRUE;

	case WM_DESTROY:
		if (logType == LOG_HPP) {
			IEVIEWWINDOW ieWindow;
			ieWindow.cbSize = sizeof(IEVIEWWINDOW);
			ieWindow.iType = IEW_DESTROY;
			ieWindow.dwFlags = 0;
			ieWindow.dwMode = IEWM_TABSRMM;
			ieWindow.parent = hwnd;
			ieWindow.hwnd = hwndLog;
			CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);
		}
	}
	return FALSE; // DefWindowProc(hwnd, msg, wParam, lParam);
}
Beispiel #12
0
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
Beispiel #13
0
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify) 
{
  char szCurDir[_MAX_PATH];
  switch(id) 
  {
    case ID_LIST_DIR:
      if(codeNotify == LBN_DBLCLK) 
      {
        int index = ListBox_GetCurSel(hWndCtl);
        DWORD dwItemData = ListBox_GetItemData(hWndCtl, index);

        if(HIWORD(dwItemData) == ID_ICON_OPENSELECT) 
        {
          shutDialog(hWnd);
          char szString[_MAX_PATH];
          Edit_GetText(GetDlgItem(hWndDirPicker, ID_EDIT_DIR), szString, sizeof(szString));
          lstrcpy(lpszStringToReturn, szString);
          EndDialog(hWnd, IDOK);
          break;
        }

        ListBox_GetText(hWndCtl, index, szCurDir);

        char szDir[_MAX_DIR];
        LPSTR lpsz;
        if((HIWORD(dwItemData) == ID_ICON_FOLDEROPEN) && (index != 0)) 
        {
          GetWindowText(hWndCtl, szDir, sizeof(szDir));
          lpsz=_fstrstr(szDir, szCurDir);
          *(lpsz + lstrlen(szCurDir)) = '\0';
          lstrcpy(szCurDir, szDir);
        }
        if (_chdir(szCurDir) == 0) 
        {
          _getcwd(szCurDir, _MAX_PATH);
          fillListBox(hWndDirPicker, szCurDir);
        }
      }
      break;
    case ID_COMBO_DIR:
      if(codeNotify == CBN_SELCHANGE) 
      {
        char szDrive[80];
        int index = ComboBox_GetCurSel(hWndCtl);
        if(index == CB_ERR)
          break;
        ComboBox_GetLBText(hWndCtl, index, szDrive);

        int iCurDrive = _getdrive();
Retry:
        HCURSOR hCursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
        SetCapture(hWndDirPicker);
        if((0 == _chdrive((int)(szDrive[0] - 'a' + 1))) && (NULL != _getcwd(szCurDir, _MAX_PATH))) 
        {
          fillListBox(hWndDirPicker, szCurDir);
          ListBox_SetTopIndex(GetDlgItem(hWndDirPicker, ID_LIST_DIR), 0);
          SetCursor(hCursorOld);
          ReleaseCapture();
          break;
        }
        SetCursor(hCursorOld);
        ReleaseCapture();

        char szText[80];        
        sprintf(szText, "Cannot read drive %c:", szDrive[0]);
        if(IDRETRY == MessageBox(hWndDirPicker, szText, "Choose Directory", MB_ICONEXCLAMATION|MB_RETRYCANCEL))
          goto Retry;
        
        //Changing drives failed so restore drive and selection
        _chdrive(iCurDrive);

        sprintf(szDrive, "%c:", (char)(iCurDrive + 'a' - 1));
        index = ComboBox_SelectString(hWndCtl, -1, szDrive);
      }
      break;
    case IDOK:
      shutDialog(hWnd);
      char szString[_MAX_PATH];
      Edit_GetText(GetDlgItem(hWndDirPicker, ID_EDIT_DIR), szString, sizeof(szString));
      lstrcpy(lpszStringToReturn, szString);
      EndDialog(hWnd, IDOK);
      break;
    case IDCANCEL:
      shutDialog(hWnd);
      lpszStringToReturn[0] = '\0';
      EndDialog(hWnd, IDCANCEL);
      break;
    default:
      break;
  }
}
Beispiel #14
0
static void fillListBox(HWND hWnd, LPSTR lpszDir) 
{
  HWND hWndLB = GetDlgItem(hWnd, ID_LIST_DIR);
  HWND hWndTempLB = GetDlgItem(hWnd, ID_LISTTEMP_DIR);
  HWND hWndEdit = GetDlgItem(hWnd, ID_EDIT_DIR);
  if((hWndLB == NULL) || (lpszDir == NULL))
    return;
  
  int iLastChar = lstrlen(lpszDir);
  if(lpszDir[iLastChar - 1] == '\\')
    lpszDir[iLastChar - 1] = '\0';

  SetWindowRedraw(hWndLB, FALSE);
  ListBox_ResetContent(hWndLB);
  ListBox_ResetContent(hWndTempLB);

  LPSTR lpszLast;
  lpszLast = CharLower(lpszDir);

  SetWindowText(hWndLB, lpszDir);

  char szDir[_MAX_DIR];
  char szFullDir[_MAX_DIR];
  sprintf(szFullDir, "%s", lpszDir);
  sprintf(szDir, "%s\\*.*", lpszDir);

  BOOL bFirst = TRUE;
  char ch;
  int index;
  while (TRUE) 
  {
    LPSTR lpsz;
    if((lpszDir[0] == '\\') && (lpszDir[1] == '\\') && bFirst)
      lpsz = strchr(lpszLast + lstrlen(szUNCRoot), '\\');
    else
      lpsz = strchr(lpszLast, '\\');
    if(lpsz != NULL) {
      if (bFirst)
        ch = *(++lpsz);
      else
        ch = *lpsz;
      *lpsz = 0;
    } 
    else 
    {
      //If we're looking at a drive only, then append a backslash
      if (lpszLast == lpszDir && bFirst)
        lstrcat(lpszLast, "\\");
    }
    //Add the drive string--includes the last one where lpsz == NULL
    index = ListBox_AddString(hWndLB, lpszLast);

    UINT i = (NULL != lpsz) ? ID_ICON_FOLDEROPEN : ID_ICON_OPENSELECT;
    ListBox_SetItemData(hWndLB, index, MAKELONG(index, i));

    if(NULL == lpsz)
      break;

      //Restore last character.
    *lpsz = ch;
    lpsz += (bFirst) ? 0 : 1;

    bFirst=FALSE;
    lpszLast = lpsz;
  }
  int indent = index + 1;

  //Get available directories
  fillTempLBWithDirs(hWndTempLB, lpszDir);

  int itemCount = ListBox_GetCount(hWndTempLB);

  int i=0;
  for (i = 0; i < itemCount; i++) {
    index = ListBox_GetText(hWndTempLB, i, lpszDir);
    //Skip directories beginning with . (skipping . and ..)
    if(lpszDir[1] == '.')
      continue;
    //Remove the ending ']'
    iLastChar = lstrlen(lpszDir);
    lpszDir[iLastChar - 1] = '\0';
    //Add the string to the real directory list.
    index = ListBox_AddString(hWndLB, lpszDir + 1);
    ListBox_SetItemData(hWndLB, index, MAKELONG(indent, ID_ICON_FOLDERCLOSED));
  }
  //Force a listbox repaint.
  SetWindowRedraw(hWndLB, TRUE);
  InvalidateRect(hWndLB, NULL, TRUE);

  if(szFullDir[lstrlen(szFullDir) - 1] == ':')
    lstrcat(szFullDir, "\\");
  Edit_SetText(hWndEdit, szFullDir);

  GetScrollRange(hWndLB, SB_VERT, (LPINT)&i, (LPINT)&index);

  if(!(i == 0 && index == 0))
    ListBox_SetTopIndex(hWndLB, max((int)(index - 2), 0));

  ListBox_SetCurSel(hWndLB, indent - 1);
}
Beispiel #15
0
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
Beispiel #16
0
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
}
Beispiel #17
0
/*
 * 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);
}
Beispiel #18
0
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
Beispiel #19
0
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