Stephen Lebans said:
Here is a previous post of mine on this subject. You will havew to adapt it
for your particular situation.
It works for System Color Constants(ex. vbButtonFace), COM color values and
standard RGB values as well.
Open your Form in Design view.
Open the Properties window and go to the Events Tab
For the OnLoad event click on the little arrow and select Event
Procedure
Next to the little arrow you just clicked is three small dots. Click on
these.
YOu are now looking at the class module behind the Form
1) At the very top of the Form just under these two lines add the API
declaration:
Option Compare Database
Option Explicit
Private Declare Function OleTranslateColor Lib "oleaut32.dll" _
(ByVal lOleColor As Long, ByVal lHPalette As Long, lColorRef As Long) As
Long
Now back in the Load event sub add the code to change the backcolor
property
Private Sub Form_Load()
' Save the control's original dimensions
Dim lngColor As Long
Dim lngRet As Long
lngRet = OleTranslateColor(Me.Section(acDetail).BackColor, 0&,lngColor)
Me.customerdatasheet.Form.DatasheetBackColor = lngColor
End Sub
That's it!
Hi Stephen.
My request was different unfortunatly... was not the same as in the private
mail, and this solution you give me
change Control(Datasheet) Back Color not Gray Area... ;-)
For this truble i try to give more info, with my bad english... ;-)
I use a Image(control) to draw a personal Graphic Button:
1) I create an hDC_Tmp
2) I draw graphic button with Icon and RoundedRect XP_Style with gradient
ecc....
3) With your code on(pictureBox Demo) i convert hDC trought DIB on
PictureData so i have my XP_BUTTON
In my opinion is a nice demo.
If the Image control was located on Form(every section) work very fine, i
detect Section BackColor
to give to Button trasparent aspect on Border.
Here you can find this demo, much part of it are Lebans made.
http://www.alessandrobaraldi.it/DettaglioFaq.asp?IdFAQ=290
My prboblem occur when the control is located on TabControl(not trasparent)
or over Shape(rectancle widh color).
In this case i need to find the Graphical BackColor(around the image
control) to set it into hDC_Tmp and
obtain trasparency of Corner, because my Graphical button have rounded one
as i said...!
I have no idea, so i try to capture the area around the Image control on hDC
and get Pixel color, but unforunatly this solution work good only if the
Form was just painted(it's normal)... but i need to get the color on LOAD...
Public Function GetBackColor() as Long
' m_hWndSection it's the hWnd of Image(Control) Section
Dim hDC_S As Long
Dim hDC_Tmp As Long
Dim rct As RECT
Call GetWindowRect(m_hWndSection, rct)
With rct
hDC_S = GetDC(m_hWndSection)
hDC_Tmp = GetDC(0)
' I need only ONE PIXEL NEAR IMAGE
.Left = .Left + fTwipsToPixels(m_ImgBtn.Left, 1) - 1
.Right = .Left + 1
.Top = .Top + fTwipsToPixels(m_ImgBtn.Top, 0) - 1
.Bottom = .Top + 1
Call BitBlt(hDC_Tmp, .Left, .Top, 1, 1, hDC_S, 0, 0, SRCCOPY)
GetBackColor= GetPixel(hDC_Tmp, .Left, .Top)
Debug.Print GetBackColor
End With
Call ReleaseDC(m_hWndSection, hDC_S)
Call DeleteDC(hDC_Tmp)
End Function
This is what i try to do... and work only if i execute it after form was
painted.
Probably it's a bad code... but i don't know how to solve.
I Hope is better then the first exemple of my truble.
Thanks