Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to change color of image using code?
How to change color of image using code? [message #453605] Fri, 08 April 2005 01:37 Go to next message
Eclipse UserFriend
Originally posted by: aaa.domain.invalid

This is a multi-part message in MIME format.
--------------000504030306070909040304
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

I have a transparent image in black and white (white is transparent).

Now when I use it, I want the black area to become white (like the
colored image attached), is there some way I can do this programatically.

XOR'ing it the black against a white should cause the image to become
white but I can't get it to work.

I am putting this image on a dark blue background so the white areas
become blue but I need to somehow change the black to white.

Any ideas on how to achieve this?

-Chhil

--------------000504030306070909040304
Content-Type: image/gif;
name="black and white.gif"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="black and white.gif"

R0lGODlhYADAAIAAAAAAAP///yH5BAEAAAEALAAAAABgAMAAQAL/jA2py+0P o5zvIIqz3jzb
D4biSJZk15zoGqnsC8fyTM/mjef6zvf+DwwKh8RirVP8HTlJH3L0bO4kRKp0 Gv2grtilh5vz
asDhrGVLvk0uALaD7a6kq+3A2l6f0+Xosd75BPPXgsd0IPMnIvaVyBC36IgD OflSSHl5lAgm
qHmF+VljCTr61ml6ipoKcqkaQhqpWilqGIvBw5hqa6mo8ChXS6tldvq60Do7 eqwrembsW9pq
lfDsPI3sfHxY2meVDUEtPTy4HWh9TTH3fc4oqxdZnBcNegtfDF6Pn6+/b58N xMlLn4sV/v61
K0iPn8KFDBvS0OZwCcKJFCtavIgxo0Zh/8m81VP2UR48kMMIilxWYgNJQoC6 5XJ5gdcqmMTE
rWP5MlgznTV53lMHrF/QVyuJnjQ61OWvm7ByEsIGtRfTeKjuWLNa545Hcj9j nsP4zlzKq0D9
qeOm1WmKqeT8qCVriIXan3yiuiVzNhBEk1ye8o3hbi0ittA0wUU6rhriTorn IXScMGKovZIl
Vr6MObPmzZw7e0670dXB0DPlkg7IV7RAKKM55huI5nTp1LIpx65N+LPu3bx7 +379O0rwu7aH
S8WNPLny5cybO38OPbr06YwhbyV1fXFPoW87JvXe3XrVkN9xmS4Puji6o+th tw+/1ATx7Th1
oBxfv0d6UzQRKOBCXRh+OB3H0U758WfTbQLOR1eA9OFiIIPV+ZQbNvD1VyGB C0Ko3n4Tcrch
eCGK96CIJZKI4EjsmZgiiCce6Np9L67FVIc0XnichQbaqOGM5khVVx4eGhZO VnkZCeOHXNWI
xz0F+dVVk+tUtCRWvuD2I1BikdYWVaohGd+Kh/nx3oUNCiajkmHFJWFiaLKp 0ohnrkmhm2CS
eV5RXwDWyJtx2tVmEkf+KSRtUvilE599DRpnhmE2wSgtAG3S5V+GUgokIpcS qSKnd7KYBp2g
4iXqJwvO+ZA8qA72JIpiirFDAQA7
--------------000504030306070909040304
Content-Type: image/gif;
name="colored.gif"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="colored.gif"

R0lGODdhjwDSAPcAAAAAAAAAgACAAACAgIAAAIAAgICAAMDAwMDcwPDKpgQE BMbw8AAHAA0A
AAAAJCAdwggICAAOABsAAAAASQwMDAAUACgAAAAAbQgJK41OPxEREQAdADkA AAAAmw4OLBYW
FgAlAEkAAAAAyBEROxwcHAAvAF0AABcXRSIiIgA6AHEAAAoF/0kRERwcUykp KQBFAAAW/ysA
/yEhbFkUFDAwMABRAKAAAAAi/0MA/zE5AFYhHUcaahkyZzk5OQBhAL4AAAAx /2EA/2ooE1Mg
exZDZ0U+AS4u4kJCQgBwANwAAABA/38A/yJMZSZZFlFGBGguSUoyhQdSj2oY uJAjFU1NTQBT
/6MA/2pKEnUzbEpBmiRfYDdlC6QsFYMfsU4s/yBRtghkklVVVQCQAP8OAP8A TQBh/74A/29W
C4U5allDrShmdjZyEgJ3hTRI+JYit7AzF19fXwChAP8fAP8AqABx/98A/3df H4lHcWJPrDZu
e0R4I7BDHOnspbctfaUk4ACGlTZa7WlpaQCyAP8wAACC/3puI5RScHNWtUR1 kEiENiafAAqU
i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I
k2NJg13dXk/BtD4rJE/wRWFpvB71Yf17cbHxnXfTuQQ67V3NFc/kP5G7ffWN NxYazmv1cSLS
fd1zNI/tXd4sJc+CFTRWlKqKXMJWy4AAiq+BN82cb6Th7U7xUIlL/3aKUR45 aKj3HXJ1icid
sGzhEdLYcBQqNI7NonANbSi9Ko8iqdD5D/OrFGqsVZHkgr/kYL+t8vsqknx+ v6rMie3UF84r
cE93QKrrlIOJdn9xwl+LorjWPmvdshvaiK0tcQFwvf+YfWvXxyFP6ElvzORV muqXEE6uHunv
/EVCxvNPuoQe7wBxocMFggMLEhSI0GDCgw0v5DrwTmIWHgfkyfuXUeNGjh09 ftT47gCUFgYH
nlSY0uHChS1kiOhgcqGIhDQFylR5wSbDmAVx3vQZNNW9dDIsXgSZVCnHiyIf lGSpsidQqlOn
uoTZM+rKnFsZfvUaNmWLa+8unpVntulZtWnZvl0bV+KBdCd0dsXL1SFWqyh3 bu0btOrPwIOF
3rt2b9q0xIsbM1YM2XHkx5UpK+Zhs/Bmwj+xwtQLNq/o0GJLjzZNWnVq1qNd nijMs7NgzrRn
G8ZdO/dt3b1vt8gM+/Tw1aiejRNvjfx48dB8AfOGblv67um+q0ennv1qZpaE lydnHh78+O/l
Hcp4qVU9Yc0m2xd8LzB+h/n1aduvit+qfvf3/V8ATgTYBsqKvpgOjKlABBU8 kMEEEWwQwgcl
dNBACiW0EMIKN8SQwwtjkiELKHgYkcQSSeTBxBRRVDHFEqE48cUYXZyxRRZh XFHGHGnc0UYd
XeQRSB+DvLFGHIWEIiAAOw==
--------------000504030306070909040304--
Re: How to change color of image using code? [message #453608 is a reply to message #453605] Fri, 08 April 2005 01:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

This may not be the most helpful, but wouldn't it be easier to invert
the image and make black transparent than futz around at runtime trying
to fix it?

Bob Foster

Chhil wrote:
> Hello,
>
> I have a transparent image in black and white (white is transparent).
>
> Now when I use it, I want the black area to become white (like the
> colored image attached), is there some way I can do this programatically.
>
> XOR'ing it the black against a white should cause the image to become
> white but I can't get it to work.
>
> I am putting this image on a dark blue background so the white areas
> become blue but I need to somehow change the black to white.
>
> Any ideas on how to achieve this?
>
> -Chhil
Re: How to change color of image using code? [message #453609 is a reply to message #453608] Fri, 08 April 2005 02:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aaa.domain.invalid

Hi Bob,

But that would result in the black becoming blue (i.e. set to the
background color) and the white image background would get displayed as
it is no longer transparent. I do not see how the outcome of your
suggestion would result in the colored image I attached in my previous
email..am I missing something from your post?

-Chhil



Bob Foster wrote:
> This may not be the most helpful, but wouldn't it be easier to invert
> the image and make black transparent than futz around at runtime trying
> to fix it?
>
> Bob Foster
>
> Chhil wrote:
>
>> Hello,
>>
>> I have a transparent image in black and white (white is transparent).
>>
>> Now when I use it, I want the black area to become white (like the
>> colored image attached), is there some way I can do this programatically.
>>
>> XOR'ing it the black against a white should cause the image to become
>> white but I can't get it to work.
>>
>> I am putting this image on a dark blue background so the white areas
>> become blue but I need to somehow change the black to white.
>>
>> Any ideas on how to achieve this?
>>
>> -Chhil
Re: How to change color of image using code? [message #453753 is a reply to message #453609] Fri, 08 April 2005 16:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

This is too confusing to do with words. Show the image as it actually is
indicating the transparent color and the image as you want to see side
by side. Then I'll show you an image that will get the desired effect.

Bob

Chhil wrote:
> Hi Bob,
>
> But that would result in the black becoming blue (i.e. set to the
> background color) and the white image background would get displayed as
> it is no longer transparent. I do not see how the outcome of your
> suggestion would result in the colored image I attached in my previous
> email..am I missing something from your post?
>
> -Chhil
>
>
>
> Bob Foster wrote:
>
>> This may not be the most helpful, but wouldn't it be easier to invert
>> the image and make black transparent than futz around at runtime
>> trying to fix it?
>>
>> Bob Foster
>>
>> Chhil wrote:
>>
>>> Hello,
>>>
>>> I have a transparent image in black and white (white is transparent).
>>>
>>> Now when I use it, I want the black area to become white (like the
>>> colored image attached), is there some way I can do this
>>> programatically.
>>>
>>> XOR'ing it the black against a white should cause the image to become
>>> white but I can't get it to work.
>>>
>>> I am putting this image on a dark blue background so the white areas
>>> become blue but I need to somehow change the black to white.
>>>
>>> Any ideas on how to achieve this?
>>>
>>> -Chhil
Re: How to change color of image using code? [message #453754 is a reply to message #453753] Fri, 08 April 2005 16:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aaa.domain.invalid

Hi Bob,

Let see if this makes it clearer...
My first post contains attached images.

The black and white image is the original one that I have. The white
part in that image is transparent.

The colored image is what I would like to have.

The problem:
When I have a canvas with a blue background and put the black and white
image on it, the transparent white part displays as blue (as desired).
But I want to change the black part on the image as white.

-chhil

Bob Foster wrote:
> This is too confusing to do with words. Show the image as it actually is
> indicating the transparent color and the image as you want to see side
> by side. Then I'll show you an image that will get the desired effect.
>
> Bob
>
> Chhil wrote:
>
>> Hi Bob,
>>
>> But that would result in the black becoming blue (i.e. set to the
>> background color) and the white image background would get displayed
>> as it is no longer transparent. I do not see how the outcome of your
>> suggestion would result in the colored image I attached in my previous
>> email..am I missing something from your post?
>>
>> -Chhil
>>
>>
>>
>> Bob Foster wrote:
>>
>>> This may not be the most helpful, but wouldn't it be easier to invert
>>> the image and make black transparent than futz around at runtime
>>> trying to fix it?
>>>
>>> Bob Foster
>>>
>>> Chhil wrote:
>>>
>>>> Hello,
>>>>
>>>> I have a transparent image in black and white (white is transparent).
>>>>
>>>> Now when I use it, I want the black area to become white (like the
>>>> colored image attached), is there some way I can do this
>>>> programatically.
>>>>
>>>> XOR'ing it the black against a white should cause the image to
>>>> become white but I can't get it to work.
>>>>
>>>> I am putting this image on a dark blue background so the white areas
>>>> become blue but I need to somehow change the black to white.
>>>>
>>>> Any ideas on how to achieve this?
>>>>
>>>> -Chhil
Re: How to change color of image using code? [message #453802 is a reply to message #453754] Sat, 09 April 2005 22:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

I think what you missed from my earlier comment is that you first invert
black and white in the original image, so the current white parts are
black and vice versa, and then you make black (which was formerly white)
the transparent color. From your reply, you got only the last part.

Bob

Chhil wrote:
> Hi Bob,
>
> Let see if this makes it clearer...
> My first post contains attached images.
>
> The black and white image is the original one that I have. The white
> part in that image is transparent.
>
> The colored image is what I would like to have.
>
> The problem:
> When I have a canvas with a blue background and put the black and white
> image on it, the transparent white part displays as blue (as desired).
> But I want to change the black part on the image as white.
>
> -chhil
>
> Bob Foster wrote:
>
>> This is too confusing to do with words. Show the image as it actually
>> is indicating the transparent color and the image as you want to see
>> side by side. Then I'll show you an image that will get the desired
>> effect.
>>
>> Bob
>>
>> Chhil wrote:
>>
>>> Hi Bob,
>>>
>>> But that would result in the black becoming blue (i.e. set to the
>>> background color) and the white image background would get displayed
>>> as it is no longer transparent. I do not see how the outcome of your
>>> suggestion would result in the colored image I attached in my
>>> previous email..am I missing something from your post?
>>>
>>> -Chhil
>>>
>>>
>>>
>>> Bob Foster wrote:
>>>
>>>> This may not be the most helpful, but wouldn't it be easier to
>>>> invert the image and make black transparent than futz around at
>>>> runtime trying to fix it?
>>>>
>>>> Bob Foster
>>>>
>>>> Chhil wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I have a transparent image in black and white (white is transparent).
>>>>>
>>>>> Now when I use it, I want the black area to become white (like the
>>>>> colored image attached), is there some way I can do this
>>>>> programatically.
>>>>>
>>>>> XOR'ing it the black against a white should cause the image to
>>>>> become white but I can't get it to work.
>>>>>
>>>>> I am putting this image on a dark blue background so the white
>>>>> areas become blue but I need to somehow change the black to white.
>>>>>
>>>>> Any ideas on how to achieve this?
>>>>>
>>>>> -Chhil
Re: How to change color of image using code? [message #453803 is a reply to message #453802] Sat, 09 April 2005 23:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aaa.domain.invalid

Thanks Bob....
Thats definitely a work around (sorry I mis interpretted your first
response) but I want to make it more dynamic by doing it at runtime.
-chhil

Bob Foster wrote:
> I think what you missed from my earlier comment is that you first invert
> black and white in the original image, so the current white parts are
> black and vice versa, and then you make black (which was formerly white)
> the transparent color. From your reply, you got only the last part.
>
> Bob
>
> Chhil wrote:
>
>> Hi Bob,
>>
>> Let see if this makes it clearer...
>> My first post contains attached images.
>>
>> The black and white image is the original one that I have. The white
>> part in that image is transparent.
>>
>> The colored image is what I would like to have.
>>
>> The problem:
>> When I have a canvas with a blue background and put the black and
>> white image on it, the transparent white part displays as blue (as
>> desired). But I want to change the black part on the image as white.
>>
>> -chhil
>>
>> Bob Foster wrote:
>>
>>> This is too confusing to do with words. Show the image as it actually
>>> is indicating the transparent color and the image as you want to see
>>> side by side. Then I'll show you an image that will get the desired
>>> effect.
>>>
>>> Bob
>>>
>>> Chhil wrote:
>>>
>>>> Hi Bob,
>>>>
>>>> But that would result in the black becoming blue (i.e. set to the
>>>> background color) and the white image background would get displayed
>>>> as it is no longer transparent. I do not see how the outcome of your
>>>> suggestion would result in the colored image I attached in my
>>>> previous email..am I missing something from your post?
>>>>
>>>> -Chhil
>>>>
>>>>
>>>>
>>>> Bob Foster wrote:
>>>>
>>>>> This may not be the most helpful, but wouldn't it be easier to
>>>>> invert the image and make black transparent than futz around at
>>>>> runtime trying to fix it?
>>>>>
>>>>> Bob Foster
>>>>>
>>>>> Chhil wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I have a transparent image in black and white (white is transparent).
>>>>>>
>>>>>> Now when I use it, I want the black area to become white (like the
>>>>>> colored image attached), is there some way I can do this
>>>>>> programatically.
>>>>>>
>>>>>> XOR'ing it the black against a white should cause the image to
>>>>>> become white but I can't get it to work.
>>>>>>
>>>>>> I am putting this image on a dark blue background so the white
>>>>>> areas become blue but I need to somehow change the black to white.
>>>>>>
>>>>>> Any ideas on how to achieve this?
>>>>>>
>>>>>> -Chhil
Re: How to change color of image using code? [message #453804 is a reply to message #453803] Sat, 09 April 2005 23:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

Make it more dynamic by keeping two sets of images, one for dark
backgrounds and one for light backgrounds. If you just want to learn how
to invert colors in an image, never mind my comments. I just wouldn't do
it that way myself.

Bob

Chhil wrote:
> Thanks Bob....
> Thats definitely a work around (sorry I mis interpretted your first
> response) but I want to make it more dynamic by doing it at runtime.
> -chhil
>
> Bob Foster wrote:
>
>> I think what you missed from my earlier comment is that you first
>> invert black and white in the original image, so the current white
>> parts are black and vice versa, and then you make black (which was
>> formerly white) the transparent color. From your reply, you got only
>> the last part.
>>
>> Bob
>>
>> Chhil wrote:
>>
>>> Hi Bob,
>>>
>>> Let see if this makes it clearer...
>>> My first post contains attached images.
>>>
>>> The black and white image is the original one that I have. The white
>>> part in that image is transparent.
>>>
>>> The colored image is what I would like to have.
>>>
>>> The problem:
>>> When I have a canvas with a blue background and put the black and
>>> white image on it, the transparent white part displays as blue (as
>>> desired). But I want to change the black part on the image as white.
>>>
>>> -chhil
>>>
>>> Bob Foster wrote:
>>>
>>>> This is too confusing to do with words. Show the image as it
>>>> actually is indicating the transparent color and the image as you
>>>> want to see side by side. Then I'll show you an image that will get
>>>> the desired effect.
>>>>
>>>> Bob
>>>>
>>>> Chhil wrote:
>>>>
>>>>> Hi Bob,
>>>>>
>>>>> But that would result in the black becoming blue (i.e. set to
>>>>> the background color) and the white image background would get
>>>>> displayed as it is no longer transparent. I do not see how the
>>>>> outcome of your suggestion would result in the colored image I
>>>>> attached in my previous email..am I missing something from your post?
>>>>>
>>>>> -Chhil
>>>>>
>>>>>
>>>>>
>>>>> Bob Foster wrote:
>>>>>
>>>>>> This may not be the most helpful, but wouldn't it be easier to
>>>>>> invert the image and make black transparent than futz around at
>>>>>> runtime trying to fix it?
>>>>>>
>>>>>> Bob Foster
>>>>>>
>>>>>> Chhil wrote:
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> I have a transparent image in black and white (white is
>>>>>>> transparent).
>>>>>>>
>>>>>>> Now when I use it, I want the black area to become white (like
>>>>>>> the colored image attached), is there some way I can do this
>>>>>>> programatically.
>>>>>>>
>>>>>>> XOR'ing it the black against a white should cause the image to
>>>>>>> become white but I can't get it to work.
>>>>>>>
>>>>>>> I am putting this image on a dark blue background so the white
>>>>>>> areas become blue but I need to somehow change the black to white.
>>>>>>>
>>>>>>> Any ideas on how to achieve this?
>>>>>>>
>>>>>>> -Chhil
Re: How to change color of image using code? [message #453843 is a reply to message #453804] Mon, 11 April 2005 20:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aaa.domain.invalid

Bob Foster wrote:
> Make it more dynamic by keeping two sets of images, one for dark
> backgrounds and one for light backgrounds. If you just want to learn how
> to invert colors in an image, never mind my comments. I just wouldn't do
> it that way myself.
>
> Bob
>
> Chhil wrote:
>
>> Thanks Bob....
>> Thats definitely a work around (sorry I mis interpretted your first
>> response) but I want to make it more dynamic by doing it at runtime.
>> -chhil
>>
>> Bob Foster wrote:
>>
>>> I think what you missed from my earlier comment is that you first
>>> invert black and white in the original image, so the current white
>>> parts are black and vice versa, and then you make black (which was
>>> formerly white) the transparent color. From your reply, you got only
>>> the last part.
>>>
>>> Bob
>>>
>>> Chhil wrote:
>>>
>>>> Hi Bob,
>>>>
>>>> Let see if this makes it clearer...
>>>> My first post contains attached images.
>>>>
>>>> The black and white image is the original one that I have. The white
>>>> part in that image is transparent.
>>>>
>>>> The colored image is what I would like to have.
>>>>
>>>> The problem:
>>>> When I have a canvas with a blue background and put the black and
>>>> white image on it, the transparent white part displays as blue (as
>>>> desired). But I want to change the black part on the image as white.
>>>>
>>>> -chhil
>>>>
>>>> Bob Foster wrote:
>>>>
>>>>> This is too confusing to do with words. Show the image as it
>>>>> actually is indicating the transparent color and the image as you
>>>>> want to see side by side. Then I'll show you an image that will get
>>>>> the desired effect.
>>>>>
>>>>> Bob
>>>>>
>>>>> Chhil wrote:
>>>>>
>>>>>> Hi Bob,
>>>>>>
>>>>>> But that would result in the black becoming blue (i.e. set to
>>>>>> the background color) and the white image background would get
>>>>>> displayed as it is no longer transparent. I do not see how the
>>>>>> outcome of your suggestion would result in the colored image I
>>>>>> attached in my previous email..am I missing something from your post?
>>>>>>
>>>>>> -Chhil
>>>>>>
>>>>>>
>>>>>>
>>>>>> Bob Foster wrote:
>>>>>>
>>>>>>> This may not be the most helpful, but wouldn't it be easier to
>>>>>>> invert the image and make black transparent than futz around at
>>>>>>> runtime trying to fix it?
>>>>>>>
>>>>>>> Bob Foster
>>>>>>>
>>>>>>> Chhil wrote:
>>>>>>>
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> I have a transparent image in black and white (white is
>>>>>>>> transparent).
>>>>>>>>
>>>>>>>> Now when I use it, I want the black area to become white (like
>>>>>>>> the colored image attached), is there some way I can do this
>>>>>>>> programatically.
>>>>>>>>
>>>>>>>> XOR'ing it the black against a white should cause the image to
>>>>>>>> become white but I can't get it to work.
>>>>>>>>
>>>>>>>> I am putting this image on a dark blue background so the white
>>>>>>>> areas become blue but I need to somehow change the black to white.
>>>>>>>>
>>>>>>>> Any ideas on how to achieve this?
>>>>>>>>
>>>>>>>> -Chhil
Hello Bob,

Consider this...I have a background and foreground color for my
composite which is dynamic (user defined change based on user
selection). The image color needs to change based on the foreground
color. Hence images cannot be static and swapped in and out,the
repainting of the image becomes necessary.

How do I achieve this?

Thanks for your feedback...

Regards Murtuza
Re: How to change color of image using code? [message #453846 is a reply to message #453843] Mon, 11 April 2005 22:24 Go to previous message
Eclipse UserFriend
Originally posted by: bob.objfac.com

Chhil wrote
> Hello Bob,
>
> Consider this...I have a background and foreground color for my
> composite which is dynamic (user defined change based on user
> selection). The image color needs to change based on the foreground
> color. Hence images cannot be static and swapped in and out,the
> repainting of the image becomes necessary.
>
> How do I achieve this?

Well, why didn't you say so? I haven't done this, but I would try:
Define your image as a GIF, which will have an indexed palette. When you
want to change colors, make a new Image with a revised palette. See the
ImageData class and, e.g., Snippet139, which will show you how it is
massaged. You should need to change only one color in your example. You
might even be able to change it in place; haven't tried it.

Any more questions, please start a new thread. I'm out of answers and
others have probably stopped reading this thread by now. ;-}

Bob
Previous Topic:TreeItem Listener
Next Topic:linux copy-paste chinese to StyledText problem
Goto Forum:
  


Current Time: Fri Feb 26 18:35:36 GMT 2021

Powered by FUDForum. Page generated in 0.02560 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top