1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

using drawtext()

Discussion in 'MFC' started by palz, Jan 21, 2010.

  1. palz

    palz New Member

    Joined:
    Jan 13, 2010
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    India
    i have used DrawText() to display time init.i have used DT_CENTER which is display time in center even if window is minimised or maximised.

    but how to display it to right side of window but not on the minimise,maximise and close buttons.

    i tried DT_RIGHT =it is displaying on those 3 buttons (minimise,maximise and close buttons)

    Code:
     	     void CMainFrame::OnTimer(UINT_PTR nIDEvent)
                {
    	         HWND hWnd;
                     hWnd = ::GetForegroundWindow();
    	         CWnd *pWnd;
    	         pWnd = CWnd::FromHandle(hWnd);
    	         CTime Time = CTime::GetCurrentTime();
    	         CString strTime=Time.Format("%H:%M:%S");
    
    	         CWindowDC dc(this);
                     CRect rect;
    	         GetClientRect(&rect);
    
                     dc.DrawText(strTime,-1,&rect,DT_CENTER);
                   
                     //pWnd->SetWindowText(strTime);
    
                } 
    
    also i am not able to display time on ActiveWIndow (GetForegroundWindow()) if i use DrawText() .

    If i use pWnd->SetWindowText(strTime) ,time is displayed on ActiveWindow(GetForegroundWindow()).

    what is the problem.
    plzzzzzz help me solve this problem
     
    Last edited by a moderator: Jan 22, 2010

Share This Page