コード例 #1
0
ファイル: showpropdlg.cpp プロジェクト: vasilenkomike/xray
INT_PTR CALLBACK PropDlgProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
    App* pApp = (App*)GetWindowLongPtr(hWnd,GWLP_USERDATA);
    // WIN64 Cleanup: Martell

    switch (message) {
    case WM_INITDIALOG:
    {
        pApp = (App*)lParam;
        SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam);
        // WIN64 Cleanup: Martell
        SetCursor(LoadCursor(NULL,IDC_ARROW));
        //CenterWindow(hWnd, GetParent(hWnd));
        SetWindowPos(hWnd, HWND_TOP, pApp->regsettings.propdlgx, pApp->regsettings.propdlgy, 0, 0,
                     SWP_NOOWNERZORDER|SWP_NOSIZE);

        pApp->hPropDialog = hWnd;

        // Arrange the columns in the list view
        LV_COLUMN column;
        column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
        column.fmt = LVCFMT_LEFT;
        column.pszText = pApp->GetString(IDS_CUST_NAME);
        column.cx = 80;
        ListView_InsertColumn(GetDlgItem(hWnd, IDC_CUSTOM), 0, &column);
        column.pszText = pApp->GetString(IDS_CUST_VALUE);
        ListView_InsertColumn(GetDlgItem(hWnd, IDC_CUSTOM), 1, &column);
        column.pszText = pApp->GetString(IDS_CUST_TYPE);
        ListView_InsertColumn(GetDlgItem(hWnd, IDC_CUSTOM), 2, &column);

        pApp->GetProperties();
    }
    return 1;
    case WM_CLOSE:
        DestroyWindow(hWnd);
        break;
    case WM_DESTROY:
    {
        RECT wr;
        GetWindowRect(hWnd, &wr);
        pApp->regsettings.propdlgx = wr.left;
        pApp->regsettings.propdlgy = wr.top;
    }
    pApp->hPropDialog = NULL;
    break;
    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDOK:
        case IDCANCEL:
            DestroyWindow(hWnd);
            break;
        case IDC_PREV:
        {
            int cur = SendMessage(pApp->hListBox, LB_GETCURSEL, 0, 0);
            //int tot = SendMessage(pApp->hListBox, LB_GETCOUNT, 0, 0);
            if (cur > 0) {
                SendMessage(pApp->hListBox, LB_SETCURSEL, cur-1, 0);
                pApp->GetProperties();
            }
        }
        break;
        case IDC_NEXT:
        {
            int cur = SendMessage(pApp->hListBox, LB_GETCURSEL, 0, 0);
            int tot = SendMessage(pApp->hListBox, LB_GETCOUNT, 0, 0);
            if (cur < (tot-1)) {
                SendMessage(pApp->hListBox, LB_SETCURSEL, cur+1, 0);
                pApp->GetProperties();
            }
        }
        break;

        }
        return 1;
    }
    return 0;
}