Suggestion wanted for MFC custom scrollbars - mfc

I want to make my own scrollbars for a custom drawn plot, like this image, what would be the best way to go?
Scrollbars should:
Only be visible when mouse hover over it (with fade in/out)
Be a part of the x/y axis of the plot, like in the picture
Not have any arrow buttons, just the thumb Thinner than the normal scrollbars
Would you suggest to:
Create everything from scratch, handling paging, scrollwheel etc.
Try to inherit CScrollBar and do my own drawing?
From what I've read, it's not very easy to customize scrollbars in MFC, for example here)

First off, these have to be scrollbar (or other) controls, not window scrollbars (used for scrolling a window).
Second, the statement "it's not very easy to customize scrollbars in MFC", is only partially true. MFC is a "thin wrapper" of Windows API, so you should better refer to the documentation of the Windows scrollbar control.
Then there is the CScrollBar class, but took a short look, and indeed, it does not really offer anything more than the Windows scrollbar does. As for the sample in the link you posted is a new (custom) control (painting everything on its own), i.e. literally "from scratch", not inheriting anything from CScrollBar.
So, you have to look into the Windows scrollbar control, and what it offers. Did take a look, and saw few things. Unfortunately there seems to be no owner-draw functionality. You can process the WM_CTLCOLORSCROLLBAR message, but this only allows you to change colors.
And according to the documentation the background color only. This appears to be the only possible customization, apart from the SBM_ENABLE_ARROWS message, which can hide the arrows. And no fading effect. If these are enough to you, you could try the Windows/MFC scrollbar, otherwise try writing your own.

Related

How to create a borderless window with titlebar in windows c++

I am trying to create a Direct3D app that is operating in windowed mode with a title bar and minimize/quit button. However, I'd really like to be able to axe the border around the window.
I am looking to do this because it looks pretty cheesy on dual monitors when the app is filling the primary monitor horizontally (with room to move the app vertically), but its window border overflows onto the secondary screen. I've tried a bunch of combinations of setwindowlong with GWL_STYLE and GWL_EXSTYLE, but can't seem to make headway unless I disable the title bar.
I've seen a bunch of apps that are borderless however they seem to emulate the title bar rather than using the built in one provided by Microsoft.
Thanks for any suggestions.
You can't remove the border and keep the titlebar AFAIK.
You can reimplement the titlebar by using WM_NCHITTEST but you still need to draw it yourself which would not be a bad idea if you want your D3D app to look its best.
Visual Studio, last time I checked, achieves its border with transparent layered windows standing behind the primary one. They are the shadows you see.

Image to display while dragging

I am implementing drag and drop of button on windows application.During dragging I want to display some dragging effect. I think image of the button would be appropriate to display during dragging.
Also I think cursor should be changed during dragging.
My doubts are:
How to capture the image of button and display while dragging.
What type of cursor should be displayed during dragging.
Application is in C++, win32.
Drag image:
If it is a standard button control then you should be able to use WM_PRINT or WM_PRINTCLIENT to ask it to draw itself to a GDI HDC (i.e. into a bitmap that you then use as the drag-image).
Note that not all controls support those messages and some of them support them in slightly different ways. Sometimes you have to experiment a bit or have custom code-paths for different controls.
Another way is to draw the button yourself using the visual styles (themes) API, with a fallback on DrawFrameControl for when themes are disabled. But that is much more tedious than using WM_PRINT/WM_PRINTCLIENT if you don't need it.
Cursor:
Depends what the operation is doing, really. Note that you get the copy and move cursors for free with the shell drag object, if you want them. Sometimes it makes sense to use a custom cursor, though.

How to write a scrollable MFC custom control?

I want to write my own chart control which requires scrolling.
I found that there is a CScrollView but nothing like this for a control.
Other toolkits like Cocoa, QT or GTK offer me a base class where i can set a content view which is displayed in a viewport and saves me from writting all of the scrolling code.
The code for custom scrolling isn't that much. Create the scrollbars, write the message handlers and remember one rectangle for the current visible part.
I would just try it. If you have problems, we are here to help :-)

Displaying a popup widget in QT over application border

Let's say that I have an application frame, and I want to show a popup QCalendarWidget over on the right side of the frame. Normally, QT will clip the edges of the QCalendarWidget, cutting it in half and not displaying the rest, as it would be over the right side border.
Is there a way to work around this limitation without resorting to implementing a QDialog?
I want the widget to be visible outside the bounds of it's container.
If you'd show your Calendar, let's say, after a button click, as QDateTimeEditor does, it's contents will not be clipped, cause it do not belong to frame. It will be just a widget, that shows in a dialog manner. And maybe you should even place it in QDialog, that is modal and provides some convenience methods, rather then simple QWidget.
Btw, why don't you want to use QDatetimeEditor?

Windows regions and transparency

I have a CDHTMLDialog in a BHO that I want to be partially transparent, in the sense that the transparent area changes according to the logic of the dialog. I got it to become transparent visually (using SetLayeredWindowAttributes), but it is critical to make this region truly transparent, because otherwise when I click on the transparent region my clicks do not reach the IE window which is below the transparent part of my dialog. I temporarily fix this by constantly resizing my dialog according to the size of the active part of the dialog, but I can't keep up with this forever...
I think the solution has something to do with what windows calls "regions" (http://msdn.microsoft.com/en-us/library/dd162915%28VS.85%29.aspx) but I'm not exactly sure how to work with them. Can anyone point me in the right direction?
I don't think you want to make parts of your window transparent, what you want to do is (I think) set the window region (like you mention). Read the MSDN on SetWindowRgn() - basically you define a GDI object of type HRGN (if you're using MFC, CRgn) which described a surface of a certain shape, and eventually with parts cut out. Windows then considers only the 'region' that you set on a window as the part of the window to use. Basically it's how you make non-rectangular windows. A 'region' isn't a 'transparent' part of a window, it's a way to discard areas of a window, in a way.
I found the way to make an entire window transparent and click-through here:
http://www.codeproject.com/KB/wtl/transparent.aspx
But it's not useful for my case where I only want the transparent part of my window (transparent by HTML/CSS definitions) to be click-through...
Update: Apparently, the clicks are supposed to go through the transparent parts (see http://jalaj.net/2007/02/05/form-with-a-hole/), but in my CDHTMLDialog they don't. My best guess is that a sub-window of the BHO catches my clicks, but I don't really think that makes much sense...