MFC: Why does my spin control work backwards - visual-studio-2005

Using MS Visual Studio, I have attached a spin control to an edit control using the "auto buddy" property.
The spin control alters the edit box, but the up button decrements the value and the down button increments the value.
How do you fix this?

Because that's how it is. 8-) You work around it using SetRange.
The documentation says "The default range for the spin button has the maximum set to zero (0) and the minimum set to 100. Because the maximum value is less than the minimum value, clicking the up arrow will decrease the position and clicking the down arrow will increase it. Use CSpinButtonCtrl::SetRange to adjust these values." ...without any decent explanation.

The reason it works this way is because a spin control is just a thinly veiled scroll bar, and windows use a coordinate system where rows increase as you move down (so the down arrow increases the value).
To fix it, just interchange the min and max values you are currently useing when you call SetRange.

Related

SwapMouseButton does not "resist" a reboot

I am SwapMouseButton function to change the primary mouse button from right to left.
It seems work, the mouse buttons are swapped, and I can go check in the settings and see that they are indeed swapped...
BUT,
If I reboot the computer, the setting goes back to the original setting, undoing my programmatic swap.
Any clue as to what might be going wrong there?
Swapping the mouse buttons via code is not a permanent operation. As you have already discovered, it is reset on the next OS restart. If the user wants the buttons swapped permanently, they should be setting that in the Control Panel, not in your code.
That said, if you really want to handle this in code, then every time your app is run, have it use GetSystemMetrics(SM_SWAPBUTTON) to check if the mouse buttons are currently swapped, and if not then swap them.

How to make mouswheel switch tabs slower in sublimetext

I searched already for this for some time, but could not find a solution.
I have mouse_wheel_switches_tabs set to true, but on my system and with my mouse, when I scroll the minimal amount possible on the mousewheel, already 2 tabs are switched.
Is there a setting to make the amount, that the mousewheel advances (or goes back) in the open tabs smaller?
I do not want to change my mouse settings, because they are already adjusted to everything else.
I believe this should be adjustable, because you can never garanty that on all systems the mouse wheel has a similar pace.
I also tried to set the scroll_speed setting to values above or below 1, and also to 0, but this did not change anything.
I am on windows and I am not adding a version number, because I will happily switch to any version that can do this.
Mouse wheel is not something that is calculated in small steps, but rather it has a concrete amount of events fired for each scroll step, thus SublimeText can't do anything but receive 2 steps each time you do a scroll, this is controlled by system or your mouse, but I doubt that your mouse vendor has built a hardware that does fires two steps for this minimum amount.
So I highly doubt it's possible without changing your mouse settings. At least without tweaking the core of SublimeText, which is not possible as it's code is not open-source.

Windows Phone 8 Control has undefined or erratic behaviour on the first click/interaction

There are some controls on windows phone that behave different on the first interaction with them than on subsequent ones. e.g. a button control takes about 3-5 seconds to initialize the required action the first time the button is pressed, however on subsequent clicks it works immediately.
Another usercontrol that adjusts its height based on the key press doesn't adjust properly the first time, however the second time it works.
Is there a way to either prepare the controls, i.e. set them in a ready state so that all the clicks behave the same, or can first click can be faked to bypass this annoying behaviour?
Also what is causing this problem?
NB:- I am testing on a Lumia 520 device.
Unfortunately There is no way to prepare the controls. Nokia Lumia 520 comes in Lower Memory Device So Its behaviour seems slow at loading first time in memory and there are so many Background tasks also runnig at a same point of time. You should try it in Higher Memory Device and see the Behaviour.
I found out from this app performance document why it was happening , http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff967560(v=vs.105).aspx#BKMK_Applicationstartup.
I have a loading panel that is set to collapsed by default and only set visible once the button is clicked. According to the document, elements in collapsed state arent added to memory, so this means the first time it needs to initialize the panel and it doesnt need to in subsequent tries.
The other UI control behaving weirdly was also due to its parent's height not being adjusted after its own height is adjusted the first time, so adjusting the parent height as well fixed it.

ZedGraph scrolling left truncates data

I am using a ZedGraphControl in a WindowsForms project in C#. The ZedGraphControl is V5.1.5.
The data in the control is static and I add it all before the form is shown. The X axis of the data consists of numbers indicating seconds offset from the beginning. in other words from 0 to some number of seconds.
I want to initially show the last 5 seconds, but provide a horizontal scrollbar so the user can scroll back and forth. I set the "graphPane.XAxis.Scale.Max = maxX;" where maxX is the largest X value in my data. I set the "graphPane.XAxis.Scale.Min = maxX - 5;".
The data starts off displaying the way I want it, but when the user scrolls the horizontal bar, bizzar behavior occurs.
As you drag the thumb of the scrollbar to the left, the beginning of the data shown in the grid moves to the lower values as expected, and the thumb of the scrollbar moves to the left, but the right edge of the thumb stays at the right of the scrollbar and you cannot move back to the right. It is as if the data to the right of the viewing range gets truncated as you scroll left.
I cannot find any reason for this nor any way to control it. Does anyone have any ideas about this behavior?
Ok, found it myself.
I found a fine article that describes scrolling:
Add a ScrollBar
In it the author specifically says "the scrolling will be wacky because the scrollable range has not been set".
I used the sample "Manually Setting the Scroll Range" and the part that I was missing is setting the zedGraphControl1.ScrollMinX and zedGraphControl1.ScrollMaxX properties. Once I defined these values everything started working as expected. I also found that in my case, the value of zedGraphControl1.IsAutoScrollRange had no effect, but I left it set to false to be consistent with the example. This would probably have an effect if the dataset is dynamic.

Macro for clicking (Mac compatible)

I would like to create a macro so whenever I hold a key, it will click the current position of mouse for x amount of time and releases for y amount of time.
The only ones I have found only click and pause instead of holding down the mouse button or I am only allowed to click in intervals of a tenth of a second (I would like to be able to click in a hundredth of second or even better... a millisecond). Does anybody know any good mac compatible programs out there?

Resources