How do I retreive the background color from a control? - winapi

How can I retrieve the background color from a given control?
I'm looking for as general a solution as possible, including the default colors of a control. Is it possible to do this?
The closest I have gotten so far is the find of GetPixel(), but I realize it's far from a perfect solution. If I have text or something over the control -- that basically all controls have, it leads to the wrong result.

Related

Is there a way to manually scroll a large image in PowerPoint?

Preview of what I'm looking for
Hello, I'm looking for a way to manually scroll a large image in PowerPoint. In the image there's an example of what I'm looking for. I want to have a preview of the image that I can scroll through and the actual image that moves accordingly to the scrollbar.
Thanks!
I assume you want this in SlideShowView? For sure this can be achieved only by scripting. Essentially you would have to program buttons for up and down movements and use vba do apply this to the image. The preview is a bit more complicated since you would have to do some math too to achieve the conversion in the size differences. All in all a job for a programmer. Are you looking for programming support here?

What system color to use to highlight required fields in delphi/windows

a bit background
I am currently using the clHighlight color together with a StyleServices.GetSystemColor call to set the background color of controls that are:
not focused
have a NULL value (field.IsNull=True)
and are about a required field (field.required=True)
Its not about how to do the highlighting itself, I figured that out already.
Currently I am using system color clHighlight, but this makes confuses my users as they think the entire contents of the field is selected (see screenshot).
But I also have style support implemented, so using a custom predefined color is not really what I am looking for. after googling a bit I found quite a list here https://learn.microsoft.com/en-us/dotnet/api/system.windows.systemcolors?view=netframework-4.7.2 but I am unable to find what I am looking for.
Using RAD studio Rio 10.3.1 Enterprise.
The actual question
So - what system color should I use? (not really looking for subjective suggestions, but for a more or less "officially recommended" constant to use.)
a screenshot
Answer: There is no more or less system color constant defined for this specific purpose.
Solution/workaround:
Thanks all for the suggestions. I decided to go for the clInfoBk constant (background color for hint windows), this looks far less confusing. One could interpret the color as a "hint" for fields that need to be filled out.
And it looks like this, in the default color scheme:

Box keeps resizing Interface Builder

Still a n00b (sorry) and I wondered if there is a solution this rather simple quandry which I cannot find an answer for (probably because it is so simple).
Basically I have a label which is inside a custom box. When I change the box size and then hit run the box size changes back to another random annoying size. It sounds simple enough but can I change it so that it sticks to the definitions I set. I have a series of labels and it would be great if the layout were the same. Thanks.
Turn off 'Live Autoresizing' in the menu.

Get the word under the mouse cursor in Windows

Greetings everyone,
A friend and I are discussing the possibility of a new project: A translation program that will pop up a translation whenever you hover over any word in any control, even static, non-editable ones. I know there are many browser plugins to do this sort of thing on webpages; we're thinking about how we would do it system-wide (on Windows).
Of course, the key difficulty is figuring out the word the user is hovering over. I'm aware of MSAA and Automation, but as far as I can tell, those things only allow you to get the entire contents of a control, not the specific word the mouse is over.
I stumbled upon this (proprietary) application that does pretty much exactly what we want to do: http://www.gettranslateit.com/
Somehow they are able to get the exact word the user is hovering over in almost any application (It seems to have trouble in a few apps, notably Windows Explorer). It even grabs text out of obviously custom-drawn controls, somehow. At first I thought it must be using OCR. But even when I shrink the font so far down that the text becomes a completely unreadable blob, it can still recognize words perfectly. (And yet, it doesn't recognize anything if I change the font to Wingdings. But maybe that's by design?)
Any ideas as to how it's achieving this seemingly impossible task?
EDIT: It doesn't work with Wingdings, but it does work with some other nonsense fonts, so I've confirmed it can't be OCR.
You could capture the GDI calls that output text to the display, and then figure out which word's bounding box the cursor falls in.
Well, for GDI controls you can get the position and size of the control, and you can usually get the font info. For example, with static text controls you'd use WM_GETFONT. Then once you have that you can get the position of the mouse relative to the position of the control and use one of the font functions, perhaps something like GetTextExtentPoint32 to figure out what is under the cursor. I'm pretty sure the answer lies in that direction...
You can run dumpbin /imports on the other application and see what APIs they are calling.

Visual Metaphor for Inversion

Before you throw me out into the cold with your bold assertions that this is not programming related, please hear me out.
I'm looking for a visual metaphor (Icon) to suggest the idea of inversion of a filter. So if a user has a filter which reduces a list of 10 items to 4, I want a button that will allow the user to invert the filter to display only the other 6.
Another wrinkle is that the UI will also have a button for removing the filter nearby.
While this certainly isn't a nuts-and-bolts programming question, I think it's relevant to the process of software creation. As a developer it's relatively easy to construct the mechanisms to perform complex filters, but it's all for naught if normal users find the presentation confusing.
If an icon doesn't jump to mind for you, then there probably isn't one that will have obvious meaning to your users either. You're better off using a text label for this.
If it must be an icon, then it doesn't matter much what it is, since users won't be able to guess it any way, but at least try to make it visually distinct and memorable if not particularly intuitive. MS Access uses a funnel to represent "filtering." Maybe use an upside-down or white-on-black funnel for inversion? (An X'ed-out funnel means "don't filter").
Whatever. Like I said, it doesn't matter much.
Maybe it's not the most appropriate, but what about the logical inverter icon?
Maybe something like this: Invert Selection?
If you really need an image, I'd suggest looking at image editing programs like GIMP or Photoshop and seeing how their "invert selection" buttons look.
16x16 pixels is enough to draw two small list boxes with an arced arrow going from one to the other where the second has an inverted selection list of the first.
alt text http://img524.imageshack.us/img524/6782/4092009000139am.png
I think the 3 icons above could be used in one spot with each user click causing a rotation through the 3 of them. I think the above icon set offers the following benefits:
F - clearly communicates it is for a filter control.
Red and Green - clearly communicate ON and OFF action.
The line above F means inversion (I think - based on memories of boolean algebra at university - I could be wrong?)
The use of yellow while still maintaining the F, links the new action (filter inverted) to the previous filter actions let still communicates it is different to the filter simply being turned on or off.
On icon click rotation could be, (starting) Red - Green - Yellow - Red. This is a widely understood rotation pattern that the user would quickly pick-up. Therefore no need for additional filter on/off button.
Simpler solution - a user only needs to look at a single icon (even perhaps only with peripheral vision) to deduce the current state of the control.

Resources