Sign in to follow this  

Painting to a picturebox

This topic is 4842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?)

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites

This topic is 4842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this