In mfc dialog based application i draw one graph on picture control and plot points as i needed,but problem is whenever i resize dialog that picture control remained as it is and looked weired! I can write some code on event of 0nSize() of dialog but it only resize other controls except picture control, so how to make changes on event of size changes of dialog?
`
RECT rc;
GetClientRect(&rc);
rc.top+=25;
rc.bottom-=80;
rc.left+=15;
rc.right+=15;
GetDlgItem(IDC_PIC1)->MoveWindow(&rc);
Above i paste some code which i tried so much but not working,please give me any idea for that!
Related
I have an SVG map with some pins on it that need to be clickable. Furthermore, a small animation is activated whenever the user hovers over one of the pins on desktop. My issue is that it is only the actual shape that receives the event, which is problematic, as the pins have a little "hole" in its center, so if the user hovers or clicks in the center of the pin nothing happens. Is there a way to make the event trigger whenever the user clicks or hovers over the bounding box of the shape, ie. the area is outlined when the element is viewed in the inspector, or would I have to extend the actual SVG with an invisible box or some other "hacky" solution"?
Yes, you'll need to add an invisible rectangle on top. You'll want to set that rectangle to pointer-events: fill, so it gets click events even though it is invisible.
I am new to VC++.
How to zoom in/out an image on clicking zoom in/out button in SDI.
You might want to derive your document view class from CScrollView instead of the default CView created by the wizard. Use the SetScrollSizes() member function to set the zoom level. You could use SetScaleToFit() initially to define 100% zoom. In OnDraw() use CDC::StretchBlt() to actually draw the image to the size you have set via SetScrollSizes().
I am trying to make a MFC SDI application in VC++ to draw different shapes on click of the respective button. We have written our code inside the OnDraw() function. But Ondraw gets automatically called on running the application. We want it to be called only on the onclick of respective button. How do we proceed..?
When a shape button is clicked set a member variable that remembers what you want to draw.
Call Invalidate. This will cause OnDraw to be called by the framework.
In OnDraw check the member variable and draw the shape.
You must permit OnDraw to draw every time it is called by the framework. That is how the window image is restored after being uncovered, unminimized, resized, etc.
You cant prevent that OnDraw is only called when you press a button.
OnDraw in a view is called when WM_PAINT arrives and asks the window to repaint itself. Not executing OnDraw would cause nothing to be drawn at all.
OnDraw is also called when your application is minimized and maximized again, or when the size of the window changes.
Also I can not think about a scenario, where I want drawing only when a button is pressed. You need to be more precise. here.
OnDraw, as xMRi said, is called by the framework ... but if you want to draw something only when you click on a button, why don't you create a member variable, setup when you click the button, and get count when OnDraw is executed ?
void CYourAppView::OnDraw(CDC* pDC)
{
// MFC code
if(m_bButtonWasClicked)
{
// draw what ever you want
}
}
I am having button and on which I am trying to load a bitmap and able to load the bitmap on the button.But when I run my exe on an japanese win7 enterprise Operating system then my button's are a bit stretched and the bitmap did not get stretched and was not fit to the button area.
Can anyone please let me know how can we make the bitmap to get strecthed and fit to the button whenever the button is stretched.
You have to derive you own owner draw button class. You need to overwrite OnDrawItem and use StretchBlt to draw the bitmap into the buttons client area.
Just use the code you find in the MFC in CBitmapButton...
You may be asking the wrong question. You could get the size of the bitmap and then change the button size (with MoveWindow) to match the bitmap.
I am creating a project similar to task manager,
Now I want to draw a graph to that show cpu usage.
My problem is that I dont have any knowledge about painting in vc++,
but my idea is that I should first make a grid like in task manager but I dont have any pixel information,
So plese tell me how to find the pixel value if the Picture control.
Rather than trying to manipulate what's on screen what you need to do is a create a bitmap in memory using CBitmap::CreateCompatibleBitmap and BitBlt when Windows sends a WM_PAINT message.
This question looks at how to subclass a CStatic control (ie a picture control) to draw onto a dialog by handling WM_PAINT messages:
Handling WM_PAINT in a Subclassed CStatic Control
You just need to add the bitmap painting bit.