Custom Tooltip Formatting - c

I am working in plain old native C on Windows. No other platforms, no C++. (Yes, I'm a dinosaur.)
I am trying to find an example of what I think of as an "owner draw tooltip control" but that does not appear to exist. At least not for the standard Windows tooltip control. I have tried to search for a library or source that implements a custom tooltip control, but all I can find is things that extend controls in .NET (or in other environments that are not where I am working.)
My hope is to support markdown (or something like it) for the text in the tooltip window. Mostly, I want to clearly differentiate the title from the content, and have some limited formatting of the content (bold, italics, color, and columns, mostly.)
I don't expect a full solution here, I am just hoping that someone else has already found a solution and can point me to where they found it. Please?

Tooltips cannot be owner drawn, but they can be "custom drawn".
Custom drawn Win32 controls allow you to override the built-in drawing by receiving and responding to the NM_CUSTOMDRAW notification. You can read about custom draw here.
You can refer to the specific documentation on the tooltip control, see:
NM_CUSTOMDRAW (tooltip) notification code
Finally, here is a good tutorial demonstrating the whole thing in C.

Related

MFC: how to render an Aero-style combo box for owner draw?

I have inherited a large MFC application which contains a CComboBox subclass that overrides OnPaint. Currently it does all its drawing by hand (with lines and rectangles), and renders a combo box that looks decidedly Windows 98-style. However, it otherwise works great and provides a lot of useful custom functionality that we rely on, and rewriting the entire control is probably not an option.
I would like to modernize it so that the OnPaint draws in Aero style where available (falling back to the old code when modern theming is unavailable). I've done this with some other custom controls we have, like buttons, and it works great for our purposes. I know there are some tiny behaviors that it won't get right, like gentle highlights on mouse-hover, but that's not a big deal for this app.
I have access to the CVisualStylesXP ckass, so I've already got the infrastructure to make calls like OpenThemeData, GetThemeColor or DrawThemeBackground pretty easily (via LoadLibrary so we don't force Vista as a min-system). Unfortunately, I don't know the proper sequence of calls to get a nice looking combo box with the theme-appropriate border and drop-down button.
Anyone know what to do here?
Honestly, I don't know why they originally tried to override OnPaint. Is there a good reason? I'm thinking that at least 99% of the time you are just going to want to override the drawing of the items in the ComboBox. For that, you can override DrawItem, MeasureItem, and CompareItem in a derived combo box to get the functionality you want. In that case, the OS will draw the non-user content specific to each OS correctly.
I think you best shot without diving in the depth of xp theming and various system metrics is take a look at this project: http://www.codeproject.com/Articles/2584/AdvComboBox-Version-2-1
Check the OnPaint of the CAdvComboBox class - there is a full implementation of the control repainting including xp theme related issues.
Not sure if it's the same situation - but when I faced this problem (in my case with subclassed CButtons), solving it only required changing the control declaration to a pointer and creating the control dynamically.
Let's assume that your subclassed control is called CComboBoxExt.
Where you had
CComboBoxExt m_cComboBoxExt;
You'll now have
CComboBoxExt* m_pcComboBoxExt;
And on the OnInitDialog of the window where the control is placed, you create it using
m_pcComboBoxExt = new CComboBoxExt();
m_pcComboBoxExt->Create(...)
Since this is now a pointer, don't forget to call DestroyWindow() and delete the pointer on termination.
This solved my particular problem - if your control is declared in the same way, consider giving it a try.

WPF Generic Search Box for a window (only View search no backend search)

I was thinking of ways to implement a generic View search. What I mean here is say a Window has many controls (including usercontrols,customcontrols, etc). I want to implement a generic search box on the top of window which searches any Text in the window and highlight them.
I wanted to know is there a generic way of doing this or has anyone tried such UI based search.
I was searching through internet and found some nice links like below::
http://khason.net/blog/search-and-highlight-any-text-on-wpf-rendered-page/ which says search and highlight any Text in WPF rendered page but it doesnt work when there are lot of UserControls and CustomControls.
I myself did some research and thought of going through the VisualTree,LogicalTree, etc but I did not find them satisfactory.
Some say do it using attached behaviors or by data binding but that also did not help me. Because even if i achieved search using this technique, the problem is highlighting. Say there are 4 TextBoxes having different background colors and I highlight background to Yellow when Text is found, I have no way of removing the highlighting when Text is not found because I don't know the previous background color of TextBox.
Ok , enough of my thoughts. I would like to simply accept I am going nowhere in my thoughts. So people I want some guidance in implementing UI search. Also if you people can tell me how I can make it generic, it will be useful!!

Blend Slider Control

Is there a free implementation of the text box in Blend's property grid that allows you to change the number by clicking and dragging? Or perhaps another way to ask is what kind of control called so I can google it?
just try this
http://www.codeproject.com/KB/WPF/MicrosoftBlendStyleTextBo.aspx
It's called a numeric UpDown control. (Terrible name, I know).
MS has a sample implementation for WPF, although I think you'll have to provide the draggable part yourself.

WinForms "mini-windows"

I need to create some mini-windows, like the ones shown in the image bellow, in my winform main form.
It would be nice if they could be draggable, resizable, and, mainly, closable.
How can I approach this design? Has anybody already seen some control (with code available) implementing something similar?
alt text http://img716.imageshack.us/img716/5765/imagea.png
A normal Form works fine for this. Set its FormBorderStyle to either FixedToolWindow or SizableToolWindow as desired.
If you want to keep your floating windows inside your main window, use MDI (Multiple Document Interface). Here is a tutorial (Google can find you many more).
Have you tried just setting the FormBorderStyle property to SizeableToolWindow?
Is that what you're after?
You can create them as resizable and draggable custom controls.
You could use my example at:
http://hourlyapps.blogspot.com/2008/07/resizable-and-movable-controls-c-net.html

Styling WPF slider background

I'm trying to apply a specific style to a slider control and I'm having trouble figuring out what I need to do for the slider's background. What do I need to do to get something like this triangle to show in the background of my slider?
I initially thought I would define a GeometryDrawing and set something in the tickbar tag to it - but I can't find anything suitable.
This is what I'm looking for. Thanks for any ideas.
Slider background http://img16.imageshack.us/img16/690/slider.png
Check out my Intuipic project, which does something similar (only horizontally):
you need to investigate a bit more into styling and templatiting in wpf. I would expect the easiest way would be to define a Control Template but you 'might' be able to achieve this with just styling
Check out this page on msdn for starters. There is probably loads of other resources out there. Big sections on it in the book i'm reading at the moment - pro wpf in c# 2008
Sorry i'm not coming up with an example... you'd be better off doing a bit of background reading and then coming back with any specific issues.

Resources