Painting to a picturebox

Started by
2 comments, last by Wan 19 years, 7 months ago
god i feel like such a noob -_- but i never learned real win32 programming just opengl...anyways im trying to make a perlin noise sample, but im sorta just learning how to program using dialogs as i go, ive figured out how to do button interaction and such, when i click the generate button, an array is filled with the perlin values (greyscale from 0-255), i have a picturebox that i want to paint the pixels to...but what functions might i go about using to do this? (perhaps bitblt, but how would i tell it to target the picturebox?)
---------------------------------------------think outside the quadLogic GamesI realized I stay on the pc too long when my wireless mouse died after replacing the batteries...twice
Advertisement
If you want to plot just pixels, you're better of using SetPixelV. This function (and bitblt for that matter) needs a handle to the device context (hdc). It depends on the language, but if you're talking about a vb picturebox you can use its hDC property, otherwise you'll need GetDC (ReleaseDC).
no im using c++, vb picturebox painting is easy...

so would it look like this?

hDC = GetDC(hDlg);
SetPixelV(hDC, x, y, Color);

Is that all i need, or do i need to refresh the picturebox after i paint or anything? (i know in vb you can set the picturebox to auto-redraw, or refresh it, so what would i do in c++?)

Edit: i can get the DC to the window and paint to that, but how would i grab the DC of the picturebox?

[Edited by - SilverLogic on September 11, 2004 7:42:06 PM]
---------------------------------------------think outside the quadLogic GamesI realized I stay on the pc too long when my wireless mouse died after replacing the batteries...twice
Yeah, if hDlg is the handle to the window that contains the picturebox, this should work:

// get handle to picture box window (using its id)
HWND hWndPic = PicGetDlgItem(hDlg, THE_PICTUREBOX_ID);
// get handle to device context picture box
HDC hDC = GetDC(hDlg);
// draw
SetPixelV(hDC, x, y, Color);
// release
ReleaseDC(hWndPic, hDC);

This topic is closed to new replies.

Advertisement