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.
Related
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 have to draw a transparent square, that never disappears from the user's interface, by clicking to other windows the rectangle remains, only the windows/application content has to be shown behind.
I have thought of doing it with OpenGl or Flex or Canvas , but the problem is whenever I click on another window the programmed rectangle disappears .The rectangle has to act as a default image but has to be always at the foreground.
Do I have to mess with the operating system(Linux, Mac or Windows), by creating this image as default?
here is one example
http://i42.tinypic.com/15g3vxh.png
You can do that with Java pretty easy. See this link for code examples. If you got your transparent Image, you can use the setAlwaysOnTop(true); Method on the Object, and you are good to go. The only things that could get in front of that are other Applications that are using that method.
I'm pretty new to javafx so I'm trying to learn here so please be reasonable and don't dis away my question, I really appreciate any help at all, thanks!
I would like to know how I could move an object, let's say this circle on different events, like keypress or mouseclick, mousemove, whatever.
Circle circle = new Circle();
circle.setCenterX(100.0f);
circle.setCenterY(100.0f);
circle.setRadius(50.0f);
Do I need to use that KeyFrame thing I saw on the javafx site tutorial, or how does this work?
I would not have asked this here if I weren't feeling so lost, honestly.
So to make this clear: What is the code for moving objects that I created, by using events?
EDIT: By moving it I mean, press up key and it moves up by a few pixels, transform it maybe, with another key, or click somewhere on the scene and make it move there instantly or travel there with a certain speed. I don't have to redraw it like you need to with html5 canvas, I hope, right?
I don't have to redraw it like you need to with html5 canvas, I hope, right?
Not if you are using a standard JavaFX scene graph as opposed to a JavaFX canvas.
I would like to know how I could move an object, let's say this circle on different events, like keypress or mouseclick, mousemove, whatever
There are three ways to move a Shape:
You can adjust the shape's geometry (e.g. the centerX/centerY properties of a circle).
You can adjust the shape's layout (e.g. it's layoutX/layoutY properties).
You can adjust the shape's translation (e.g. it's translateX/translateY properties).
You can think of the layout as the home position for the object; i.e. where it should normally be in the context of it's parent group. You can think of it's translation transform as a temporary position for an object (often used when the object is being animated).
If you are using a layout pane such as a VBox or TilePane, then the layout pane will handle setting the layout co-ordinates of the child node for you. If you are using a simple Group or a plain Pane or Region, then you are responsible for setting the correct layout values for the child nodes.
To listen for events, set event handlers on Nodes or Scenes.
Here is a small sample app which demonstrates the above. It places the object to be moved inside a Group and modifies the position of the object within a Group in response to various events.
I have a problem with MFC dialog boxes that are drawn using derived MFC classes for custom drawing of controls.
One of our customers has a real slow PC with a poor graphics card and even normal Windows dialogs paint quite slow. In our case, the problem is far worse. Each individual control (e.g. buttons, group boxes, labels) can be seen to draw seperately.
In most cases I've overridden/implemented the OnPaint() handlers, thinking that drawing on whatever device context I'm provided should be the way to go.
Ideally, what I would like to do is have all controls painted on an off-screen buffer so that when a dialog repaint is required - bang - it just copies the single rendered image to the screen, rather than painting each control to the screen one by one.
Can somebody please advise me how I can achieve this kind of double-buffering?
I've sort of found the solution to my problem.. By setting the dialog extended style to WS_EX_COMPOSITED, the drawing works nicely.. The problem I'm having now concerns a continuous stream of WM_PAINT and WM_ERASEBKGND messages that I keep getting when this style is enabled.
Does anyone know how I can stop the WM_PAINT/WM_ERASEBKGND messages from continously occurring?
Hi Friends,
I have created one canvas form & on that i placed one image which is my button register. Now i am going to catch image touch events using pointerPressed method for only register image button. But how can i done this? can any one give me idea how to do this. How i can detect the user touches image of register using pointerPressed method. please help me friends.
Thanks
Working with CustomItem will provide your needs.
I have created one canvas form
Canvas or Form? these are totally different objects and handling pointer events would be totally different in Canvas vs Form.
given your mention of pointerPressed I suspect you're talking about Canvas right?
updated: For image drawn on Canvas (thanks for clarifying this btw), you need to know coordinates of the area it occupies, then you just need to check if x and y coordinates passed to in pointerPressed are within area occupied by your image (these are horizontal and vertical location where the pointer was pressed, relative to the Canvas - check the API docs)