Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Where should I implement StretchBlt?

I need to zoom in and out of a bitmap. I am currently able to display the image onto the screen. So my question now is, where can I call the StretchBlt method in order to zoom in and out of the image?
0
mwcmp
Asked:
mwcmp
2 Solutions
 
AlexFMCommented:
In WM_PAINT message handler, like any other drawing code. I guess you have BitBlt already, replace it with StretchBlt with some zoom coefficient.
0
 
mwcmpAuthor Commented:
Ya, I do have BitBlt.
But how can I have 2 OnPaint() in a Dlg?

For example, I click on a button call 'zoom', how can I pass it to call StretchBlt?
0
 
Nass89Commented:
Hi,
You don't need two OnPaint().
Add a member variable and name it ZommFactor. When you click the zoom button set the ZoomFactor to the value you want and call OnPaint(). In OnPaint() use StrechBlt based on zoom factor.

Good Luck!
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Jaime OlivaresSoftware ArchitectCommented:
I think you didn't understood the windows painting paradigm, the OnPaint function will be the unique point where paint takes effect (with few advanced exceptions), so, if you want to react to user input, like change zoom and pan, then save your new data as Nass89 specified, and force painting with RedrawWindow() or Invalidate() functions.
0
 
mwcmpAuthor Commented:
Thanks Nass89. Its done.

0
 
mwcmpAuthor Commented:
one more question...

>> if you want to react to user input, like change zoom and pan
How do I know that the user had click on the screen? (for panning)
0
 
Jaime OlivaresSoftware ArchitectCommented:
Create an event for the WM_LBUTTONDOWN message using the ClassWizard (press Ctrl-W), put it on your CView derived object.
every time the user clicks the left button the event will be launched (OnLButtonDown) passing you the client screen coordinates.
The same with WM_MOUSEMOVE and WM_LBUTTONUP
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now