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