1. [WIN32LIB] Transparent Labels

Hello everyone!

I have a quick question.  I am working on a project, but not in Euphoria 
due to the fact that I haven't been able to create a transparent label 
using win32lib.ew.  The basic idea is that the main form has, as a 
background, an image.  The labels are placed on top of this image, and 
ideally, the image would be seen through the label, so that the text 
would appear to be written directly on top of the background image. 
 Yes, I suppose I could use putsw to write the text directly on the form 
using wPuts(), but I am worried about a "flashing" effect, as most of 
the text would need to be updated once per second, and a few every 1/8 
second, so this might be a little better achieved via a transparent 
label and setText().

I've been able to do this with Borland C++, using VCL and transparent 
labels, but I would much, MUCH rather write this application in Euphoria.

Any ideas?


Travis Beaty
Mason City, Iowa

new topic     » topic index » view message » categorize

2. Re: [WIN32LIB] Transparent Labels

Create your OWN label! Look into PatRat's Transparent Window Library, I believe
it's in the
Archive. Use this to create a small transparent window, then use wPuts() to put
the text on the
label only during an onPaint event, to minimize flickering. I believe this
should work, although
I've never tried it.


----- Original Message -----
From: Travis Beaty <t_beaty at mchsi.com>
Subject: [WIN32LIB] Transparent Labels



Hello everyone!

I have a quick question.  I am working on a project, but not in Euphoria
due to the fact that I haven't been able to create a transparent label
using win32lib.ew.  The basic idea is that the main form has, as a
background, an image.  The labels are placed on top of this image, and
ideally, the image would be seen through the label, so that the text
would appear to be written directly on top of the background image.
 Yes, I suppose I could use putsw to write the text directly on the form
using wPuts(), but I am worried about a "flashing" effect, as most of
the text would need to be updated once per second, and a few every 1/8
second, so this might be a little better achieved via a transparent
label and setText().

I've been able to do this with Borland C++, using VCL and transparent
labels, but I would much, MUCH rather write this application in Euphoria.

Any ideas?


Travis Beaty
Mason City, Iowa



TOPICA - Start your own email discussion group. FREE!

new topic     » goto parent     » topic index » view message » categorize

3. Re: [WIN32LIB] Transparent Labels

Hello Greg!

Thanks for the response.  I looked in the archive for the code that you 
mentioned, but the only thing I could find by PatRat that  might be 
close to what I need is his "Alpha Blending" library, which uses Windows 
2000's alpha blending feature.  That sticks me out a little, because I'm 
still (for the time being) using Windows ME.  Even if I were using XP or 
Windows 2000, using this library could limit my users to those two 
particular versions.

Perhaps I should explain a little better what I am doing.  There are two 
problem elements to this main form.  First of all, there is a time and 
date label, which sits above the background image (which fills the 
entire window).  The time label in particular needs to be updated once 
per second to properly update the seconds display.   (I can easy get out 
of updating the date display by simply checking when hour = 0, and 
updating the date then.)

Secondly, along the left side of the window, there are seven labels 
which display characters, sort of the "Matrix" style.  These characters 
start off at a font size of 5,  and are increased by 5 points every 
1/8th of a second, until it reaches a size of 20.  This presents the 
illusion of the character growing inside the label.  This is the control 
that I am most worried about flashing and choking, but I think I can get 
away with it in win32lib.ew given abundant calls to doEvents().

If I *do* end up having to manually draw these characters on the window 
using wPuts(), perhaps I can find a way to just repaint the effected 
areas as opposed to the entire window.

Thanks,

Travis Beaty
Mason City, Iowa.



Greg Haberek wrote:

>
>Create your OWN label! Look into PatRat's Transparent Window Library, I believe
>it's in the
>Archive. Use this to create a small transparent window, then use wPuts() to put
>the text on the
>label only during an onPaint event, to minimize flickering. I believe this
>should work, although
>I've never tried it.
>

new topic     » goto parent     » topic index » view message » categorize

4. Re: [WIN32LIB] Transparent Labels

Sorry, the name of the libary is  "Irregular Windows Library" although I've been
having trouble
downloading it, both from RapidEuphoria.com as well as PatRat's site,
Rat-Software.com

----- Original Message -----
From: Travis Beaty <t_beaty at mchsi.com>
Subject: Re: [WIN32LIB] Transparent Labels



Hello Greg!

Thanks for the response.  I looked in the archive for the code that you
mentioned, but the only thing I could find by PatRat that  might be
close to what I need is his "Alpha Blending" library, which uses Windows
2000's alpha blending feature.  That sticks me out a little, because I'm
still (for the time being) using Windows ME.  Even if I were using XP or
Windows 2000, using this library could limit my users to those two
particular versions.

Perhaps I should explain a little better what I am doing.  There are two
problem elements to this main form.  First of all, there is a time and
date label, which sits above the background image (which fills the
entire window).  The time label in particular needs to be updated once
per second to properly update the seconds display.   (I can easy get out
of updating the date display by simply checking when hour = 0, and
updating the date then.)

Secondly, along the left side of the window, there are seven labels
which display characters, sort of the "Matrix" style.  These characters
start off at a font size of 5,  and are increased by 5 points every
1/8th of a second, until it reaches a size of 20.  This presents the
illusion of the character growing inside the label.  This is the control
that I am most worried about flashing and choking, but I think I can get
away with it in win32lib.ew given abundant calls to doEvents().

If I *do* end up having to manually draw these characters on the window
using wPuts(), perhaps I can find a way to just repaint the effected
areas as opposed to the entire window.

Thanks,

Travis Beaty
Mason City, Iowa.



Greg Haberek wrote:

>
>Create your OWN label! Look into PatRat's Transparent Window Library, I believe
>it's in the
>Archive. Use this to create a small transparent window, then use wPuts() to put
>the text on the
>label only during an onPaint event, to minimize flickering. I believe this
>should work,
although
>I've never tried it.
>



TOPICA - Start your own email discussion group. FREE!

new topic     » goto parent     » topic index » view message » categorize

5. Re: [WIN32LIB] Transparent Labels

On Mon, 10 Mar 2003 18:51:43 -0500, <thomas at columbus.rr.com> wrote:

>
> The first solution that popped into my mind when I read your message was
> to make use of a back buffer. This would involve drawing all of your
> text to a picture (pixmap?) in the background then copying that back
> buffer to your window all at once. This would eliminate the flashing of
> text labels for the most part.
>
> It's less complicated than managing a fleet of semi-transparent floating
> text labels, no?
>
> ~Tom
>
> -----Original Message-----
> From: Travis Beaty [mailto:t_beaty at mchsi.com] Sent: Monday, March 10, 
> 2003 3:01 PM
> To: EUforum
> Subject: [WIN32LIB] Transparent Labels
>
> Hello everyone!
>
> I have a quick question.  I am working on a project, but not in Euphoria
>
> due to the fact that I haven't been able to create a transparent label 
> using win32lib.ew.  The basic idea is that the main form has, as a 
> background, an image.  The labels are placed on top of this image, and 
> ideally, the image would be seen through the label, so that the text 
> would appear to be written directly on top of the background image. Yes, 
> I suppose I could use putsw to write the text directly on the form
>
> using wPuts(), but I am worried about a "flashing" effect, as most of the 
> text would need to be updated once per second, and a few every 1/8 
> second, so this might be a little better achieved via a transparent label 
> and setText().
>
> I've been able to do this with Borland C++, using VCL and transparent 
> labels, but I would much, MUCH rather write this application in
> Euphoria.
>
> Any ideas?

There is no reason why you can't use win32lib. All you have to do is create 
an owner-drawn window and manage all the drawing yourself.

I really must take the time to knock up a demo of this technique.

-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

6. Re: [WIN32LIB] Transparent Labels

Here you go... I already told you this in the chatroom, but I though I might 
as well share it.

Use this code as the Paint routine of the label you want to be transparent:

global procedure PaintTransparentLabel(atom hWnd)
    atom client_rect, szText, pFont, pOldFont, dwStyle, dwText, void,len

    atom dc -- device context for painting
    hWnd = getHandle(hWnd)
    dc = w32Func(xGetDC, {hWnd})

    -- Where to draw text
    client_rect = allocate(16)
    void = w32Func(xGetClientRect, {hWnd, client_rect})

    -- Get the caption
    len = w32Func(xGetWindowTextLength, {hWnd})
    szText = allocate(len)
    void = w32Func(xGetWindowText, {hWnd, szText, len})

    -- Get the font
    pFont = w32Func(xSendMessage, {hWnd, WM_GETFONT, 0, 0})
    pOldFont = w32Func(xSelectObject, {dc, pFont})

    -- Map "Static Styles" to "Text Styles"
    dwStyle = w32Func(xGetWindowLong, {hWnd, GWL_STYLE})
    dwText = 0
    if and_bits(dwStyle, SS_RIGHT) then
        dwText = or_bits(dwText, DT_RIGHT)
    end if
    if and_bits(dwStyle, SS_CENTER) then
        dwText = or_bits(dwText, DT_CENTER)
    end if
    if and_bits(dwStyle, SS_CENTERIMAGE) then
        dwText = or_all({dwText, DT_VCENTER, DT_SINGLELINE})
    end if
    if and_bits(dwStyle, SS_NOPREFIX) then
        dwText = or_bits(dwText, DT_NOPREFIX)
    end if
    if and_bits(dwStyle, SS_WORDELLIPSIS) then
        dwText = or_bits(dwText, DT_WORD_ELLIPSIS)
    end if
    if and_bits(dwStyle, SS_ENDELLIPSIS) then
        dwText = or_bits(dwText, DT_END_ELLIPSIS)
    end if
    if and_bits(dwStyle, SS_PATHELLIPSIS) then
        dwText = or_bits(dwText, DT_PATH_ELLIPSIS)
    end if

    if not(and_bits(dwStyle, or_all({SS_LEFTNOWORDWRAP, SS_CENTERIMAGE, 
SS_WORDELLIPSIS, SS_ENDELLIPSIS, SS_PATHELLIPSIS}))) then
        dwText = or_bits(dwText, DT_WORDBREAK)
    end if

    -- Set transparent background
    void = w32Func(xSetBkMode, {dc, TRANSPARENT})

    -- Draw the text
    --void = w32Func(xDrawText, {dc, szText, len - 1, client_rect, dwText})
    -- Some win32lib versions incorrectly define it as a procedure....
    -- Win32Lib v 0.58.2 seems to have it right
    w32Proc(xDrawText, {dc, szText, len - 1, client_rect, dwText})

    -- Select old font
    void = w32Func(xSelectObject, {dc, pOldFont})
    void = w32Func(xReleaseDC, {hWnd, dc})
    free(client_rect)
    free(szText)
end procedure

>From: Travis Beaty <t_beaty at mchsi.com>
>Reply-To: EUforum at topica.com
>To: EUforum <EUforum at topica.com>
>Subject: [WIN32LIB] Transparent Labels
>Date: Mon, 10 Mar 2003 14:00:56 -0600
>
>
>Hello everyone!
>
>I have a quick question.  I am working on a project, but not in Euphoria 
>due to the fact that I haven't been able to create a transparent label 
>using win32lib.ew.  The basic idea is that the main form has, as a 
>background, an image.  The labels are placed on top of this image, and 
>ideally, the image would be seen through the label, so that the text would 
>appear to be written directly on top of the background image. Yes, I 
>suppose I could use putsw to write the text directly on the form using 
>wPuts(), but I am worried about a "flashing" effect, as most of the text 
>would need to be updated once per second, and a few every 1/8 second, so 
>this might be a little better achieved via a transparent label and 
>setText().
>
>I've been able to do this with Borland C++, using VCL and transparent 
>labels, but I would much, MUCH rather write this application in Euphoria.
>
>Any ideas?
>
>
>Travis Beaty
>Mason City, Iowa
>
>
>
>TOPICA - Start your own email discussion group. FREE!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu