Sign in to follow this  
Followers 0
jpm

Background Of Label Control

6 posts in this topic

I want to be able to have specific background color of a label control.

I modified the handling of WM_CTLCOLORSTATIC in application.cpp

case WM_CTLCOLORSTATIC:
     g_oGUI.SetColor((HDC) wParam, (HWND) lParam);
    /*  if (g_oGUI.m_nBackground != -1)
     {
    SetBkColor((HDC)wParam, g_oGUI.m_nBackground);
     }
     else
    SetBkColor((HDC)wParam,GetSysColor(COLOR_BTNFACE));
    */

and add special code in the gui class

void  CGuiBox::SetColor(HDC hdc, HWND hWnd)
{ 
    int nColor = GetSysColor(COLOR_BTNFACE);
    if (m_nBackground != -1)
  nColor= m_nBackground;

    int i= GetControlID(hWnd);
    if (i>0)
    {
  if (GUICtrl[i].nBackColor>0)
     nColor = GUICtrl[i].nBackColor;

  if (GUICtrl[i].nTextColor>0)
     SetTextColor(hdc, GUICtrl[i].nTextColor);
    }
    SetBkColor(hdc, nColor);

} // SetColor

I get the following result which does not fill the complete control area

the label have been created with the default value

Posted Image

Opt("GuiCoordMode", 2)

GUICreate("My GUI") ; will create a dialog box that when displayed is centered
GUICreateEx("",0xFFFFFF)

GUISetControl("label", "label1", 0,0,100,300)
GUISetControlEx(-1,-1,$GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM, "", 0x0,0xFF0000)
GUISetControl("label", "label2", 0,-1)
GUISetControlEx(-1,-1,$GUI_DOCKTOP+$GUI_DOCKBOTTOM, "", 0xFF,0xFF00)
GuiWaitClose()

I need some help in this last feature.

do I will just to create the label with special style or I need more code.?

Share this post


Link to post
Share on other sites



I get the start of the solution 101.12?

Posted Image

Share this post


Link to post
Share on other sites

this new label color thing is french to me.... get it... ha ha.

OK, so .12 is final... now Jon needs to get this into unstable (beta) so we can have it released before May.

Lar.

Sorry English speaking people difficult to do your flag with just labels.

Larry,

Do you think it is possible to put label on label? I cannot have the latest defined displayed.

Share this post


Link to post
Share on other sites

I need to massage the source. is uploaded?

I do it

Share this post


Link to post
Share on other sites

Upload of the source done. you get GUIcolor.au3 to find out what is good or not.

Thanks Larry.

Share this post


Link to post
Share on other sites

in controlex() I did this...

if (GUICtrl[m_iCurCtrl].cType == GUI_LABEL)
    {
  if (nExt1 == -1 )
    GUICtrl[m_iCurCtrl].nTextColor = GetSysColor(COLOR_BTNTEXT);
  else
    GUICtrl[m_iCurCtrl].nTextColor = nExt1;

  if (nExt2 == -1 )
    GUICtrl[m_iCurCtrl].nBackColor = GetSysColor(COLOR_BTNFACE);
  else
    GUICtrl[m_iCurCtrl].nBackColor = nExt2;
    }

I think the GUIcolor.au3 is coded badly...

GUISetCoord(20,20)
GUISetControl("label", "label", 0,0)

or something...

if I do...

GUISetCoord(20,20)
GUISetControl("label", "label", 0,-1)

I see my label.

Thanks Larry, :whistle:

Since the source for 102 is uploaded perhahs not final but at least a good start I am going to generate 102.12

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0