Esempio n. 1
0
static INT_PTR CALLBACK NvGpuDialogProc(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
    )
{
    //PhDeleteLayoutManager(&LayoutManager);

    //PhDeleteGraphState(&GpuGraphState);
    //PhDeleteGraphState(&MemGraphState);
    //PhDeleteGraphState(&SharedGraphState);
    //PhDeleteGraphState(&BusGraphState);

    //if (GpuGraphHandle)
    //    DestroyWindow(GpuGraphHandle);
    //if (MemGraphHandle)
    //    DestroyWindow(MemGraphHandle);
    //if (SharedGraphHandle)
    //    DestroyWindow(SharedGraphHandle);
    //if (BusGraphHandle)
    //    DestroyWindow(BusGraphHandle);
    //if (GpuPanel)
    //    DestroyWindow(GpuPanel);

    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            PPH_LAYOUT_ITEM graphItem;
            PPH_LAYOUT_ITEM panelItem;

            WindowHandle = hwndDlg;

            GpuLabelHandle = GetDlgItem(hwndDlg, IDC_GPU_L);
            MemLabelHandle = GetDlgItem(hwndDlg, IDC_MEMORY_L);
            SharedLabelHandle = GetDlgItem(hwndDlg, IDC_SHARED_L);
            BusLabelHandle = GetDlgItem(hwndDlg, IDC_BUS_L);

            PhInitializeGraphState(&GpuGraphState);
            PhInitializeGraphState(&MemGraphState);
            PhInitializeGraphState(&SharedGraphState);
            PhInitializeGraphState(&BusGraphState);

            PhInitializeLayoutManager(&LayoutManager, hwndDlg);
            PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDC_GPUNAME), NULL, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_RIGHT | PH_LAYOUT_FORCE_INVALIDATE);
            graphItem = PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDC_GRAPH_LAYOUT), NULL, PH_ANCHOR_ALL);
            GpuGraphMargin = graphItem->Margin;
            panelItem = PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDC_LAYOUT), NULL, PH_ANCHOR_LEFT | PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM);

            SendMessage(GetDlgItem(hwndDlg, IDC_TITLE), WM_SETFONT, (WPARAM)Section->Parameters->LargeFont, FALSE);
            SendMessage(GetDlgItem(hwndDlg, IDC_GPUNAME), WM_SETFONT, (WPARAM)Section->Parameters->MediumFont, FALSE);
            SetDlgItemText(hwndDlg, IDC_GPUNAME, GpuName->Buffer);

            GpuPanel = CreateDialog(PluginInstance->DllBase, MAKEINTRESOURCE(IDD_GPU_PANEL), hwndDlg, NvGpuPanelDialogProc);
            ShowWindow(GpuPanel, SW_SHOW);
            PhAddLayoutItemEx(&LayoutManager, GpuPanel, NULL, PH_ANCHOR_LEFT | PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM, panelItem->Margin);

            NvGpuCreateGraphs();

            NvGpuUpdate();
            NvGpuUpdateGraphs();
            NvGpuUpdatePanel();
        }
        break;
    case WM_SIZE:
        NvGpuLayoutGraphs();
        break;
    case WM_NOTIFY:
        {
            NMHDR* header = (NMHDR*)lParam;

            if (header->hwndFrom == GpuGraphHandle)
            {
                NvGpuNotifyUsageGraph(header);
            }
            else if (header->hwndFrom == MemGraphHandle)
            {
                NvGpuNotifyMemoryGraph(header);
            }
            else if (header->hwndFrom == SharedGraphHandle)
            {
                NvGpuNotifySharedGraph(header);
            }
            else if (header->hwndFrom == BusGraphHandle)
            {
                NvGpuNotifyBusGraph(header);
            }
        }
        break;
    case UPDATE_MSG:
        {
            NvGpuUpdateGraphs();
            NvGpuUpdatePanel();
        }
        break;
    }

    return FALSE;
}
Esempio n. 2
0
static INT_PTR CALLBACK NvGpuDialogProc(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
    )
{
    PPH_NVGPU_SYSINFO_CONTEXT context = NULL;

    if (uMsg == WM_INITDIALOG)
    {
        context = (PPH_NVGPU_SYSINFO_CONTEXT)lParam;

        SetProp(hwndDlg, L"Context", (HANDLE)context);
    }
    else
    {
        context = (PPH_NVGPU_SYSINFO_CONTEXT)GetProp(hwndDlg, L"Context");

        if (uMsg == WM_NCDESTROY)
        {
            PhDeleteLayoutManager(&context->LayoutManager);

            PhDeleteGraphState(&context->GpuGraphState);
            PhDeleteGraphState(&context->MemGraphState);
            PhDeleteGraphState(&context->SharedGraphState);
            PhDeleteGraphState(&context->BusGraphState);

            if (context->GpuGraphHandle)
                DestroyWindow(context->GpuGraphHandle);
            if (context->MemGraphHandle)
                DestroyWindow(context->MemGraphHandle);
            if (context->SharedGraphHandle)
                DestroyWindow(context->SharedGraphHandle);
            if (context->BusGraphHandle)
                DestroyWindow(context->BusGraphHandle);
            if (context->GpuPanel)
                DestroyWindow(context->GpuPanel);

            PhUnregisterCallback(&PhProcessesUpdatedEvent, &context->ProcessesUpdatedRegistration);

            RemoveProp(hwndDlg, L"Context");
        }
    }

    if (context == NULL)
        return FALSE;

    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            PPH_LAYOUT_ITEM graphItem;
            PPH_LAYOUT_ITEM panelItem;

            context->WindowHandle = hwndDlg;

            context->GpuLabelHandle = GetDlgItem(hwndDlg, IDC_GPU_L);
            context->MemLabelHandle = GetDlgItem(hwndDlg, IDC_MEMORY_L);
            context->SharedLabelHandle = GetDlgItem(hwndDlg, IDC_SHARED_L);
            context->BusLabelHandle = GetDlgItem(hwndDlg, IDC_BUS_L);

            PhInitializeGraphState(&context->GpuGraphState);
            PhInitializeGraphState(&context->MemGraphState);
            PhInitializeGraphState(&context->SharedGraphState);
            PhInitializeGraphState(&context->BusGraphState);

            PhInitializeLayoutManager(&context->LayoutManager, hwndDlg);
            PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_GPUNAME), NULL, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_RIGHT | PH_LAYOUT_FORCE_INVALIDATE);
            graphItem = PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_GRAPH_LAYOUT), NULL, PH_ANCHOR_ALL);
            context->GpuGraphMargin = graphItem->Margin;
            panelItem = PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_PANEL_LAYOUT), NULL, PH_ANCHOR_LEFT | PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM);

            SendMessage(GetDlgItem(hwndDlg, IDC_TITLE), WM_SETFONT, (WPARAM)context->Section->Parameters->LargeFont, FALSE);
            SendMessage(GetDlgItem(hwndDlg, IDC_GPUNAME), WM_SETFONT, (WPARAM)context->Section->Parameters->MediumFont, FALSE);
            SetDlgItemText(hwndDlg, IDC_GPUNAME, context->GpuName->Buffer);

            context->GpuPanel = CreateDialogParam(PluginInstance->DllBase, MAKEINTRESOURCE(IDD_GPU_PANEL), hwndDlg, NvGpuPanelDialogProc, (LPARAM)context);
            ShowWindow(context->GpuPanel, SW_SHOW);
            PhAddLayoutItemEx(&context->LayoutManager, context->GpuPanel, NULL, PH_ANCHOR_LEFT | PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM, panelItem->Margin);

            NvGpuCreateGraphs(context);

            NvGpuUpdateValues();
            NvGpuUpdateGraphs(context);
            NvGpuUpdatePanel(context);

            PhRegisterCallback(
                &PhProcessesUpdatedEvent,
                ProcessesUpdatedHandler,
                context,
                &context->ProcessesUpdatedRegistration
                );
        }
        break;
    case WM_SIZE:
        NvGpuLayoutGraphs(context);
        break;
    case WM_NOTIFY:
        {
            NMHDR* header = (NMHDR*)lParam;

            if (header->hwndFrom == context->GpuGraphHandle)
            {
                NvGpuNotifyUsageGraph(context, header);
            }
            else if (header->hwndFrom == context->MemGraphHandle)
            {
                NvGpuNotifyMemoryGraph(context, header);
            }
            else if (header->hwndFrom == context->SharedGraphHandle)
            {
                NvGpuNotifySharedGraph(context, header);
            }
            else if (header->hwndFrom == context->BusGraphHandle)
            {
                NvGpuNotifyBusGraph(context, header);
            }
        }
        break;
    case MSG_UPDATE:
        {
            NvGpuUpdateGraphs(context);
            NvGpuUpdatePanel(context);
        }
        break;
    }

    return FALSE;
}