Hallo, First of all: thanx for the messageboard, and thanx to the people who post & reply. Now my problem: edit controls and related stuff: 1) When the user enters an invalid floating-point number into an edit control, I replace the text in the edit control using SendDlgItemText (the main window is a dialog box) but Windows automatically puts the caret to the front of the edit control, but I dont want that. How can I keep the caret position the same? I've tried GetCaretPos & SetCaretPos but it didnt work. 2) If the text IS valid, I use StrToFloat, do some calculating, and then FloatToStr. Now, if I display the resulting text in a MessageBox, everything is fine, same goes if I do 'invoke SendMessage, hWnd, WM_SETTEXT, 0, ADDR szText' to change the dialog box's title. But if I try to set the second edit control with this text (ie GetDlgItem, SetDlgItemText) I get a kernel32 error, and soon have to restart my comp because everything else stuffs up. What's up with that?!? 3) Final Q. So far, I can make the file size of the exe pretty small, but how can I make it even smaller? Assuming I've written the tightest possible sourcecode (ha ha, unlikely) is there anything else I can do to make it even smaller? Ie. compiler directive, hacking the PE, whatever. Thanx.
Posted on 2001-01-28 04:46:00 by Dee-Jon Bryce
1. send EM_SETSEL with wParam==-1 and lParam==0. This will place the caret at the end of the text 2. this implies a bug in your prog. It's not a normal behavior. You must help yourself in this case, I'm afraid. 3. Play with the PE file
Posted on 2001-01-28 05:25:00 by Iczelion
when you say you call GetDlgItem, SetDlgItemText, you shoudn't have to These following do exactky the same thing: 1) invoke GetDlgItem ,hDlg,100 invoke SengMessage ,eax,WM_SETTEXT,NULL,ADDR szText 2) invoke SendDlgItemMessage ,hDlg,100,WM_SETTEXT,NULL,ADDR szText 3) invoke SetDlgItemText ,hDlg,100,ADDR szText As you can see, 2 is a slightly more refined version of 1, and 3 is a slightly more refined version of 2. For some funny reason, if you had code like this invoke GetDlgItem ,hDlg,100 invoke SetDlgItemText ,eax,100,ADDR szText windows might not perform any error checking on the hDlg param of SetDlgItemText, thus, it could end up corrupting something in kernel32, etc
Posted on 2001-01-28 06:24:00 by X
Thanx for the help, I figured out why i got a kernel32 error: I was sending SetDlgItemText message inside a EN_UPDATE message (so i could immediately update another edit control when the user makes a keystroke) but SetDlgItemText itself sent an EN_UPDATE, and it went on again and again until a Stack Overflow occured (the error in kernel32). Silly me.
Posted on 2001-01-29 08:14:00 by Dee-Jon Bryce
Here is how to determine caracter position after which a caret is in both NT and 9x. And set caret on some position caracter index oriented: (next time inform of what OS you use, please, will you? edit implementation on NT and 9x is somewhat quite different) 1.Before you perform the replace operation get caret per caracter index position by sending to edit control EM_GETSEL. EM_GETSEL wParam = (WPARAM) (LPDWORD) lpdwStart; // receives starting position lParam = (LPARAM) (LPDWORD) lpdwEnd; // receives ending position Either there is or not any selected text variable addressed by lParam will recieve index of the caracter after which the caret is. 2. Save it. 3.Then perform replacement. 4. Then, to put caret at the same position (caracter index) as it was before replacement send EM_GETSEL and use as wParam and lParam the same variable - what you get to lpdwEnd at step one. 5. Then use EM_SCROLLCARET .data? endpos dd ? ... .code ..... invoke SendMessage,hWndEdit,EM_GETSEL,addr endpos,addr endpos .... here is code for replacement ... invoke SendMessage,hWndEdit,EM_SETSEL,endpos,endpos invoke SendMessage,hWndEdit,EM_SCROLLCARET,0,0 It will do... The Svin.
Posted on 2001-01-29 10:26:00 by The Svin