bluebass44
bluebass44

Reputation: 65

MFC Picture Control

I am graphing incoming data in a picture control. Is there a direct way to change the resolution so I have a more dense grid of pixels to play with? I would rather not have to deal with any file IO because I am pressed on execution time. The dialogue around the picture control appears to be at a higher resolution.

I am sorry for the apparent lack of information that I originally provided as I am unsure exactly what vernacular to use. Below is a snippet of code that it being used in an OnPaint() function.

//Draw X Axis
    int XIncrement = 40;
    int TextY = YOrigin + 5;
    int IntNum; 
    CString Str;
    //Label
    dc.TextOutW(10, 5, Str = "Part Profile", 12);
    dc.TextOutW(GraphMax / 2, YOrigin + 20, Str = "Part Length (in)", 16);

    for (int N = 0; N < 25; N++) {
        IntNum = N * 5;
        Str.Format(_T("%d "), IntNum);
        dc.Rectangle(N * XIncrement + XOffset, YOrigin, N * XIncrement + 2 + XOffset, YOrigin + 5);
        dc.TextOutW(N * XIncrement + XOffset - 7, TextY, Str, 3);
    }

I needed a very basic graph to help iron out an algorithm for a bow inspection machine on a high speed manufacturing line. I used a picture control only because the MFC doesn't appear to have an elegant solution and everything else I found online seemed like a lot of overhead. I am no expert if you have some other suggestion I am open. As far as the resolution is concerned, the text around this control on my UI appears to have a more fine resolution. I was simply curious if I could control the resolution inside the picture control. This would enable me to graph the 1200 data points with more clarity. enter image description here

Upvotes: 0

Views: 1332

Answers (1)

Barmak Shemirani
Barmak Shemirani

Reputation: 31599

You can't make any improvements with bitmaps or bitmap magnification. A better alternative is to give the user more control over the graph, for example insert a couple of slider controls.

One slider changes the x-offset, for example it allows the x-axis to start from zero, or to start from 50. Another slider changes the zoom. For example x-axis can be change to go from (0 to 100) or (0 to 1000)

To make the graph more interesting, enable the modern UI look by adding this line to the main *.cpp file:

#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

Use a more modern font like Segoe UI, and set text background color to match the canvas background:

CFont font;
font.CreatePointFont(90, L"Segoe UI");

dc.SelectObject(font);
dc.SetBkColor(GetSysColor(COLOR_3DFACE));
dc.TextOut(0, 0, L"Hello world");

Upvotes: 1

Related Questions