473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Passing BackColor Values Between .NET and VB6 applications

Hi,

Here's my question first and then some information about what my problem is. Anyone know how or have a function/module/class/whatever to convert from argb to rgb?

We have quite a few vb6 applications that are all called from another vb6 application called the navigator. It's kind of like using explorer. Basically we have two "modes" in the navigator. One is test and one is production. When in test the back color is an ugly orange (just to alert the user they're in test mode) and production is just the typical gray. So when the navigator is told to call an application it writes a bunch of properties to a file for the called application to pick up and apply. One of those properties is backcolor. Well colors must be handled quite differently between vb6 and .net.

In the called application (vb6) the code I use to set backcolor is frmParticipants.BackColor = RetrieveProperty("BackColor"). For the orange test mode the value is 33023. Well in .net I can't specify a color that way. When I send that same orange color property to the called program I use Me.BackColor.ToArgb.ToString and that sends a value of -32768 which the vb6 application doesn't like.

Through some more digging I realized that colors from vb.net are stored as argb and in vb6 it's rgb. I don't really understand what the "a" does in argb other than cause me a headache :-/. I do not want to have to go into each vb6 application and make any changes to convert from argb to rgb so I need to do this on the .net side. Anyone know how or have a function/module/class/whatever to convert from argb to rgb? I guess that's my question in a nutshell.

Thanks,

Jesse
Nov 20 '05 #1
3 3954
Jesse wrote:
Hi,

Here's my question first and then some information about what my
problem is. Anyone know how or have a function/module/class/whatever
to convert from argb to rgb?


I don't have VB6 here so I can't check, but from the value you give it
appears the order in VB6 is actually BGR, not RGB! This figures
because -32768 in two's complement is FFFF8000 hex, but 33023 is 0080FF hex.
(on a side note, long live the Windows Calculator)

In any case, the alpha value is transparancy. A value of FF (255) is
completely opaque. The only way to solve this is to construct the VB6 number
yourself. If you have a variable C of type Color you can do this as follows:
Dim BGR as Integer
BGR = (C.B << 16) + (C.G << 8) + C.R

The otherway around is of course just reversing the above formula, using
bitwise and to get rid of the unnecessary bits where needed.
C.B = BGR >> 16
C.G = BGR >> 8 And &hff
C.R = BGR And &hff

Hope this helps.

--
Sven Groot
Nov 20 '05 #2
Even easier, you can go from VB6 to VB.Net using:

System.Drawing.ColorTranslator.FromOle()

It takes an Int32 and return a Color
Nov 20 '05 #3
Thanks Chris. That's the easiest way that I've found. I just did System.Drawing.ColorTranslator.ToOle(Me.BackColor) .ToString to convert the .net backcolor to a color that vb6 likes. So now as I convert all of those vb6 apps to .net I'm going to have to do me.backcolor = System.Drawing.ColorTranslator.FromOle(IntColorPas sedIn). Then once all my vb6 apps are converted then I can just pass the colors across without any converting.

Jesse
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PeteCresswell | last post by:
Users want negative values to have a yellow background. No problem on the subforms where every value is a discreet field, but I can't figure out how to make it happen on a continuous form where...
5
by: DC Gringo | last post by:
I've got a command button to submit a value from a dropdown list that should then filter a SELECT query. I'm simply appending a WHERE colx = <variableSelectedFromDropdownList>. How do I pass this...
2
by: D Sheldon | last post by:
I've created a server control that builds a table. I've exposed a public property that can change the background color of the table. When I compile the control and try to use it in a project, I am...
3
by: A Ward | last post by:
I am trying to find a way to have multiple seperate ASP.Net applications where I can response.redirect() to a second web application and pass information. From what I have tried: * HTTP-GET - I...
2
by: Roy | last post by:
Hey all, Is it possible to pass session variables between pages in separate projects? For example: inetpub\thisproject\blah.aspx has a session variable and response.redirects the user to...
1
by: Firewalker | last post by:
I am attempting to change the backColor property on the previously instantiated buttons FROM a listbox_doubleClick event. I thought it would be something like this: If...
13
by: anonymike | last post by:
Hello, I started working with the ObjectDataSource today. I have the select, and have been working on getting the update method to work. Here is the asp code for my Data source: ...
8
by: preeti13 | last post by:
I have a datagrid with a hyperlink field. It passes a parameter but I need it to pass two. I need two of the parameters to be querystrings but I have no idea how to add them the hyperlink column if...
4
Vkas
by: Vkas | last post by:
HELLO!!!!!!!!!!!!! me using ASP.net 2.0, language VB.net! working tool Visula studio.Net 2005 I HAVE CREATED A simple WEB User control (calender.ascx) having a text box , a button, and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.