Пример #1
0
/////////////////////////////////////////
// Dir window callback
LRESULT CALLBACK ShDirProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static const int tTabs[] = { 90, 125 };
struct S_DirectoryContent *pDir = (struct S_DirectoryContent *) lParam;
HWND hLBWnd = GetDlgItem (hWnd, IDC_LB_SHDIR);
int Ark;

  switch (message)
  {
       case WM_INITDIALOG :
	   	   // Set the window name to either tftpd32 or tftpd64
	       SetWindowText (hWnd, TFTPD_DIR_TITLE);

           ListBox_SetTabStops ( hLBWnd, SizeOfTab(tTabs), tTabs );
           ListBox_ResetContent ( hLBWnd );
           for ( Ark=0 ;  Ark < pDir->nb ;  Ark++ )
                ListBox_AddString ( hLBWnd, pDir->ent[Ark].file_descr );
           CenterChildWindow (hWnd, CCW_INSIDE | CCW_VISIBLE);
           // If GUI is in remote mode, deactivate Explorer Button
           if ( IsGuiConnectedToRemoteService () )
                Button_Enable (GetDlgItem (hWnd, IDC_SD_EXPLORER), FALSE);
           break;

       case WM_COMMAND :
            Handle_VM_Command (hWnd, wParam, lParam);
           break;
       case WM_CLOSE :
       case WM_DESTROY :
            EndDialog (hWnd, 0);
            break;

  } // switch

return FALSE;
} // ShDirProc
Пример #2
0
BOOL ViewStatistics_OnInitDialog( HWND hwnd, HWND hwndFocus, LPARAM lParam )
{
  INT i, tabs[3], nSelectedVertices;
  HWND hwndCtrl;
  VERTEX huge *pVertex;
  INT nLifeForms[MAX_LIFEFORMS*3];
  INT nItems[MAX_ITEMS*3];
  char szBuf[128];

  _fmemset(nLifeForms, 0, sizeof(nLifeForms));
  _fmemset(nItems, 0, sizeof(nItems));

  nSelectedVertices = CountSelectedVertices(pLevel);

  for(i = 0; i < pLevel->nVertices; ++i)
  {
    pVertex = pLevel->pVertexData + i;

    if (nSelectedVertices > 0 && (pVertex->flags & VF_SELECTED) == 0)
    {
      continue;
    }

    if (pVertex->flags & VF_LIFEFORM)
    {
      if (pVertex->lifeform_index >= 0 && pVertex->lifeform_index < po->nLifeForms)
      {
        if (pVertex->flags & VF_DIFFICULTY_LEVEL_1)
        {
          ++nLifeForms[pVertex->lifeform_index];
        }
        if (pVertex->flags & VF_DIFFICULTY_LEVEL_2)
        {
          ++nLifeForms[pVertex->lifeform_index + MAX_LIFEFORMS];
        }
        if (pVertex->flags & VF_DIFFICULTY_LEVEL_3)
        {
          ++nLifeForms[pVertex->lifeform_index + MAX_LIFEFORMS * 2];
        }
      }
    }
    else if (pVertex->flags & VF_ITEM)
    {
      if (pVertex->item_index >= 0 && pVertex->item_index < po->nItems)
      {
        if (pVertex->flags & VF_DIFFICULTY_LEVEL_1)
        {
          ++nItems[pVertex->item_index];
        }
        if (pVertex->flags & VF_DIFFICULTY_LEVEL_2)
        {
          ++nItems[pVertex->item_index + MAX_ITEMS];
        }
        if (pVertex->flags & VF_DIFFICULTY_LEVEL_3)
        {
          ++nItems[pVertex->item_index + MAX_ITEMS * 2];
        }
      }
    }
  }

  hwndCtrl = GetDlgItem( hwnd, IDC_STATISTICS_LIST );

  tabs[0] = 96;
  tabs[1] = tabs[0] + 32;
  tabs[2] = tabs[1] + 32;

  ListBox_SetTabStops(hwndCtrl, 3, &tabs);

  ListBox_AddString( hwndCtrl, "Difficulty Level\t1\t2\t3" );
  ListBox_AddString( hwndCtrl, "" );

  for(i = 0; i < po->nLifeForms; ++i)
  {
    if (nLifeForms[i] > 0 ||
        nLifeForms[i + MAX_LIFEFORMS] > 0 ||
        nLifeForms[i + MAX_LIFEFORMS * 2] > 0)
    {
      wsprintf(szBuf,
        "%s\t%d\t%d\t%d",
        po->pLifeFormData[i].lifeform_name,
        nLifeForms[i],
        nLifeForms[i + MAX_LIFEFORMS],
        nLifeForms[i + MAX_LIFEFORMS * 2]);

      ListBox_AddString( hwndCtrl, szBuf );
    }
  }

  for(i = 0; i < po->nItems; ++i)
  {
    if (nItems[i] > 0 ||
        nItems[i + MAX_ITEMS] > 0 ||
        nItems[i + MAX_ITEMS * 2] > 0)
    {
      wsprintf(szBuf,
        "%s\t%d\t%d\t%d",
        po->pItemData[i].item_name,
        nItems[i],
        nItems[i + MAX_ITEMS],
        nItems[i + MAX_ITEMS * 2]);

      ListBox_AddString( hwndCtrl, szBuf );
    }
  }

  ListBox_SetCurSel( hwndCtrl, 2 );

  AllDialogs_OnInitDialog( hwnd, hwndFocus, lParam );

  return TRUE;

} // ViewStatistics_OnInitDialog
Пример #3
0
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    static HBITMAP hbmp = NULL;
    HDC hdc;

    switch (uMsg)
    {
    case WM_INITDIALOG:
    {
        HWND hwnd;
        RECT r, rdlg, chrome, rtab, rcancel, rstart;
        int32_t xoffset = 0, yoffset = 0;

        // Fetch the positions (in screen coordinates) of all the windows we need to tweak
        ZeroMemory(&chrome, sizeof(chrome));
        AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
        GetWindowRect(hwndDlg, &rdlg);
        GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
        GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
        GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);

        // Knock off the non-client area of the main dialogue to give just the client area
        rdlg.left -= chrome.left;
        rdlg.top -= chrome.top;
        rdlg.right -= chrome.right;
        rdlg.bottom -= chrome.bottom;

        // Translate them to client-relative coordinates wrt the main dialogue window
        rtab.right -= rtab.left - 1;
        rtab.bottom -= rtab.top - 1;
        rtab.left  -= rdlg.left;
        rtab.top -= rdlg.top;

        rcancel.right -= rcancel.left - 1;
        rcancel.bottom -= rcancel.top - 1;
        rcancel.left -= rdlg.left;
        rcancel.top -= rdlg.top;

        rstart.right -= rstart.left - 1;
        rstart.bottom -= rstart.top - 1;
        rstart.left -= rdlg.left;
        rstart.top -= rdlg.top;

        // And then convert the main dialogue coordinates to just width/length
        rdlg.right -= rdlg.left - 1;
        rdlg.bottom -= rdlg.top - 1;
        rdlg.left = 0;
        rdlg.top = 0;

        // Load the bitmap into the bitmap control and fetch its dimensions
        hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
        hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
        SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
        GetClientRect(hwnd, &r);
        xoffset = r.right;
        yoffset = r.bottom - rdlg.bottom;

        // Shift and resize the controls that require it
        rtab.left += xoffset;
        rtab.bottom += yoffset;
        rcancel.left += xoffset;
        rcancel.top += yoffset;
        rstart.left += xoffset;
        rstart.top += yoffset;
        rdlg.right += xoffset;
        rdlg.bottom += yoffset;

        // Move the controls to their new positions
        MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
        MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE);
        MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);

        // Move the main dialogue to the centre of the screen
        hdc = GetDC(NULL);
        rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
        rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
        ReleaseDC(NULL, hdc);
        MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
                   rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);

        // Add tabs to the tab control
        {
            TCITEM tab;

            hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);

            ZeroMemory(&tab, sizeof(tab));
            tab.mask = TCIF_TEXT;
            tab.pszText = TEXT("Setup");
            SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
            tab.mask = TCIF_TEXT;
            tab.pszText = TEXT("Message Log");
            SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);

            // Work out the position and size of the area inside the tab control for the pages
            ZeroMemory(&r, sizeof(r));
            GetClientRect(hwnd, &r);
            SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
            r.right -= r.left-1;
            r.bottom -= r.top-1;
            r.top += rtab.top;
            r.left += rtab.left;

            // Create the pages and position them in the tab control, but hide them
            pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(),
                                             MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
            pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
            SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
            SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);

            // Tell the editfield acting as the console to exclude the width of the scrollbar
            GetClientRect(pages[TAB_MESSAGES],&r);
            r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
            r.left = r.top = 0;
            SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);

            // Set a tab stop in the game data listbox
            {
                DWORD tabs[1] = { 150 };
                (void)ListBox_SetTabStops(GetDlgItem(pages[TAB_CONFIG], IDCDATA), 1, tabs);
            }

            SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
            SetWindowText(hwndDlg, apptitle);
        }
        return FALSE;
    }

    case WM_NOTIFY:
    {
        LPNMHDR nmhdr = (LPNMHDR)lParam;
        int32_t cur;
        if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
        cur = (int32_t)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
        switch (nmhdr->code)
        {
        case TCN_SELCHANGING:
        {
            if (cur < 0 || !pages[cur]) break;
            ShowWindow(pages[cur],SW_HIDE);
            return TRUE;
        }
        case TCN_SELCHANGE:
        {
            if (cur < 0 || !pages[cur]) break;
            ShowWindow(pages[cur],SW_SHOW);
            return TRUE;
        }
        }
        break;
    }

    case WM_CLOSE:
        if (mode == TAB_CONFIG) done = 0;
        else quitevent++;
        return TRUE;

    case WM_DESTROY:
        if (hbmp)
        {
            DeleteObject(hbmp);
            hbmp = NULL;
        }

        if (pages[TAB_CONFIG])
        {
            DestroyWindow(pages[TAB_CONFIG]);
            pages[TAB_CONFIG] = NULL;
        }

        startupdlg = NULL;
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case WIN_STARTWIN_CANCEL:
            if (mode == TAB_CONFIG) done = 0;
            else quitevent++;
            return TRUE;
        case WIN_STARTWIN_START:
            done = 1;
            return TRUE;
        }
        return FALSE;

    case WM_CTLCOLORSTATIC:
        if ((HWND)lParam == pages[TAB_MESSAGES])
            return (BOOL)(intptr_t)GetSysColorBrush(COLOR_WINDOW);
        break;

    default:
        break;
    }

    return FALSE;
}