Results 1 to 8 of 8

Thread: WM_CTLCOLORSTATIC: Try #2

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024

    WM_CTLCOLORSTATIC: Try #2

    Ok the fourm is all messed up. So if this gets posted more than once I am going to be pissed

    I have this problem with changing the background color and text color of an edit box. It looks like it is no getting set right on the paint. If you look at the attached pic you will see.

    Here is the code:

    PHP Code:
    case WM_CREATE:
            {
                
    hBrush_Changes CreateSolidBrush(RGB(0,0,0));
                
    hBrush_AppInfo CreateSolidBrush(RGB(0,0,0));
                return 
    DefWindowProc(hWndmessagewParamlParam);
            }
            case 
    WM_CLOSE:
            {
                
    DeleteObject(hBrush_Changes);
                
    DeleteObject(hBrush_AppInfo);
                
    DestroyWindow(hWnd);
                
    m_hWnd_About NULL;
                break;
            }

            
            case 
    WM_CTLCOLORSTATIC:
                if ((
    HWND)lParam == m_hWnd_Changes)
                {
                    
    SetTextColor((HDC)wParamRGB(0,100,255));
                    
    SetBkMode((HDC)wParamTRANSPARENT);
                    return (
    long)hBrush_Changes;
                }
                if ((
    HWND)lParam == m_hWnd_AppInfo)
                {
                    
    SetTextColor((HDC)wParamRGB(0,100,255));
                    
    SetBkMode((HDC)wParamTRANSPARENT);
                    return (
    long)hBrush_AppInfo;
                }
            break;

            case 
    WM_PAINT:
            {
                
    BeginPaint(hWnd,&ps);
                
    EndPaint(hWnd,&ps);
                break;
            } 
    //WM_PAINT 
    Any suggestions?
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  2. #2

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Image
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    if your Edit control is not set to Read Only, then you need to move you code to the WM_CTLCOLOREDIT event instead of the WM_CTLCOLORSTATIC

  4. #4

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    No they are readonly
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  5. #5
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Juz can't anything out from your code & it seem weird 'coz i did the same thing in my application too.

    Perhaps, the problem is from where you update the text in the edit control?

  6. #6

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Well here is the rest of my code. Its not pretty because I havent finished it.

    PHP Code:
    /*###########################################################################################*/

    BOOL ShowAbout()
    {

        
    int i;

        
    CLog.LogInfo("Started ShowAbout()",TRUE,TRUE,FALSE);

        
    UnregisterClass(szAboutClass,m_hInst);

        if(!
    InitAbout())
            return 
    FALSE;

        if(!
    InitAboutInstance())
            return 
    FALSE;
        
        
    CEdit.EditWrite(m_hWnd_AppVer,"Got Mail Verison #3",TRUE);
        
    CEdit.EditWrite(m_hWnd_AppVer,"",TRUE);

        
    CEdit.EditWrite(m_hWnd_AppVer,"Main:   1",TRUE);

        
    CEdit.EditWrite(m_hWnd_AppVer,"Major:  ",FALSE);
        
    CEdit.EditWrite(m_hWnd_AppVer,MAJOR,TRUE);

        
    CEdit.EditWrite(m_hWnd_AppVer,"Build:   ",FALSE);
        
    CEdit.EditWrite(m_hWnd_AppVer,BUILD,FALSE);

        
    CEdit.EditWrite(m_hWnd_AppInfo,CHANGES,FALSE);
        
        
    CEdit.EditWrite(m_hWnd_Changes,BUGS,FALSE);
        
    CEdit.EditWrite(m_hWnd_Changes,TODO,FALSE);


        
    CLog.LogInfo("Completed ShowAbout()",TRUE,TRUE,FALSE);

        return 
    TRUE;
    }




    /*###########################################################################################*/

    BOOL InitAbout()     
    {
    /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/    
        
    WNDCLASS  wc;                                //Class
    /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/

        //Setup The Class
        
    wc.style            0;
        
    wc.cbClsExtra        0;
        
    wc.cbWndExtra        0;
        
    wc.lpfnWndProc        = (WNDPROC)AboutMainWndProc;
        
    wc.hInstance        = (HINSTANCE)m_hInst;
        
    wc.hbrBackground    = (HBRUSH)(COLOR_ACTIVEBORDER+1);
        
    wc.hIcon            LoadIcon((HINSTANCE)m_hInstMAKEINTRESOURCE(IDI_MAIL));
        
    wc.hCursor            LoadCursor(NULLIDC_ARROW);
        
    wc.lpszMenuName        NULL;
        
    wc.lpszClassName    szAboutClass;

        return 
    RegisterClass(&wc);

    }


    /*###########################################################################################*/

    BOOL InitAboutInstance()
    {
    static 
    HWND hWnd;
        
    DWORD dwFlags WS_OVERLAPPED WS_CAPTION WS_MINIMIZEBOX WS_SYSMENU;

        
    int h,w;

        
    400;
        
    400;

        
    //Create The Window
        
    hWnd CreateWindow(szAboutClass"About"dwFlags
                            
    CENTERX(w), CENTERY(h), whNULLNULLm_hInstNULL);

        
    //If The Handle Is Not Created
        
    if(!hWnd)
        {
            
    ErrorHandler("InitPopupInstance()","hWnd Was NULL.  CreateWindow May Have Failed",FALSE);
            return 
    FALSE;
        }

        
    //Put The Handle Into The Class
        
    m_hWnd_About hWnd;
        
    ShowWindow(m_hWnd_About,SW_NORMAL);

        
    hWnd NULL;
        
    dwFlags  WS_CHILD ES_MULTILINE ES_READONLY;

        
    hWnd CreateWindowEx(WS_EX_CLIENTEDGE WS_EX_NOPARENTNOTIFY
                            
    "Edit"
                            
    NULL
                            
    dwFlags
                            
    0
                            
    0
                            
    w-105,
                            
    h/4
                            
    m_hWnd_About
                            
    NULL
                            
    m_hInst
                            
    NULL);

        
    //If The Handle Is Not Created
        
    if(!hWnd)
        {
            
    ErrorHandler("InitPopupInstance()","hWnd Was NULL.  CreateWindow May Have Failed",FALSE);
            return 
    FALSE;
        }

        
    m_hWnd_AppVer hWnd;
        
    ShowWindow(m_hWnd_AppVer,SW_NORMAL);

        
    dwFlags  WS_CHILD ES_MULTILINE WS_HSCROLL WS_VSCROLL ES_AUTOHSCROLL ES_AUTOVSCROLL ES_READONLY;
        
    hWnd NULL;

        
    hWnd CreateWindowEx(WS_EX_CLIENTEDGE WS_EX_NOPARENTNOTIFY
                            
    "Edit"
                            
    NULL
                            
    dwFlags
                            
    0
                            
    h/4
                            
    w-5,
                            ((
    h-(h/4))-30)/2
                            
    m_hWnd_About
                            
    NULL
                            
    m_hInst
                            
    NULL);

        
    //If The Handle Is Not Created
        
    if(!hWnd)
        {
            
    ErrorHandler("InitPopupInstance()","hWnd Was NULL.  CreateWindow May Have Failed",FALSE);
            return 
    FALSE;
        }

        
    m_hWnd_AppInfo hWnd;
        
    ShowWindow(m_hWnd_AppInfo,SW_NORMAL);

        
    dwFlags  WS_CHILD ES_MULTILINE WS_HSCROLL WS_VSCROLL ES_AUTOHSCROLL ES_AUTOVSCROLL ES_READONLY;
        
    hWnd NULL;

        
    hWnd CreateWindowEx(WS_EX_CLIENTEDGE WS_EX_NOPARENTNOTIFY
                            
    "Edit"
                            
    NULL
                            
    dwFlags
                            
    0
                            (
    h-(((h-(h/4)))/2))-16
                            
    w-5,
                            ((
    h-(h/4))-30)/2
                            
    m_hWnd_About
                            
    NULL
                            
    m_hInst
                            
    NULL);

        
    //If The Handle Is Not Created
        
    if(!hWnd)
        {
            
    ErrorHandler("InitPopupInstance()","hWnd Was NULL.  CreateWindow May Have Failed",FALSE);
            return 
    FALSE;
        }

        
    m_hWnd_Changes hWnd;
        
    ShowWindow(m_hWnd_Changes,SW_NORMAL);


        
    hWnd NULL;

        
    hWnd CreateWindow("Button""Send Log"BS_PUSHBUTTON WS_CHILDw-1052510025m_hWnd_About, (HMENU)BTNLOGm_hInstNULL);
        
        
    //If The Handle Is Not Created
        
    if(!hWnd)
        {
            
    ErrorHandler("InitPopupInstance()","hWnd Was NULL.  CreateWindow May Have Failed",FALSE);
            return 
    FALSE;
        }

        
    m_hWnd_Btn_Log hWnd;
        
    ShowWindow(m_hWnd_Btn_Log,SW_NORMAL);

        
    UpdateWindow(m_hWnd_About);

        return 
    TRUE;

    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  7. #7
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    I copy all your code into a new project except those CEdit section and it work fine.

    I guest the problem is not on WM_CTLCOLORSTATIC but is somewhere else.

  8. #8

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Bah
    Well if I could I would post the entire project, but it requires Novell GW to run.

    Oh well I guess I will just have to keep working on the problem.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width