- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello,
i am trying to add an spin control on a dlg box, created by DialogBaxParam. idc_spin1 attacehed to idc_edit1 in resource editor, using autosetbuddy-arrowkeys-hotkeys style. i didnt use set buddy integer style because i want to increase and decrease in step (lets say) 0,5. i could do it in step 1,easy. but how to overcome it with real number steps?
thank you
...
real*4 x
...
case (WM_INITIALIZE)
...
hspin1=GetDlgItem(hDlg,idc,spin1)
...
iret=SendMessage(hspin1,UDM_SETRANGE,0,MakeLong(max,min))
iret=SendMessage(hspin1,UDM_SETPOS,0,MakeLong(x,0))
...
DlgProc=1
return
...
i am trying to add an spin control on a dlg box, created by DialogBaxParam. idc_spin1 attacehed to idc_edit1 in resource editor, using autosetbuddy-arrowkeys-hotkeys style. i didnt use set buddy integer style because i want to increase and decrease in step (lets say) 0,5. i could do it in step 1,easy. but how to overcome it with real number steps?
thank you
...
real*4 x
...
case (WM_INITIALIZE)
...
hspin1=GetDlgItem(hDlg,idc,spin1)
...
iret=SendMessage(hspin1,UDM_SETRANGE,0,MakeLong(max,min))
iret=SendMessage(hspin1,UDM_SETPOS,0,MakeLong(x,0))
...
DlgProc=1
return
...
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Weren't we discussing that here? You cannot set a real step/range for a spin itself, but you can make the edit box appear as if the spin is real by adding some extra logic.
Jugoslav
Jugoslav
Message Edited by intel.software.network.support on 12-09-2005 10:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i remember what we discussed there. or i think so:)
first i get the value as a character and set it in edit box. after some manipulation, i get new value and set it again in edit box. but i didnt connect it with these kind of coding. can you see? formerly, i use a spin subroutine. but now i initialize idc_spin1 in case(WM_INITIALIZE).
or should i use another function for idc_spin?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, you have to make a scaling to integer of selected float range. Let's say min=0., max=100., step=0.5. That gets
scaling = 1/step = 2
min=0.*scaling = 0,
max=200*scaling + min = 200
so, do a UDM_SETSTEP for 2, UDM_SETRANGE for (0,100). Then, handle WM_NOTIFY/UDN_DELTAPOS, calculate appropriate value (value = REAL(NM_UPDOWN%iPos) / scaling) and write that into the edit control. If you receive WM_COMMAND/EN_CHANGE from the edit control, read the text from the control, convert it to real and if it's within range, do UDM_SETPOS to appropriate value INT(value*scaling). If it's out of range, do something sensible, e.g. ifmax, set it to max.
Jugoslav
Jugoslav
scaling = 1/step = 2
min=0.*scaling = 0,
max=200*scaling + min = 200
so, do a UDM_SETSTEP for 2, UDM_SETRANGE for (0,100). Then, handle WM_NOTIFY/UDN_DELTAPOS, calculate appropriate value (value = REAL(NM_UPDOWN%iPos) / scaling) and write that into the edit control. If you receive WM_COMMAND/EN_CHANGE from the edit control, read the text from the control, convert it to real and if it's within range, do UDM_SETPOS to appropriate value INT(value*scaling). If it's out of range, do something sensible, e.g. if
Jugoslav
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
...I meant UDM_SETRANGE to (0,200), obviously. UDM_SETSTEP doesn't exist (and it shouldn't be used)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi Jugoslav,
i have been trying to figure out what you told me to do. but still complexities! see what i did;
integer*4 function DlgProc( hDlg, message, wParam, lParam )
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_DlgProc@16' :: DlgProc
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'DlgProc' :: DlgProc
!DEC$ ENDIF
use dfwin
use comctl32
use win25Globals
implicit none
integer hDlg ! window handle of the dialog box
integer message ! type of message
integer wParam ! message-specific information
integer lParam
include 'resource.fd'
! Variables
character(10) text
integer*4 iret, iErr, iPos
integer*4 hSpin1, hSpin, hEdit1
integer*4 max, min
integer*4 MaxCharacter
real*4 step, scaling, pos
logical(4) bret
type (T_NMHDR) :: iscale
pointer (lpscale, iscale)
type (T_NMUPDOWN) iUpDown
type (T_INITCOMMONCONTROLSEX) iccex
iccex%dwSize = sizeof(iccex)
iccex%dwICC = ICC_WIN95_CLASSES
call initcommoncontrolsex(iccex)
select case (message)
case (WM_INITDIALOG)
min = 0
max = 100
step = 0.5
MaxCharacter = 10
scaling = 1/step
min = 0.*scaling
max = 200*scaling + min
pos = 15.5
hSpin1 = GetDlgItem(hDlg,IDC_Spin1)
iret = SendMessage(hSpin1,UDM_SETRANGE,0,MAKELONG(0,100))
iret = SendMessage(hSpin1,UDM_SETPOS,0,MAKELONG(pos,0))
DlgProc = 1
return
case (WM_NOTIFY)
lpscale = lparam
if(iUpDown%iPos == UDN_DELTAPOS) then
hSpin = iscale%hwndFrom
iret = GetDlgItemText(hSpin1,IDC_Edit1,text,MaxCharacter)
read(text, *, iostat=iErr) Pos
if (iErr.ne.0) pos = 0.
iret = GetDlgItem(hSpin1, IDC_Spin1)
if (iPos < 25) then
Pos = Pos-0.5
else
Pos = Pos+0.5
end if
write(text, *) pos
iret = SetDlgItemText(hDlg, IDC_Edit1, adjustl(text))
!Reset back to middle position
iret = GetDlgItem(hSpin1, IDC_Spin1)
endif
DlgProc = 1
return
case (WM_COMMAND)
if (Loword(wParam).EQ.IDCANCEL.or.Loword(wParam).EQ.IDOK)then
iret = EndDialog(hDlg, TRUE)
DlgProc = 1
return
end if
if (Loword(wParam).EQ.IDC_Edit1)then
hEdit1 = GetDlgItem(hDlg,IDC_Edit1)
iret = GetDlgItemText(hEdit1,IDC_Edit1,text,MaxCharacter)
read(text,*,iostat=iErr) Pos
iret = SendMessage(hSpin1,UDM_SETPOS,0,MAKELONG(Pos,0))
DlgProc = 1
return
end if
end select
DlgProc = 0
return
end
now, even if i dont know if it will work, it gives some error messages,
Error: This derived type name has not been declared. [T_NMUPDOWN]
type (T_NMUPDOWN) iUpDown
Error: This name does not have a type, and must have an explicit type. [IUPDOWN]
if(iUpDown%iPos == UDN_DELTAPOS) then
maybe it is the same problem as in TC_ITEM (instead of TC_ITEMHEADER) structure? or what? meanwhile i still use cvf6.1.
shiptar...
i have been trying to figure out what you told me to do. but still complexities! see what i did;
integer*4 function DlgProc( hDlg, message, wParam, lParam )
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_DlgProc@16' :: DlgProc
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'DlgProc' :: DlgProc
!DEC$ ENDIF
use dfwin
use comctl32
use win25Globals
implicit none
integer hDlg ! window handle of the dialog box
integer message ! type of message
integer wParam ! message-specific information
integer lParam
include 'resource.fd'
! Variables
character(10) text
integer*4 iret, iErr, iPos
integer*4 hSpin1, hSpin, hEdit1
integer*4 max, min
integer*4 MaxCharacter
real*4 step, scaling, pos
logical(4) bret
type (T_NMHDR) :: iscale
pointer (lpscale, iscale)
type (T_NMUPDOWN) iUpDown
type (T_INITCOMMONCONTROLSEX) iccex
iccex%dwSize = sizeof(iccex)
iccex%dwICC = ICC_WIN95_CLASSES
call initcommoncontrolsex(iccex)
select case (message)
case (WM_INITDIALOG)
min = 0
max = 100
step = 0.5
MaxCharacter = 10
scaling = 1/step
min = 0.*scaling
max = 200*scaling + min
pos = 15.5
hSpin1 = GetDlgItem(hDlg,IDC_Spin1)
iret = SendMessage(hSpin1,UDM_SETRANGE,0,MAKELONG(0,100))
iret = SendMessage(hSpin1,UDM_SETPOS,0,MAKELONG(pos,0))
DlgProc = 1
return
case (WM_NOTIFY)
lpscale = lparam
if(iUpDown%iPos == UDN_DELTAPOS) then
hSpin = iscale%hwndFrom
iret = GetDlgItemText(hSpin1,IDC_Edit1,text,MaxCharacter)
read(text, *, iostat=iErr) Pos
if (iErr.ne.0) pos = 0.
iret = GetDlgItem(hSpin1, IDC_Spin1)
if (iPos < 25) then
Pos = Pos-0.5
else
Pos = Pos+0.5
end if
write(text, *) pos
iret = SetDlgItemText(hDlg, IDC_Edit1, adjustl(text))
!Reset back to middle position
iret = GetDlgItem(hSpin1, IDC_Spin1)
endif
DlgProc = 1
return
case (WM_COMMAND)
if (Loword(wParam).EQ.IDCANCEL.or.Loword(wParam).EQ.IDOK)then
iret = EndDialog(hDlg, TRUE)
DlgProc = 1
return
end if
if (Loword(wParam).EQ.IDC_Edit1)then
hEdit1 = GetDlgItem(hDlg,IDC_Edit1)
iret = GetDlgItemText(hEdit1,IDC_Edit1,text,MaxCharacter)
read(text,*,iostat=iErr) Pos
iret = SendMessage(hSpin1,UDM_SETPOS,0,MAKELONG(Pos,0))
DlgProc = 1
return
end if
end select
DlgProc = 0
return
end
now, even if i dont know if it will work, it gives some error messages,
Error: This derived type name has not been declared. [T_NMUPDOWN]
type (T_NMUPDOWN) iUpDown
Error: This name does not have a type, and must have an explicit type. [IUPDOWN]
if(iUpDown%iPos == UDN_DELTAPOS) then
maybe it is the same problem as in TC_ITEM (instead of TC_ITEMHEADER) structure? or what? meanwhile i still use cvf6.1.
shiptar...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think it's spelled T_NM_UPDOWN (note second underscore) in earlier incarnations.
In any case, you can check what's the definition on your computer by searching files in ...DF98Include folder. DFWINTY.f90 contains definitions of TYPEs and PARAMETERs, and other modules (USER32, KERNEL32) contain INTERFACEs to routines. And if it's not there, you can add your own based on CVF Win32 documentation.
Jugoslav
In any case, you can check what's the definition on your computer by searching files in ...DF98Include folder. DFWINTY.f90 contains definitions of TYPEs and PARAMETERs, and other modules (USER32, KERNEL32) contain INTERFACEs to routines. And if it's not there, you can add your own based on CVF Win32 documentation.
Jugoslav

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page