Extending clickable area of a standard Win32 button? - winapi

I have a button which, due to margins (and it looks better this way) is 3 pixels from the edge of the screen. I'd like it to highlight on mouse-over in this margin region, so that it can be clicked by moving the mouse to the side of the screen.
Is there any way to extend the clickable area of a standard Win32 button, such that the button believes its clickable area to be larger than its drawing area?

Related

WIN32: Is there a way to have the button icon (BM_SETIMAGE) on the right side of the text

Is there a way to have a button with text and graphic, with the graphic on the right side of the text, without having to owner-draw the button?
I want to just sent BM_SETIMAGE and whatever else would be needed so the graphic is to the right of the text.
Also, I noticed the image is so tight against the text that it doesn't look good. Is there a way to adjust the margin without having to use a blank space in the text?
Is there a way to have a button with text and graphic, with the graphic on the right side of the text, without having to owner-draw the button?
There are BS_LEFTTEXT and BS_RIGHTBUTTON styles available, but the documentation says they only apply to CheckBoxes and RadioButtons:
Constant
Description
BS_LEFTTEXT
Places text on the left side of the radio button or check box when combined with a radio button or check box style. Same as the BS_RIGHTBUTTON style.
BS_RIGHTBUTTON
Positions a radio button's circle or a check box's square on the right side of the button rectangle. Same as the BS_LEFTTEXT style.
For a standard push button, there does not appear to be a way to control the position of the image other than through owner-drawing.
Is there a way to adjust the margin without having to use a blank space in the text?
Use BCM_SETTEXTMARGIN/Button_SetTextMargin():
Sets the margins for drawing text in a button control.

custom checkbox needs to decide when to draw psalternate border

I'm trying to create a custom checkbox control (delphi 2010; based on tstatictext), and i can't figure how to decide if the (psalternate style) border should be drawn around the focused caption. Windows draws this border once the tab key has been pressed, and does not it if the control is focused with the mouse prior to the first tab press (after activating the parent). Any hints?

What's the proper way to scroll and clip child window in WinAPI

I have main window of my app divided into three areas (top, content, bottom). Some of controls are docked to bottom or to top and rest of controls are placed in 'content' area between top and bottom area.
If the total height of controls in 'content' area is greater than available space, some controls overlay controls docked to bottom. Similar problem occurs when I scroll up 'content' area. Some controls overlay controls docked to top.
How to limit area, where a child control(window) can be drawn? I found function SetWindowRgn(), but I'm not sure it's is the correct way, how to limit child window drawing area.
thx
The best way is to make your controls children of another child window with the WS_CLIPCHILDREN style set on it. That also makes it easy if you want to allow those separate areas to scroll independently of each other - all you have to do is reposition the child controls in response to the scroll offsets and they'll automatically be clipped to the parent window's borders.

WM_NCCALCSIZE, custom client area, and scroll bars

I have an MFC app that embeds a Scintilla text edit control. I want to customize the Scintilla control to display some custom controls next to the vertical scrollbar. Essentially, I want to render some controls in the orange area below, where the green area represent the scroll bars:
I tried overriding the WM_NCCALCSIZE message of the Scintilla window and subtracting an offset from the right side of the client rectangle. Here is the code:
void CScintillaCtrl::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
lpncsp->rgrc[0].right -= 100;
}
However, this causes the vertical and horizontal scroll bars to reposition themselves to account for the smaller client width, as shown below:
I'm not sure if this behavior is caused by Scintilla or Windows. Is there a way I can adjust the client area and preserve the positions of the scroll bars?
I found a Scintilla specific solution. I can use the SCI_SETMARGINRIGHT command to add a margin to the right side of the client area, and then render my controls inside that.

Making an NSButton resize its image (Cocoa OSX)

I could not find a way in the documentation to tell an NSButton to resize its image to fill up the whole button. Is there a way to do this programatically?
The closest you'll get is -setImageScaling: ... look up the constants to see how the image will be scaled within the button cell, given its bordered state and bezel type.
If you're looking to replace the standard button entirely with your image (ie, the button cell doesn't draw itself at all - your image serves as the entire visual representation), turn off the border (-setBordered:).
All of these options can be configured in IB as well. A tip: in IB, hover the mouse over any setting in the inspector panel - most if not all give you a hint that shows what method controls the behavior affected by the setting's control.

Resources