Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CEedit MFC question

CEedit MFC question

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FredrickNorge
    wrote on last edited by
    #1

    I want to display a text file , using the CEdit controller. Though i dont want the user the be able to edit the text, only mark the text if he wants to copy something. If i set the readonly parameter, it is exactly the way i want it, except its color background is greyed, i want the white. This is the code i have now: CEdit * p = static_cast(GetDlgItem(IDC_Readme)); p->SetWindowText("Text"); p->SetMargins(2,2);

    E PJ ArendsP T 3 Replies Last reply
    0
    • F FredrickNorge

      I want to display a text file , using the CEdit controller. Though i dont want the user the be able to edit the text, only mark the text if he wants to copy something. If i set the readonly parameter, it is exactly the way i want it, except its color background is greyed, i want the white. This is the code i have now: CEdit * p = static_cast(GetDlgItem(IDC_Readme)); p->SetWindowText("Text"); p->SetMargins(2,2);

      E Offline
      E Offline
      Eikthrynir
      wrote on last edited by
      #2

      You don't need to make the edit-box to be read-only. You only have to manage the WM_KEYDOWN message, like this: BOOL CTestDlg::PreTranslateMessage( MSG *pMsg ) { if ( pMsg -> message == WM_KEYDOWN ) { CEdit *p = (CEdit *) GetDlgItem( IDC_Readme ); if ( GetFocus( ) == p ) return TRUE; } return CDialog::PreTranslateMessage( pMsg ); } I don't know what is the name of your application's main dialog class. In my example it's CTestDlg. Don't forget to declare this overriden function in that class. Good luck!

      F 1 Reply Last reply
      0
      • E Eikthrynir

        You don't need to make the edit-box to be read-only. You only have to manage the WM_KEYDOWN message, like this: BOOL CTestDlg::PreTranslateMessage( MSG *pMsg ) { if ( pMsg -> message == WM_KEYDOWN ) { CEdit *p = (CEdit *) GetDlgItem( IDC_Readme ); if ( GetFocus( ) == p ) return TRUE; } return CDialog::PreTranslateMessage( pMsg ); } I don't know what is the name of your application's main dialog class. In my example it's CTestDlg. Don't forget to declare this overriden function in that class. Good luck!

        F Offline
        F Offline
        FredrickNorge
        wrote on last edited by
        #3

        thanks, worked great!

        1 Reply Last reply
        0
        • F FredrickNorge

          I want to display a text file , using the CEdit controller. Though i dont want the user the be able to edit the text, only mark the text if he wants to copy something. If i set the readonly parameter, it is exactly the way i want it, except its color background is greyed, i want the white. This is the code i have now: CEdit * p = static_cast(GetDlgItem(IDC_Readme)); p->SetWindowText("Text"); p->SetMargins(2,2);

          PJ ArendsP Offline
          PJ ArendsP Offline
          PJ Arends
          wrote on last edited by
          #4

          Handle the WM_CTLCOLORSTATIC message.


          You may be right
          I may be crazy
          -- Billy Joel --

          Within you lies the power for good, use it!!!

          Within you lies the power for good; Use it!

          1 Reply Last reply
          0
          • F FredrickNorge

            I want to display a text file , using the CEdit controller. Though i dont want the user the be able to edit the text, only mark the text if he wants to copy something. If i set the readonly parameter, it is exactly the way i want it, except its color background is greyed, i want the white. This is the code i have now: CEdit * p = static_cast(GetDlgItem(IDC_Readme)); p->SetWindowText("Text"); p->SetMargins(2,2);

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            FredrickNorge wrote:

            If i set the readonly parameter, it is exactly the way i want it, except its color background is greyed, i want the white.

            Hanle OnCtlColr message and repaint the ctrl with white color

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups