Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

IFLOGM dialog scroll bar position problem

andrew_4619
Honored Contributor III
1,452 Views

I was making an update to my last remaining program that uses IFLOGM for dialogs rather than the Windows SDK. Consider the small routine below which gets the handle for a list box on a modeless dialog, gets the min / max range of the vertical scroll bar and then sets the current position to the max position such that you can see the info that has been put there.

This works fine in that the 'get' returns the correct values, and 'set' returns with the correct position before the update, however irrespective of where the slider thumb was or has been set to the dialog is always then displayed with the thumb moved to position zero. IE my set has no effect. 

Is my code wrong? Is it just a 'feature' of the IFLOGM implementation of dialogs? Is there a simple alternative method?

Any ideas would be appreciated. Best Regards, Andrew 

subroutine update_scroll_pos()
    use             :: ifwin, only: bool, LPINT, GetScrollRange, TRUE, SetScrollPos, &
                                    SB_VERT, SINT, GetDlgItem, handle, SB_CTL
    use             :: dku, only: gdlg, IDC_LIST_MESG
    use, intrinsic  :: iso_c_binding, only: c_loc
    implicit none
    integer(handle) :: Hwnd
    integer(bool)   :: bret
    integer         :: ipmin, ipmax 
    integer(SINT)   :: ipos
    hwnd = GetDlgItem(gdlg%hwnd,IDC_LIST_MESG)
    bret = GetScrollRange( Hwnd, SB_VERT, &
                           transfer(C_loc(ipmin),hwnd),&
                           transfer(C_loc(ipmax),hwnd)     )
    if(bret /= 0) ipos = SetScrollPos( Hwnd, SB_VERT, int(ipmax, sint) , TRUE )
end subroutine update_scroll_pos 

 

0 Kudos
11 Replies
Steven_L_Intel1
Employee
1,452 Views

I'm confused. There's no IFLOGM code in this subroutine - all the calls are to Windows API routines.

Or perhaps you've (invisibly to what you posted) extracted the handle to the IFLOGM control and are using these APIs to modify it. I see that MSDN suggests using SetScrollInfo instead of SetScrollPos - did you try that? But I am not sure this is supposed to work at all - the IFLOGM code believes it knows where the position is and it will reset it the next time it sends a message to the control.

0 Kudos
andrew_4619
Honored Contributor III
1,452 Views

The dialog is created by IFLOGM (dlgmodeless), gdlg is of type dialog. I haven't rechecked but there never used to be any options for moving scroll bar positions hence the use of the sdk.

It doesn't respond to the positioning routine above and if the slider it is manually positioned and another line is added the unsorted list box the slider always gets reset to the top position. Quite annoying as the thing added cannot then be seen. 

0 Kudos
Steven_L_Intel1
Employee
1,452 Views

Right - IFLOGM will reset the position to what it thinks it is.  From what I can see in the code (and you can follow along in IFLOGM.f90), the control will be reset the next time IFLOGM sends it a message.

   case (ctrl_scrollbar)
    scrollInfo % Size = SIZEOF(scrollInfo)
    scrollInfo % Mask = SIF_ALL
    scrollInfo % Min = dlg % list(index) % intvalue(5)
    scrollInfo % Max = dlg % list(index) % intvalue(2)
    scrollInfo % Pos = dlg % list(index) % intvalue(1)
    scrollInfo % Page = dlg % list(index) % intvalue(4)
    dummyi = DlgSendMessage( hwndControl, SBM_SETSCROLLINFO, &
       1, loc(scrollInfo))
    ! Note: EnableScrollBar is called after SBM_SETSCROLLINFO
    !       Otherwise disabling does not work.
      if (dlg % list(index) % logvalue(1)) then
      dummyL = EnableScrollBar( hwndControl, SB_CTL, ESB_ENABLE_BOTH)
    else
      dummyL = EnableScrollBar( hwndControl, SB_CTL, ESB_DISABLE_BOTH)
    end if

 

0 Kudos
andrew_4619
Honored Contributor III
1,452 Views

Steve Lionel (Intel) wrote:
I see that MSDN suggests using SetScrollInfo instead of SetScrollPos - did you try that? 

Funny you should say that because a few minutes ago I looked at some old code and it would seem I adjusted a slider position on a quickwin child window using get/SetScrollInfo it would seem. I was just about to give it a whirl....

0 Kudos
Steven_L_Intel1
Employee
1,452 Views

I don't think it will help - if you look at the code I posted, which is used when IFLOGM wants to update its controls, it sets the position to a value from the dialog structure (one that is private so you don't have access to it.)

0 Kudos
Steven_L_Intel1
Employee
1,452 Views

Or... try calling DLGSET with an index of dlg_position and the position you want for the value.

0 Kudos
andrew_4619
Honored Contributor III
1,452 Views

It would appear that when you add and item to the list the scroll position gets set to Min irrespective of what you do as a user so I will ignore this problem for now.

 As it is a one dialog application doing via the sdk will not take long when I update this code next.... 

0 Kudos
andrew_4619
Honored Contributor III
1,452 Views

DLGSET / dlg_position works with slider controls but not with the side bar on a list box control.

 

0 Kudos
Anthony_Richards
New Contributor I
1,452 Views

There is a list box message LB_SETCURSEL which, when issued with the item number should bring the selected item into view, thus automatically setting the vertical scroll bar.

0 Kudos
andrew_4619
Honored Contributor III
1,452 Views

Anthony Richards wrote:

There is a list box message LB_SETCURSEL which, when issued with the item number should bring the selected item into view, thus automatically setting the vertical scroll bar.

Yes sending messages would work on an SDK dialog but a IFLOGM dialogs have some intel message processing layer and changing the position programmatically or by user input does not help as it keeps getting reset to the top when other events happen. I have given up with this and will just convert it to run via the SDK when I next work on it.

 

 

0 Kudos
Anthony_Richards
New Contributor I
1,452 Views

Have you tried sub-classing the dialog just to handle list box messages?

0 Kudos
Reply