 |
 |

09-08-2004, 04:29 AM
|
 |
Senior Contributor
|
|
Join Date: Jun 2003
Location: Birmingham, England, UK
Posts: 821
|
|
Transparent Mask
|
I have a form that i have subclassed and used BitBlt to draw my custom title in the title bar. (Screenshot). It basically just paints the picture from a picture box.
What i would like to do is create a transparent mask that does not paint the black areas of the custom titlebar picture(screenshot also)
How would this be possible?
|
|

09-08-2004, 08:03 AM
|
 |
Still asleep...
Retired Leader * Expert *
|
|
Join Date: Nov 2003
Location: IronForge
Posts: 2,694
|
|
You could do two blits and use a mask, or use TransparentBlt and specify a transparent color.
I tried the latter with the image you provided, and due to the anti-aliasing of the letter graphics it didn't turn out too hot.
Also, I hear TransparentBlt is prone to memory leaks in older versions of Windows (95, 98). You may want to stick with two Bitblts and a mask.
|
__________________
~ Jason
Use [vb][/vb] tags when posting code :) || Search the forum and MSDN|| Check out the Posting Guidelines
|

09-08-2004, 12:27 PM
|
|
Contributor
* Expert *
|
|
Join Date: Jul 2004
Posts: 484
|
|
For masking "ASM Editor Pro" lettering - don't use anti-aliasing
Quote:
|
Originally Posted by noi_max
I tried the latter with the image you provided, and due to the anti-aliasing of the letter graphics it didn't turn out too hot.
|
I agree with Noi_Max, you'll never get good masking with your original graphic, so I redid your bitmap to eliminate anti-aliasing. See attachment below (use the bmp, the gif is just for show..):
|
|

09-09-2004, 04:53 AM
|
 |
Junior Contributor
|
|
Join Date: Aug 2004
Location: India
Posts: 270
|
|
|
If u can't turn off Anti-aliasing,
Subclass it and get the original winow's titlebar blitted to a picturebox, print the text on it, and blit it back!
|
__________________
"I think; therefore I am."
|

09-09-2004, 05:49 AM
|
 |
Senior Contributor
|
|
Join Date: Jun 2003
Location: Birmingham, England, UK
Posts: 821
|
|
|
You could do two blits and use a mask, or us
Ok, iv'e done it!
Many thanks to noi_max for the TransparentBlt idea. Although it was astoundingly obvious.. i didnt know the function existed!
And thanks to pikzel_R for the crisp image. I've changed it now but i sorted the pic out with no anti-alias.
Thanks Guys
Jonny
|
|

09-09-2004, 07:15 AM
|
 |
Senior Contributor
|
|
Join Date: Jun 2003
Location: Birmingham, England, UK
Posts: 821
|
|
Draw ControlBox
|
Ok, ive searched the net and come up with nothing.
I have a subclassed form that i am custom-painting the caption-bar to. I am putting a custom gradient color over the top of the controlbox and i now need to force the controlbox to redraw. somehow. (or paint it myself).
and ideas?
|
|

09-09-2004, 07:31 PM
|
|
Contributor
* Expert *
|
|
Join Date: Jul 2004
Posts: 484
|
|
Subclass Form Titlebar
Quote:
|
Originally Posted by Jonny
Ok, ive searched the net and come up with nothing.
I have a subclassed form that i am custom-painting the caption-bar to. I am putting a custom gradient color over the top of the controlbox and i now need to force the controlbox to redraw. somehow. (or paint it myself).
and ideas?
|
Umm...how about you adjust your custom painting (WM_NCPAINT) so you don't draw off it in the first place?
Do you have any code that looks like:
Code:
Case vbFixedSingle
' 1 Fixed Single.
'Can include Control-menu box, title bar, Maximize button, and Minimize button.
'Resizable only using Maximize and Minimize buttons.
XBorder = GetSystemMetrics(SM_CXDLGFRAME)
DestHeight = GetSystemMetrics(SM_CYCAPTION) + 1
If FormControlBox = False Then
DestWidth = DestWidth - (XBorder * 2) + 9
Else
If FormMinButton = True Or FormMaxButton = True Then
DestWidth = DestWidth - (XBorder * 2) - _
(GetSystemMetrics(SM_CXSMSIZE) * 3) + 9
Else
DestWidth = DestWidth - (XBorder * 2) - _
(GetSystemMetrics(SM_CXSMSIZE) * 1) + 9
End If
End If
Case vbSizable
' 2 (Default) Sizable. Resizable using any of the optional border
'elements listed for setting 1.
XBorder = GetSystemMetrics(SM_CXDLGFRAME) + 1
DestHeight = GetSystemMetrics(SM_CYCAPTION) + 1
If FormControlBox = False Then
DestWidth = DestWidth - (XBorder * 2) + 9
Else
If FormMinButton = True Or FormMaxButton = True Then
DestWidth = DestWidth - (XBorder * 2) - _
(GetSystemMetrics(SM_CXSMSIZE) * 3) + 9
Else
DestWidth = DestWidth - (XBorder * 2) - _
(GetSystemMetrics(SM_CXSMSIZE) * 1) + 9
End If
End If
from this page:
http://www.thevbzone.com/modGradient.bas
Notice how the DestWidh is adjusted so it bypasses a control button paintover.
The other way is using masking, which was already covered in the last thread..
You can even get fancy and paint all the way around the control button, but there's really no reason to paint over it.
Some other references about subclassing the titlebar:
http://www.elitevb.com/content/01,0041,01/
http://www.vbaccelerator.com/home/VB...Bar_Sample.asp
|
Last edited by lebb; 09-10-2004 at 06:24 AM.
Reason: Merged threads, so removed link to other thread (now this thread)
|

09-10-2004, 06:00 AM
|
 |
Junior Contributor
|
|
Join Date: Aug 2004
Location: India
Posts: 270
|
|
|
Take care using Transparentblt on a Win98 there is a memory leak exists (still unresolved, i think!), if u r using WinNT/2K/XP then use GdiTransparentBlt instead.
In ur problem this memleak may not matter, but if u r using it to blit a large image or a large number of them, it may cause a windows General Protection Fault!
|
__________________
"I think; therefore I am."
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|