Home > Software engineering >  MFC through the create () function dynamically created a static text control cannot refresh window a
MFC through the create () function dynamically created a static text control cannot refresh window a

Time:11-14

As title, I created a succession to do canvas CStatic control of a class, in the parent dialog onctlcolor function will be set to transparent, but in the news of the subclass response function invalidate () and updatewindow cannot achieve the refresh () the window

This is a function of set transparent background


This is to set up the canvas background transparent before:



After this is the canvas set the background to transparent (there is a gray image so below display color is gray) :


The following is a control onm ousemove message response function in a subclass function:


Sorry points is not much, all can take out the

CodePudding user response:

Their top, by the way, could you illustrate this grey color is for the use of images, I hope he can show them things in various shapes in the above picture, so the idea is to create a transparent background canvas covered in the above, and then in a transparent canvas of response to the mouse message mapping

CodePudding user response:

to achieve transparent dialog box when the bitmap as a background of control

CodePudding user response:

Not TRANSPARENT window!

CodePudding user response:

refer to the second floor zgl7903 response:
to achieve transparent dialog box when the bitmap as a background of control
thank you for reply, I now can realize transparent controls, but the problem is that transparent controls after the refresh, I looked at your blog is about how to make a corresponding to the dialog and makes the control background transparent, but not involving the transparent background control refresh problem

CodePudding user response:

reference schlafenhamster reply: 3/f
not TRANSPARENT window!
didn't quite understand, could you go into more detail, I set the transparency is no problem now, main is to set up after the transparent static control cannot be achieved with invalidate () and updatewindow () to refresh window, leading to constantly draw rectangle when the mouse moves

CodePudding user response:

The mouse moves?
Why the mouse within the static window to redraw?

In the final rendering TRANSPARENT is the window

CodePudding user response:

refer to 6th floor schlafenhamster response:
cause while moving the mouse?
Why the mouse within the static window to redraw?

TRANSPARENT is the window in the final draw
redrawing is in order to last the mouse when it moves message painted rectangular, so you can realize the effect of a dynamic picture of rectangular box, similar to the Windows desktop click the left mouse button drag rectangle will appear a real-time changes

CodePudding user response:

Don't use picture code!
The detailed code

CodePudding user response:

Before each drawing need to make your own screen clearing operation, TRANSPARENT set, the parent window is no longer responsible for child controls background rendering, you use the background color to FillRect once again a Rectangle

CodePudding user response:

dumplings, 9/f, references and do not reply:
before each drawing need to make your own screen clearing operation, TRANSPARENT set, the parent window is no longer responsible for child controls background rendering, you use the background color to FillRect once again a Rectangle
I hope now is the background color is TRANSPARENT, so the return air brush, but the problem is the window no longer refresh, if fill the background color the words directly to the brush set to have a color is ok, but every time when the mouse moves the background color will be displayed, I hope the background is always do not display (TRANSPARENT)

CodePudding user response:

MFC simple drawing in the implementation of the


  • Related