|
I'm trying to create this on the fly in a CScrollView derived class as part of a SDI application. I suspect that the scroll view or it's base CWnd is eating the notify messages, but I can't be sure. Spy++ on your demo shows WM_NOTIFY messages sent to the parent (CDialog) but the same control instantiated as a child of the scroll view doesn't seem to be sending WM_NOTIFY messages to the parent at all. Without WM_NOTIFY, the parent can't send a reflected message.
Any clues?
|
|
|
|
|
Hi,
I am trying to develop a transparent control.It is having a picture box with a png image and transparent background.I have set the background color of the control to transparent.
Now, it is working if I place it on a panel or a form. But, it is not working as a transparent control if I place it on another control such as list view or month calender.
If some body can help me,I would be thankful to him.
|
|
|
|
|
While trying to apply this to a pocket pc program, it compiled right away without a problem, but the transparent background didn't work. As I worked with it, it would either have a white or grey background behind the slider, or if I commented out the line in the beginning of DrawChannel for ScreenToClient, that was the only time I got something of the original bitmap to show up, but it was the rectangle beginning immediately below the slider instead of where the slider was. I was able to get a custom thumb bitmap to show up fine, but only for a horizontal slider. Absolutely nothing works for a vertical slider. Any ideas?
Jennifer
|
|
|
|
|
in case of resizing window ,if initially some part of slider is hidden and then u resize it , it wont get drawn properly.
Unmanaged in a .NET world
|
|
|
|
|
i met the same problem,when i resize the slider control,transparent not work.
hello,every one.
|
|
|
|
|
When I start the demo and another program (for example the explorer) is in front of the demo program (the demo program will be displayed behind the other program), the background of the slider have a wrong background. The background behind the slider has the backgroud of the window, which was in the front of the demo program, when I startet the demo program. Any ideas how to fix this problem?
You want to test it?
Start the Windows Task-Manager and place the window in the middle of the Desktop. Now start the demo program, it will appear behind the Task-Manager. Then close the Task-Manager and you will see the problem.
Olaf
|
|
|
|
|
was a solution for this found, I like the control minus this bug
|
|
|
|
|
Hi,
I am not familiar with the things explained in the article. But I would like to have the slider having the same background color as its parent window. How can I do that? I don't want to change the thumb or anything. Can someone help me how to do this?
Thanks
Manju
|
|
|
|
|
Nic,
Another dumb question for you. In DrawTransparent() you have the following:
Invalidate();
EnableWindow(FALSE);
EnableWindow(TRUE);
I don't understand what is happening here. What do the pair of EnableWindow() calls do that Invalidate() doesn't? The documentation for EnableWindow() seems to indicate that this is for controlling mouse and keyboard input rather than drawing.
Thanks for the help!
|
|
|
|
|
Hi,
This is the only way I have found to make sure a full set of paint messages are sent, mainly needed for the users who need to change backgrounds with transparent controls.
Nic
|
|
|
|
|
I have found that this works as advertised, but not well in my application.
I have another CSliderCtrl-derived slider that gets various parameters changed very rapidly. Using the
Invalidate();
EnableWindow(FALSE);
EnableWindow(TRUE); sequence doesn't seem to "keep up". But I found that I get the same effect with this:
int min,max;
CSliderCtrl::GetRange(min,max);
CSliderCtrl::SetRange(min,max,TRUE); This forces the update immediately, which is what I needed.
For your application, it probably doesn't matter. But it is quite a remarkable difference in mine. Very strange. It would appear that there are yet more hidden actions going on!
|
|
|
|
|
Why don't you try Invalidate() followed by UpdateWindow()? UpdateWindow() forces a paint to happen right now synchronously which is probably a side effect of the SetRange TRUE param...
David Cole
|
|
|
|
|
I've tried just about everyone's suggestions regarding this, and this is the only one I have found to work. I have one more suggestion, however. If the CMySliderControl object happens to be disabled, the background color is not updated. Try this:
if (bRepaint == TRUE)
{
Invalidate();
BOOL bEnabled = IsWindowEnabled();
if ( !bEnabled )
EnableWindow();
int min, max;
CSliderCtrl::GetRange(min, max);
CSliderCtrl::SetRange(min, max);
if ( !bEnabled )
EnableWindow(FALSE);
}
This works every time under all conditions (so far). Thanks to everyone who has contributed to this!
|
|
|
|
|
In your code for DrawChannel(), you ask if there is a better way to determine if the control is vertical or horizontal. Try:
BOOL IsVertical = (TBS_VERT & GetStyle()) ? TRUE : FALSE;
Having said that, I have GOT to ask what this is all about:
crect = lpcd->rc;
if (IsVertical)
crect.InflateRect(1, 0, 1, 0);
else
crect.InflateRect(0, 2, 0, 2);
DrawEdge(pDC->m_hDC, &crect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
It looks like the goal of DrawChannel() is merely to capture the background bitmap and then finish the channel. Wouldn't it be easier to just capture the background in OnCustomDraw() and set
*pResult = CDRF_DODEFAULT;
What have I missed here?
And while I'm asking dumb questions, why do you use the DC for the parent window rather than the current window?
Thanks for your help on this. Obviously, I'm a GDI beginner...
|
|
|
|
|
Harold Bamford wrote:
In your code for DrawChannel(), you ask if there is a better way to determine if the control is vertical or horizontal. Try:
Great! I could not find that anywhere I will give it a try!
Harold Bamford wrote:
It looks like the goal of DrawChannel() is merely to capture the background bitmap and then finish the channel. Wouldn't it be easier to just capture the background in OnCustomDraw() and set *pResult = CDRF_DODEFAULT;
The class is unfinished and this is skeleton code for those who wish to alter the channel, some users do not know how to do this. I also like the type of channel this draws, I have expanded it further to fill the channel with various colours to the left, right or both sides of the slider sort of like a progress bar built in.
I will upload changes soon.
Harold Bamford wrote:
And while I'm asking dumb questions, why do you use the DC for the parent window rather than the current window?
The parent DC holds the background image we use to make the control transparent.
Nic
|
|
|
|
|
I got the first post!
This is a very cool class, (almost) exactly what I need.
It's "almost" because I've found one thing I wish it could do for me.
The background bitmap of my dialog changes while the program is running (so it's not just set once and that's it). So obviously, I would like the background image the slider saves to be changed. Unfortunetaly, the old background image, behind the sliderctrl, is still shown when I change to the new background.
GDI is NOT something I know well, but I tried to do this myself, but I couldn't. I tried deleting/clearing m_dcBk and m_bmpBk , but that didn't work, as well as some other funky things that created all kinds of ASSERT failures.
Any help would be greatly appreciated!
Thanks.
|
|
|
|
|