I'm just leaning about Win32ASM, and I'm sorry that I couldn't search this well.
As everybody sees, in the tenth example of Iczelion's tutor, it shows me these to setfocus when the dialog shows:
invoke GetDlgItem,hDlg,IDC_EDIT
invoke SetFocus,eax
It's simple to understand, but in my own program, it doesn't work.
I want to setfocus in an editbox named "Input", these are codes:
.386
.model flat,stdcall
option casemap:none
......
DlgProc proc hWnd: HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
mov eax,uMsg
.IF eax==WM_INITDIALOG
inovke GetDlgItem, hWnd, Input
invoke SetFocus, eax
......
But it doesn't work, when the dialog shows, it setfocus onto the first butten.
I read the tutor again and again, and check it again and again, but don't find where is the mistake.

I wish you won't be sick of my stupidity and laziness

Thanks
Posted on 2003-05-31 06:14:41 by pdx1989
pdx1989,

You have to put a return 0 after the SetFocus.


Regards,

Guy
Posted on 2003-05-31 07:08:59 by Guy
The problem with that is that you are setting the focus to something that isn't there yet. The WM_INITDIALOG message is sent just before the window is displayed. There is nothing on the screen to set the focus to. In order to set the focus to your Dialog, return TRUE. Make sure that the control you want focused it at the top of the Z-Order.

.IF uMsg == WM_INITDIALOG
mov eax,TRUE
ret
.ELSEIF
...
Posted on 2003-05-31 09:04:47 by donkey
Hi, pdx1989,

This is not a stupid question. It happened to me, too. I have two sections of code, handling two different dialogs. One of them works, the other doesn't.
The only difference between the two is that in the one that works, between the .IF iMsg==WM_INITDIALOG and invoke GetDlgItem I have a few more other invokes, doing different things. I guess it all has to do with the delay between the two statements.

I haven't tried it yet, but I will just insert a delay there and see what happens. It's really strange, since I can set the text and the font to that edit control, but not the focus. I found no other explanation for this behaviour.
Posted on 2003-06-02 20:55:06 by VVV
It's quite possible to set the focus to an invisible window. You just have to clear eax before returning to Windows. And if you would have bothered to read the entire thread or just read the manual, you would have known that already.
Posted on 2003-06-03 15:25:37 by Sephiroth3
Thanks. Yes, I did bother to read, but I forgot that one.
Only after I scrolled down to the end of the procedure did I see my own comments: return FALSE to set focus to the edit control, instead of first button.
Posted on 2003-06-04 11:18:34 by VVV
Thanks very much for all of the above. And I'm sorry that I didn't reply you because I'm busy preparing my final examination for my life in junior-one.
I 've tried donkey's code:
.IF uMsg == WM_INITDIALOG
mov eax,FALSE
ret
.ELSEIF
invoke GetDlgItem,hWnd,Input
invoke SetFocus,eax
.ENDIF

I guess I made mistakes, of course, since the dialog didn't show normally.
Oh, don't laugh me, maybe I didn't understand donkey very well
(My understanding is poor ;) )

Ok, if you aren't sick of me-this newbie, would Sb. give me some directions that include more details?

Thanks.
Posted on 2003-06-25 23:15:54 by pdx1989
By the way, why could it setfocus in the example of Iczelion's tutor? I 'v copy the code absolutely, but it didn't work in my program as it would be. I mean it can work on the example in the tutor properly.
Posted on 2003-06-25 23:20:20 by pdx1989
What do you mean your dialog "didn't show normally"?
Posted on 2003-06-26 16:41:01 by QvasiModo
Um... you're now setting the focus in response to everything except WM_INITDIALOG :P
Posted on 2003-06-26 16:50:08 by Sephiroth3


mov eax,uMsg
.if eax == WM_INITDIALOG
invoke GetDlgItem,hWnd,Input
invoke SetFocus,eax
xor eax,eax
ret
.elseif eax == (other command your dialog box proc processes)
(...)
.elseif eax == (so on, so on...)
(...)
.endif
xor eax,eax
inc eax
ret
Posted on 2003-06-26 18:38:44 by QvasiModo
Thanks for your codes so much, the problem was solved :alright:
Posted on 2003-06-26 22:07:19 by pdx1989