Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Urgent Help: win32 problem

Options
  • 24-06-2004 12:08pm
    #1
    Registered Users Posts: 1,365 ✭✭✭


    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 Posts: 1,421 ✭✭✭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