setscrollinfo npos within the last page - winapi

I have a problem (or misunderstanding) with the WinAPI SetScrollInfo
If I set it with the following scrollinfo struct
cbSize=28
fMask=4
nMin=0
nMax=30
nPage=12
nPos=20
nTrackPos=0
The result that comes back is 19 and not 20 ?
I'm trying to make a custom scroll bar for a grid
The nPage relates to the number of visible rows
Maybe I've misunderstood nPages's use and that is what is preventing me from setting nPos to anything other than <19
Ultimately it obviously needs to get to 30 in this case
Thanks in advance

Related

OSX - How to tell if cursor is visible

I understand that this question has already been answered:
Detect if cursor is hidden on Mac OS X
But at this point, the function "CGCursorIsVisible" has been deprecated. According to the help literature, there is no replacement.
https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/c/func/CGCursorIsVisible
When using the hide and show functions (CGDisplayHideCursor / CGDisplayShowCursor), no reference to the cursor's visibility is returned. Although a show / hide counter is maintained by quartz, there's no way of accessing that value.
So, how do we find out if the cursor is visible or not?
I ran into the very same problem and could not find a valid answer to this problem.
I solved it by implementing a counter which is set to 0 when my application starts. I increase it everytime I hide the cursor and then I can unhide while the _counter != 0.
Your Mac seems to have an own counter for each application... So if your application is not in foreground and it uses the [NSCursor hide] command, it will still be visible but become invisible, when your app becomes keyWindow again.
I know it is a little bit late, but I recently stumbled upon a similar issue. One way to solve this problem is to push an empty cursor onto the cursor stack instead of calling NSCursor.hide() like this:
let myCursor = NSCursor.init(image: NSImage.init(size: NSSize(width: 1, height: 1)), hotSpot: NSPoint(x: 0, y: 0))
myCursor.set()
At a later point in time you can then just push the normal arrow cursor with NSCursor.arrow.set() or NScursor.arrow.push().
This way you don't have the issue of keeping track of the hide/unhide count.
Theoretically you should also be able to check the reference of NSCursor.current against myCursor and see if you still have the invisible cursor (I have not checked this though).

How to get constant feedback from a slider in Xcode with ApplescriptObjC?

I'm new to ApplescriptObjC as you'll probably see if you keep reading. I was wondering how to get constant feedback from a slider so that as soon as its value is 1 it runs script A and as soon as its value is changed to 0, it runs script B.
I know you can have actions for buttons like:
on buttonClicked_(sender)
do action
end buttonClicked_
But how can I have a one that constantly checks for a change in the slider's value and does the appropriate action? Is it similar to connecting a slider to a text box with the getStringValueFrom() thing?
Any help would be appreciated. Thanks :)
Found out how!
turns out on action_(sender) will work for sliders as well. They send the signal every time the item is clicked on and released whether a change exists or not. Then its a simple matter of an if statement to run two different series of actions depending on the value the slider was set to.

SlickGrid vertical scroll bar not displaying properly unless the filter is displayed/hidden to re-size the viewport

I'm just starting to use SlickGrid but I've had a lot of success creating a remote model that can interact with the paging plugin. The only problem I have seems to be a browser issue, but I'm curious if anyone knows a trick that may resolve the issue.
I'm retrieving the data page by page in my model via AJAX and updating the grid with the grid.setData() and grid.render() methods.
The problem I would like to solve is that when the length of data changes the vertical scroll bar gets really confused, unless I change the current visibility of the filter panel (grid.hideTopPanel() or grid.showTopPanel()). By confused I mean that the scroll handle in the scroll bar doesn't change size to indicate the different number of rows that are now current, and if the list grows, the scroll handle size jumps all over the place as I scroll up and down.
I'm assuming the "fix" works because it forces the browser to recalculate the view port height, but is there any way to force that to happen? Or is there a better way to do what I'm trying to do?
Ok mleibman straightened me out, what I actually was looking for was grid.updateRowCount(). I believe he will be adding a call to this in grid.setData(), but for now just make sure the 2 method calls are used together.
Have you tried grid.invalidate() ? Im my experience that forces the grid to recalculate pretty much everything. It may be more heavy-handed than you need but at least you can see if a complete invalidate solves the problem.
I figured it out. You need to call grid.resizeCanvas() after calling grid.setData(). It seems like this should be part of the grid.setData() method because a call to it will change the number of rows. But anyway, that's what you need to do.

Width property of form is not what it's set to, though looks OK

The form's borderstyle is "fixed single" so the user cannot alter the form's dimensions manually.
There is a menu item that allows the user to select 1 of 2 width settings for the form, choosing wide (width = 11715) displays extra controls.
During the load event a sub is called to set various values and which includes this code:
If rs.Fields("ShowAll").Value = True then
Me.Width = 11715
During the form unload event a sub is called to record the settings for the next time and which includes this code:
If Me.Width = 11715 Then
rs.Fields("ShowAll").Value = True
Else
rs.Fields("ShowAll").Value = False
End If
One user has reported a situation where even though he always closes with the form "wide" it always opens "narrow".
I have never seen this happen before and nobody has ever reported it either, which is not to say it's not happening elsewhere.
His machine is windows 7 and his screen resolution is 1280 X 1024.
Edit :
Also when I checked his database the value for "ShowAll" is False.
I suggest using a form level boolean variable rather than a specific number. You can also wrap it in a property if you like to make it easier to understand. Initialize the variable with the database value when you load your app and toggle the value when the button is clicked to choose the form size.
Private m_blnExpanded As Boolean
Private Property Let Expanded(ByVal vExpanded As Boolean)
m_blnExpanded = vExpanded
End Property
Private Property Get Expanded() As Boolean
Expanded = m_blnExpanded
End Property
If you are going to hard-code the width then you have to choose a number of twips that is multiple of 15 for small-fonts and multiple of 12 for large-fonts. The least multiple of both is 60, so the closest to your hard-coded value is 11700 which is 780px in small-fonts and 975px in large-fonts exactly.
Mind that win7 comes with more DPI sizes besides 96 (aka "small-fonts") and 120 (aka "large-fonts"), which totally fail VB6 forms subsystem. So you are safe to assume that in VB6 pixel size is either 15 or 12 twips.

Win32 List-View Control SubItem padding for custom-drawn SubItems?

When using custom-draw (NM_CUSTOMDRAW) to draw the entire contents of a ListView SubItem (in Report/Details view), it would be nice to be able to apply the same left and right
padding in my custom paint method that is applied by the control itself for non-custom-drawn items.
Is there a way to programmatically retrieve this padding value? Is it
related to the width of a particular character (" " or "w" or something?) or
is it a fixed value (6px on left and 3px on right or something) or...?
EDIT: To clarify, I want to add the same padding to my NM_CUSTOMDRAWn SubItems that the control adds to items that it draws, and the metric that I'm looking for, for example, is the white space between the beginning of the 2nd column and the word "Siamese" in the following screenshot (Note: screenshot from MSDN added to help explain my question):
(source: microsoft.com)
Note that the word "Siamese" is aligned with the header item ("Breed"). I would like to be able to guarantee the same alignment for custom-drawn items.
use ListView Header message HDM_GETBITMAPMARGIN
see link text
ListView_GetSubItemRect (LVM_GETSUBITEMTECT)
http://msdn.microsoft.com/en-us/library/ms930172.aspx
Despite what the documentation says I suspect LVIR_LABEL returns just the returns the bounding rectangle of the item text, as per ListView_GetItemRect.
(This just kept niggling me as I though I had actually seen an answer somewhere when playing with NM_CUSTOMDRAW).
Edit After Comment 2:
I imagine you have seen NMLVCUSTOMDRAW which if you are willing to use Version 6.0. has rcText. I wouldn't since I use Win2K.
Given what you have found I would go back to the suggestion of using
ListView_GetItemRect to get LVIR_LABEL and compare that with LVIR_BOUNDS and use the difference.
the way for doing this is retrieving the format of the corresponding column with
ListView_GetColumn()
then check the retrieved myLVCOLUMN.mask
LVCOLUMN myLVCOLUMN;
myLVCOLUMN.mask=LVCF_FMT;
ListView_GetColumn(hwnd,nCol,&myLVCOLUMN);
then when we draw the corresponding label belonging to that column
if(myLVCOLUMN.fmt & LVCFMT_CENTER)
DrawText(x,x,x,x, DT_CENTER | DT_WORD_ELLIPSIS );
else if (myLVCOLUMN.fmt & LVCFMT_RIGHT)
DrawText(x,x,x,x, DT_RIGHT | DT_WORD_ELLIPSIS );
else
DrawText(x,x,x,x, DT_LEFT | DT_WORD_ELLIPSIS );
I would assume that GetSystemMetrics() is that you need to look at. I think that SM_CXEDGE and SM_CYEDGE are probably the values you want, but don't quote me on that. ;-)
Can only guess without seeing your output.
A few suggestions: If you are using the DrawTextEx function, have you have experimented with DT_INTERNAL et al?
Are you accidentally putting in a blank image/icon.
Does it look ok in classic screen mode? If so I would look at XP Theme functions to see if some thing is going on.
Late edit after first comment:
I wonder if the size of rectangle matches the space required for the LVN_ENDLABELEDIT edit box around the text so the text doesn't move (or for a focus rectangle)?
I guess you could compare the result of LVM_GETITEMRECT with LVIR_LABEL on the first column and use the difference as your left border.

Resources