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

cursor position in editbox after callback

lucdorpmanns
Beginner
750 Views
Hi,

In our programs we are using a callback routine to check if the input is an integer value. So when a character (or a dot etc.) is entered an error beep is generated and the wrong charcter is removed. In this callback routine we are using DLGGET to read the entered numbers and characters. This routine is called using DLG_CHANGE, so every time a character/number is entered.
After removing the wrong ones we use DLGSET to write back the corrected value. When using DLGSET in one of our projects the cursor in the editbox remains on the RIGHT (which is ok), but in another project the cursor jumps to the LEFT (which is NOT ok).
The latter one results in a "reverse" order in the edit box, when entering "23" this appears as "32" in the editbox.
We have tried to find the cause of this difference, but have not found it. The properties of the editbox (alignment etc.) are identical. We suspect the compiler options are involved but as far as we could check these are identical too.

Does anyone know wat could be the cause of this problem? We have tried to find an option which sets the (default) cursor position after calling DLGSET, but could not find it. Does this exist and if so, how can we set it?

Thanks

Luc Dorpmanns
0 Kudos
8 Replies
Jugoslav_Dujic
Valued Contributor II
750 Views
Use DlgSendCtrlMessage(EM_SETSEL) -- take a look at both entries in the Help. {Note: Docs on DlgSend... wrongly state that the 3rd argument is of type(T_MSG) -- it's an INTEGER}. See also EM_SCROLLCARET and EM_SCROLL.

Jugoslav
0 Kudos
lucdorpmanns
Beginner
750 Views
Thanks for your reaction. Using DlgSendCtrlMessages solves the problem I described, but still I do not understand why both projects behave differently. The subroutine we use to check the integer value is the same (we are using the same source file for this subroutine in both projects). I still think there has to be a setting in the projects which is different.


(We are using Compaq visual fortran professional edition 6.6.0)

Luc

0 Kudos
lucdorpmanns
Beginner
750 Views
I have to add something. The two projects I described were run on different machines (with as far as we know) the same compaq visula fortranm version. The source code for the described subroutine problem is the same.

On my machine (let call it machine A) the problem occurs in both (!) projects, while on the other machine (B) in none of the projects the problems occur. When I'm logged in on the other machine (B) the problem does not occur using the SAME project files (on the network drive)!

We are running local versions of Digital Fortran installed on the hard disk drive while our source files are placed on the network drives.
I suspect it has to be in one of the settings of my local Fortran version.
Where can I check the setting of the fortran compiler? Is there some ini-file which includes these settings? Could it be that there are different versions of the rc-compiler on both machines, and if so, how can I check this?

Luc
0 Kudos
Jugoslav_Dujic
Valued Contributor II
750 Views
I don't think you're missing anything in compiler settings. I doubt CVF itself has anything to do with it. I did a little investigation on MSDN related with edit box update and found nothing relevant. Behaviour of the caret in edit control when the text is changed on EN_CHANGE may well be undefined; that means, dependent on Windows version, Shell version (= IE version), or Phase of the Moon.

I suggest you use EM_SETSEL (with (-1,-1) parameters)consistently, to ensure the desired behaviour.

Jugoslav
0 Kudos
Jugoslav_Dujic
Valued Contributor II
750 Views
P.S. You may try DlgSendCtrlMessage(...WM_SETTEXT, 0, LOC(szText)) instead of DlgSet(...,IDC_EDIT, sText). DlgSet, being a wrapper, will eventually do the same thing (send WM_SETTEXT). If my assumption above is right, that won't change anything -- but it doesn't harm to try.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
750 Views
P.P.S. As you probably know, szText must be terminated with CHAR(0) for the purpose of WM_SETTEXT.

Also, check out the neighbouring thread "Checking a real number is entered in an edit box".

Message Edited by intel.software.network.support on 12-09-2005 11:09 AM

0 Kudos
lucdorpmanns
Beginner
750 Views
Jugoslav,

I tried your solution using EM_SETSEL, but I can't find the exact format in the help. I trie dthe following statement:

retint = DlgSendCtrlMessage(dlg,id,EM_SETSEL,-1,-1)

But it doesn't seem to work. Could you help me with this?

Thanks

Luc
0 Kudos
Jugoslav_Dujic
Valued Contributor II
750 Views
Sorry, I misread the documentation -- you cannot retrieve the last position solely by EM_SETSEL, but you have to use GetWindowTextLength as well:
Length = GetWindowTextLength(GetDlgItem(Dlg%hWnd, ID))
i = DlgSendCtrlMessage(Dlg, ID, EM_SETSEL, Length, Length)
Sorry, I don't have time to test it at the moment.
0 Kudos
Reply