How to ignore the safe area when using keyboardLayoutGuide - uikit

I have a full screen list and want to use the new keyboardLayoutGuide constraint, but by default it uses the safe area inset. How can I disable this so my list goes all the way to the bottom of the screen when the keyboard is not shown?
NSLayoutConstraint.activate([
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor)
])

Related

WIN32: Duplicate Standard Button Control (disabled Icon / hotkey underline) in Owner Draw Button?

So for the simple feat of wanting to put an icon on the right side of button text instead of the left resulted in having to use owner draw buttons (but someone here said Custom Draw is actually available if using visual themes). Okay, fine, but now I'm finding you can't really duplicate what Windows standard buttons do when it's not in owner draw mode.
For a normal enabled button I can get the look correct by checking if visual styles are available or not and then using either the DrawThemeBackground() / DrawThemeText() or DrawFrameControl() / DrawText(). However the hot key underline character is shown even when alt key is not pressed, the default buttons don't show it until alt pressed.
For a disabled button, I can't duplicate the disabled look of the icon placed on the button. I tried DrawState() over DrawIconEx() but that looks like the old Windows 3.1 type grey graphic not the visual style dimmed graphic. I see there is a DrawThemeIcon() for an image list, I guess I could try that (I'd have to test non visual style mode to see if DrawState() matches when not using visual styles).
Also, as you hover over the button, the state doesn't change, I understand that if using owner draw, that doesn't occur, maybe it would still work with Custom Draw?
So the two main questions are:
1 - Is there something built-in to the button / owner draw to handle the underlined hotkey only when alt was pressed?
Update to Question 1: I found DT_HIDEPREFIX in DrawText() and using Custom Draw there is the CDIS_SHOWKEYBOARDCUES flag. However with Owner Draw I'm not sure if there is a flag someplace?
2 - How do you draw an icon for a button that is disabled to match what default buttons do?
TIA!!
For shortcut underline you can use WM_QUERYUISTATE to ask if it should be hidden or visible
DWORD draw_text_flags = ...;
if ( SendMessage( control_hwnd, WM_QUERYUISTATE, 0, 0 ) & UISF_HIDEACCEL ) != 0 )
{
// hide prefix
draw_text_flags |= DT_HIDEPREFIX;
}
// some combination of PBS_DEFAULTED, PBS_DISABLED, PBS_HOT, PBS_NORMAL, PBS_PRESSED;
int state = ...;
DrawThemeText( theme, hdc, BP_PUSHBUTTON, state, text, text_len, draw_text_flags, 0, rect );
Answer to Q2: If you create an HIMAGELIST using ILC_COLOR32 | ILC_MASK, and use ILD_NORMAL|ILD_BLEND25 on ImageList_Draw() it gives the same look as windows default buttons for a disabled button.
Based on responses from #Remy-Lebeau and #Daniel-Sęk and reviewing various projects on CodeProject, I create an easy to use class to handle this. It can be found at CodeProject. Thanks Guys.

Adjust windows control panel settings from command line

Is it possible to adjust windows control panel settings from the command line? The settings I'm specifically interested in are the cursor width and blink rate, which can be customized in the Ease of Access Center [1]. I think this is a registry thing, right?
Same as Control Panel Settings from Command Line but I don't think a C# solution will work for me, because what I'm actually trying to do is toggle these cursor settings from AutoHotKey.
[1] https://bltt.org/adjusting-the-windows-text-cursors-blink-rate-and-width/
You can set the blink rate with the SetCaretBlinkTime function and the AHK code might look something like this:
DllCall("User32\SetCaretBlinkTime","Uint",666)
I'm not sure if you can change the width:
The width of the caret, in logical units. If this parameter is zero, the width is set to the system-defined window border width.
You can retrieve the width or height of the system's window border by using the GetSystemMetrics function, specifying the SM_CXBORDER and SM_CYBORDER values. Using the window border width or height guarantees that the caret will be visible on a high-resolution screen.
but on the other hand SystemParametersInfo has SPI_SETCARETWIDTH but it is only documented to work on edit controls.

NormallScroll and fitToSection

I have two sections. Second section has very big height, so i marked it as "normalScrollElements". And i would like to have fullpage.js appearence between this two sections and having default browser scrollbar. Disabling fitToSection made it close, but only default browser scroll is working :(
$('.scroll-sections-wrap').fullpage({
sectionSelector: '.scroll-section',
scrollBar: true,
easing: 'easeInOutCubic',
css3: true,
easingcss3: 'ease-in-out',
scrollingSpeed: 900,
fitToSectionDelay: 500,
responsiveHeight:650,
responsiveWidth:1000,
fitToSection:false,
normalScrollElements: '#second-section-id',
verticalCentered:false,
});
Second section has very big height, so i marked it as "normalScrollElements".
That's not the way you are suppose to use normalScrollElements. Normal scroll elements is for small elements that needs to use their own scroll.
normalScrollElements: (default null) If you want to avoid the auto scroll when scrolling over some elements, this is the option you need to use. (useful for maps, scrolling divs etc.) It requires a string with the jQuery selectors for those elements. (For example: normalScrollElements: '#element1, .element2')
You should be using scrollOverflow:true:
scrollOverflow: (default false) defines whether or not to create a scroll for the section in case its content is bigger than the height of it. When set to true, your content will be wrapped by the plugin. Consider using delegation or load your other scripts in the afterRender callback. In case of setting it to true, it requires the vendor plugin jquery.slimscroll.min and it should be loaded before the fullPage.js plugin.

How to change one image with another on click and back it again on release in Delphi?

I made a set of images of piano keyboard, all in two versions - one white and second with red color. I lined all keys pictures up next to each other, first white keys, then red over them. Now I would like to hide red ones, and they need to show only when it's clicked on the certain white key, so it's needed to visually show as if it were pressed. Then back to white when it's released.
I'm also interested doing it with my midi keyboard as well, so wonder how to achieve this with midi data?
Thanks
How to achieve this depends on what Controll you use for showing the button.
If you use TImages then use OnMouseDown (http://docwiki.embarcadero.com/Libraries/XE7/en/Vcl.Controls.TControl.OnMouseDown) and OnMouseUp (http://docwiki.embarcadero.com/Libraries/XE7/en/Vcl.Controls.TControl.OnMouseUp) events.
In OnMouseDown you turn your Piano Key color to red.
In OnMouseUp you turn your Paino Key color to white.
If you decide for this approach you might also need to handle special case (user moving mouse away from key while mouse button bein pressed down).
You could achieve this with OnMouseLeave (http://docwiki.embarcadero.com/Libraries/XE7/en/Vcl.Controls.TControl.OnMouseLeave) event in which you check to see if your Piano Key is red and then change it to white.
As for general aproach for switching between pressed and unpressed key versions don't change their positions by brnging them to front or sending them back as this would screw up the clicking detections of your controlls (by default the topmost detects clicks).
Instead use one set of controls and change their image at runtime.
If you have any expirience with creating custom components you could quickly create one which will have two states and two images one for each state. So in the end you only switch between two states either with ckicks or with code.
If you don't have expirience with creating custom components please tell which components you use now and I can try making a custom version of that component with the above mentioned functionality for you.

How to place a windowless control on top of a windows control?

Say, I have an Image control (which seems to be a window-less control) and I want to make sure that it is on top of a TextBox. No matter what I do, the Image control will not appear on top of the Text box.
Is there a way?
P.S. I know I can use a PictureBox, but it does not support transparency, thus I must have the Image control.
There is no way to place an image control over a normal textbox as they are drawn onto the form itself so will always be below any other windowed components.
If you have VB6 installation media there are drawn (windowless) versions of controls including a TextBox you can use that will (probably) do what you want; http://support.microsoft.com/kb/184687
A custom usercontrol of some kind if probably better .. what is it exactly you want to overlay the textbox with?
The Image Control is considered a graphical control, like shapes, so it is always inferior to text controls. If you really want a transparent image, you can use a Microsoft 2.0 Form instead(only if you have it). Images there can be on top of textboxes, and you can make it transparent by setting the Backstyle to Transparent(0).
Completely different approach to my other answer (hence the seperate Answer), but you can set AutRedraw and ClipControls on your Form to false and it will allow the Image control to render on the same layer as a windowed control. You can get some flakey redrawing in some cases but for a quick solution you could try it.
http://msdn.microsoft.com/en-us/library/aa733621(v=vs.60)
I've created a tranparent overlay control to add a kind of annotation layer on top of a VB6 app. I'll attempt to describe it from memory, and if that doesn't provide enough information then you can post back and I'll try to dig up the code.
First, add a new USerControl to you application. Give it a name like ImageEx, PictureEx, or TransparntImage. There are several properties that you will need to use. Ensure the control is Windowed, so it can sit on top of other windowed controls. Locate the MaskColor property and set it to Cyan (or whatever color you elect to use to indicate a tranparent area. There might be an addition property enable the masking behavior, just browse the properties. Set the control background color to that of the MaskColor. At this point you have an invisible control. In my control I painted on top of the surface for annotations, but you can PaintPicture or maybe even set the image property for a really simple approach.
Of course, to make this a re-usable control, you will want to code in your own properties that allow the MaskColor and image, etc to be set so that you can the drop one of these on any form you want.
Some links:
MaskColor Property
MackPicture Property
1) Remove all your textboxes , labels and ... (But memorize their name and location in the form)
2) Go to (project > components) and mark the (Microsoft Forms 2.0 Object Library) then click ok
3) Now you can see new controls under your default controls in your toolbox...
4) Use its textbox and label controls instead of the default controls
5) Right click on your Image Control then click (Bring To Front)

Resources