Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Urgent Help: win32 problem

  • 24-06-2004 12:08PM
    #1
    Registered Users, Registered Users 2 Posts: 1,368 ✭✭✭


    hey guys,

    need some help with a win32 app.

    The application will initially draw a grid on the window.

    It will then acquire the data (fill an array)

    Then i will used use the lineto function to draw a graph of the function.

    heres what ive done so far:
    1. within

    <code>LRESULT WINAPI MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)</code>

    Ive put the following code to initialise the grid:

    <code>case WM_PAINT:
    hDC = BeginPaint(hwnd, &Ps);

    hPen = CreateSolidBrush(RGB(0, 0, 0));
    SelectObject(hDC, hPen);
    etc...
    </code?

    This code draws the initial grid

    2.
    The user then clicks an "acquire data" button and a settings dialog box is displayed.

    when they click ok, the data is acquired , and the wave should be drawn:

    within
    int CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)....
    case IDOK:
    hDC = BeginPaint(hwnd, &Ps1);
    hPen = CreatePen(PS_DASHDOTDOT, 1, RGB(255, 255,0 ));
    SelectObject(hDC, hPen);

    AquireData(averages);
    for(i =0; i < 600; i++)
    {
    MoveToEx(hDC, 20+i,175+(ref_chan_average), NULL); LineTo(hDC, 21+i,175+(ref_chan_average[i+1] ));

    }

    EndPaint(hwnd, &Ps1)
    break;

    any ideas, guys,

    the arrays is filling, but no drawing?

    Thanks,
    king


Comments

  • Registered Users, Registered Users 2 Posts: 1,430 ✭✭✭Merrion


    You should add your drawing code to the WM_PAINT handler (check if the array is initialised first) - the use of BeginPaint and Endpaint outside of WM_PAINT processing is not a good idea....

    See MSDN documentation of WM_PAINT for more info, and ...

    If you must draw outside of the WM_PAINT handler use the function GetDC to get the hDC to draw on instead of BeginPaint...


Advertisement