|
But it appeared just recently, it had worked for years before
|
|
|
|
|
I can only assume that something has been corrupted somewhere. But as I said before, it's impossible to guess what. Your only chance is to collect all the information that you can, and report it to Microsoft.
|
|
|
|
|
How can I get the CListCtrl scrollbar rectangle ? Whether the scrollbar is visible or not, I tested in following way:
if(GetStyle() & WS_VSCROLL)
{
}
but, in order to change the scrollbar background by DrawThemeBackground[^], I need the scrollbar rectangle ... how can I retrieve the scrollbar rectangle ?
|
|
|
|
|
|
Thank you Jochen ... the rectangle is retrieve it ...
I have to dig in, because it seems that something is wrong in my code, because though rectangle is correct now, the color of scrollbar is not drawn ...
void CGridCtrlExt::OnDraw(CDC* pDC)
{
HTHEME hTheme = OpenThemeData(m_hWnd, L"WINDOW");
if(NULL != hTheme)
{
if(WS_VSCROLL & GetStyle())
{
SCROLLBARINFO si;
si.cbSize = sizeof(SCROLLBARINFO);
GetScrollBarInfo(OBJID_VSCROLL, &si);
CRect rect(si.rcScrollBar);
pDC->FillSolidRect(&rect, RGB(255, 255, 0));
DrawThemeBackground(hTheme, pDC->GetSafeHdc(), WP_VERTSCROLL, VSS_NORMAL, &rect, NULL);
}
CloseThemeData(hTheme);
}
}
|
|
|
|
|
This may be because the scroll bar is redrawn by the system.
You may use a custom drawn scroll bar or handle WM_CTLCOLOR when you only need to change the background.
Searching the web may give you some solutions. The article http://www.drdobbs.com/windows/developing-a-custom-windows-scrollbar-in/184416659[^] is rather old but contains a good introduction and shows how to implement a custom drawn scroll bar.
|
|
|
|
|
"You may use a custom drawn scroll bar or handle WM_CTLCOLOR when you only need to change the background"
I already tried that ... if I override WM_CTLCOLOR I could color everything, except scrollbars ...
"Searching the web may give you some solutions. The article http://www.drdobbs.com/windows/developing-a-custom-windows-scrollbar-in/184416659[^] is rather old but contains a good introduction and shows how to implement a custom drawn scroll bar."
I saw that article, but is about replacing the original scrollbar with CScrollBarEx control ... well, in this case I will front with 2 issues: hiding the original scrollbar, and second, synchronize the listctrl with CScrollbarEx control ... I think that is the longest road ... and the hardest ...
I thought that trying to use DrawThemeBackground I could change the scrollbars colors ... I am working on that for weeks ... I have to dig in ...
|
|
|
|
|
"This may be because the scroll bar is redrawn by the system"
I wonder if I put properly the scrollbar coloring code ... inside of CMyControl::OnDraw is ok ? I guess not ...
|
|
|
|
|
OnDraw is a CView member function. You probably mean some kind of custom / owner draw. But this won't work for the scroll bars of list controls because only the list control content can be changed by this method. The scroll bar is still drawn by the system when necessary and your drawing vanishes.
If handling WM_CTLCOLOR did not work (and I believe meanwhile that it does not work with list controls), the only solution is using a complety custom drawn control or another GUI framework like Qt.
|
|
|
|
|
Thank you so much for your attention Jochen !
In the real situation, I used an CGridCtrl, and this control has CGridCtrl::OnDraw to drawing itself ... but there is no difference between this kind of control or CListCtrl, or CListBox ... I had tried to change the color of the scrollbars of these last ones and I didn't succeded ...
After all, CGridCtrl is derived from CWnd, so is the same matter ... Should be a chance to move that code on some handler that is called after the system is redrawing the scrollbars ? ... who knows ...
I should dig in ...
modified 23-Jan-15 8:47am.
|
|
|
|
|
Hello,
Is it possible to retrieve module state information (AFX_MODULE_STATE) of a regular DLL (MFC shared) that is loaded in an MFC application from within the EXE?
Thank you very much in advance
|
|
|
|
|
can anybody tell me how to design in C
|
|
|
|
|
Pretty much like you would design in any procedural language. You know C supports structured programming[^].
[edit]
Fixed the link, thanks to Richard Andrew x64
[/edit]
modified 20-Jan-15 11:09am.
|
|
|
|
|
Link is broken.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Did you mean to link to a page about "banking industry jargon?" If so, then the link works.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
OOOOPS
and double OOOOOOOOOPS .
Fixed the link, thanks.
|
|
|
|
|
This isn't bugzilla!
|
|
|
|
|
Designs are usually language neutral.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
We use the standard CMFCRibbonBar class to implement a ribbon consisting of a drop down 'File' menu followed by some tabs to select the ribbon panels. Our 'File' menu has a vertical list of menu items, on hte left side of the drop down menu, and on the right side, a recent file list:
Recent Documents
1 FileA
2 FileB
3 FileC
We want to extend this as we have recent documents and recent folders:
Recent Documents
1 FileA
2 FileB
3 FileC
Recent Folders
1 FolderA
2 FolderAB
3 FolderAC
Is anyone aware of any previous implementations of this that I can use? Or any hints as to the easiest/best way to do this?
Obviously we can add menu items to the File menu for 'Recent Documents' and 'Recent Folders', and this would work, but it is not the preferred choice.
Thanks.
|
|
|
|
|
As far as I can see the ribbon code does not allow what we want without making significant changes to the code. So I'll use a standard sub-menu.
Does anyone know how to dynamically add a sub-menu item with no icons, and the text left aligned? I always get a space for the icon i.e. the text is moved right by a significant distance, even though I pass -1 for the icon indices.
|
|
|
|
|
Just in case anyone else wants to do this, I can't for the life of me work out how to left align the menu item, so I created a custom button and overrode the OnDraw method.
|
|
|
|
|
I would like to get better grasp on how C++ class is instantiated / initialized.
Here is a part of what I assume relevant code I like to have help with.
The USBHost class has a method "Task" which is basically a state machine and I am currently trying to figure out how is this state machine "advanced".
Before I can get to that I need better understanding how is the class initialized.
I have put my basic questions as comments to this code snippet.
If someone can also apply descriptive terminology and / or explain the syntax it would be nice, but nothing elaborate.
Appreciate your time.
Thanks
Vaclav
static uint32_t usb_error = 0; // is (global) static initialized to 0 as default anyway?
static uint32_t usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; // this state is not defined as 0 - this is OK
/**
* \brief USBHost class constructor.
*/
USBHost::USBHost() : bmHubPre(0) // may be a default USB hub 0 , not sure
{
usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; // why "initialized " again here?
init();
}
/**
* \brief Initialize USBHost class.
*/
void USBHost::init()
{
devConfigIndex = 0; // USB (device ?) default index
bmHubPre = 0; // is this necessary? see constructor parameter
}
|
|
|
|
|
static uint32_t usb_error = 0;
Don't care about what the compiler does. Variables that may be read before they are written should be always initialized.
usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
The variable will probably changed by the class. When creating another instance, the value is not the initial one.
bmHubPre = 0;
The variable is set in the constructor but the init function may be called multiple times.
Overall this is a bad example. When using global static variables with a class, you must ensure that only one instance of the class exists. To detect multiple instances some kind of check should be implemented. For your class this can be done by moving the re-initialization of usb_task_state to the destructor and checking the value in the constructor:
ASSERT(usb_task_state == USB_DETACHED_SUBSTATE_INITIALIZE);
Generally there is no need to use a class when that uses global static variables. When global variables are really necessary, they should be at least members of the class:
class USBHost
{
protected:
static uint32_t usb_error;
static uint32_t usb_task_state;
}
uint32_t USBHost::usb_error = 0;
uint32_t USBHost::usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
|
|
|
|