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. Disabling a CView, and darkening it

Disabling a CView, and darkening it

Scheduled Pinned Locked Moved C / C++ / MFC
databasec++helpquestion
7 Posts 2 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.
  • S Offline
    S Offline
    Sternocera
    wrote on last edited by
    #1

    Hello, I'm writing an MFC app that accesses a database. In the event of a DB user being denied access to a database object, I disable the relevant CView through an EnableWindow(FALSE) call. This works well. However, it has the potential to confuse users, who may wonder why the CView cannot be interacted with - is it a bug? Therefore, I'd like to have some obvious visual indication that the view cannot be interacted with, such as darkening it. I'm not sure how a view can be darkened. I'd be willing to settle for some other obvious visual indication if it was easier to implement. What approach is suggested? Thanks in advance, Sternocera

    D S 2 Replies Last reply
    0
    • S Sternocera

      Hello, I'm writing an MFC app that accesses a database. In the event of a DB user being denied access to a database object, I disable the relevant CView through an EnableWindow(FALSE) call. This works well. However, it has the potential to confuse users, who may wonder why the CView cannot be interacted with - is it a bug? Therefore, I'd like to have some obvious visual indication that the view cannot be interacted with, such as darkening it. I'm not sure how a view can be darkened. I'd be willing to settle for some other obvious visual indication if it was easier to implement. What approach is suggested? Thanks in advance, Sternocera

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Sternocera wrote:

      I'd be willing to settle for some other obvious visual indication if it was easier to implement.

      Are you wanting the view to be read-only (i.e., they can see records but can't edit them), or hidden?

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      S 1 Reply Last reply
      0
      • D David Crow

        Sternocera wrote:

        I'd be willing to settle for some other obvious visual indication if it was easier to implement.

        Are you wanting the view to be read-only (i.e., they can see records but can't edit them), or hidden?

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        S Offline
        S Offline
        Sternocera
        wrote on last edited by
        #3

        They can't see the records anyway - the view won't get populated. This is a database level permission. I already have the entire view non-responsive through my call to EnableWindow(FALSE) - from there, I just want a big visual cue that the view is not interactive, such as darkening the view. Thanks

        D 1 Reply Last reply
        0
        • S Sternocera

          They can't see the records anyway - the view won't get populated. This is a database level permission. I already have the entire view non-responsive through my call to EnableWindow(FALSE) - from there, I just want a big visual cue that the view is not interactive, such as darkening the view. Thanks

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Sternocera wrote:

          ...I just want a big visual cue that the view is not interactive, such as darkening the view.

          Well, you could always close the view, or create a separate view that simply contained the text, "You do not have permission..."

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          S 1 Reply Last reply
          0
          • D David Crow

            Sternocera wrote:

            ...I just want a big visual cue that the view is not interactive, such as darkening the view.

            Well, you could always close the view, or create a separate view that simply contained the text, "You do not have permission..."

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            S Offline
            S Offline
            Sternocera
            wrote on last edited by
            #5

            What does it mean to close a view? Replacing my view with another view would probably be very clunky with my existing design - I suspect I will have to do some drawing to the view. I'd rather have something that is based on the view when permission is not denied, such as a darkened version of the same thing, or overlaying of a padlock icon. That way, the user may get familiar with the general layout of the program without necessarily being able to use it all. Regards, Sternocera

            1 Reply Last reply
            0
            • S Sternocera

              Hello, I'm writing an MFC app that accesses a database. In the event of a DB user being denied access to a database object, I disable the relevant CView through an EnableWindow(FALSE) call. This works well. However, it has the potential to confuse users, who may wonder why the CView cannot be interacted with - is it a bug? Therefore, I'd like to have some obvious visual indication that the view cannot be interacted with, such as darkening it. I'm not sure how a view can be darkened. I'd be willing to settle for some other obvious visual indication if it was easier to implement. What approach is suggested? Thanks in advance, Sternocera

              S Offline
              S Offline
              Sternocera
              wrote on last edited by
              #6

              Here's how far I've got:

              void CCommonBaseView::OnDraw(CDC* pDC)
              {

              if(view\_is\_disabled)
              {
              	pDC->SetDCPenColor(RGB(0,0,0));
              	pDC->SetROP2(R2\_MERGEPEN);		
              }
              CFormView::OnDraw(pDC);
              

              }

              It ought to be possible for me to change the way that we draw to the device context through the CDC pointer, and make the CView appear different somehow - darkening it, or making it grayscale, or something else. I don't seem to be having much luck drawing to the device context after the base class implementation has been called; It just makes swathes of gray turn white. What approach is suggested? Regards, Sternocera

              S 1 Reply Last reply
              0
              • S Sternocera

                Here's how far I've got:

                void CCommonBaseView::OnDraw(CDC* pDC)
                {

                if(view\_is\_disabled)
                {
                	pDC->SetDCPenColor(RGB(0,0,0));
                	pDC->SetROP2(R2\_MERGEPEN);		
                }
                CFormView::OnDraw(pDC);
                

                }

                It ought to be possible for me to change the way that we draw to the device context through the CDC pointer, and make the CView appear different somehow - darkening it, or making it grayscale, or something else. I don't seem to be having much luck drawing to the device context after the base class implementation has been called; It just makes swathes of gray turn white. What approach is suggested? Regards, Sternocera

                S Offline
                S Offline
                Sternocera
                wrote on last edited by
                #7

                Come on guys, I'd really like to get an answer to this! How can I draw onto a CScrollView from its OnDraw() to change its appearance significantly, such as making it grayscale or darkened? Thanks, Sternocera

                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