Please... May anyone help me? I don't know how I can set the focus (setfocus) to something else than the edit control. see here #asm code ;E-Book .386 .model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib DlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD .DATA DlgName db "MyDialog",0 MenuName db "MyMenu",0 text0 db" " db 77,101,100,105,97,32,97,116,116,105,118,111,13,10,13,10 db 77,101,100,105,97,13,10,76,39,111,103,103,101,116,116,111 db 32,100,105,32,113,117,101,115,116,111,32,108,105,98,114,111 db 32,101,39,32,73,110,116,101,114,110,101,116,46,32,73,108 db 32,109,101,100,105,97,32,105,110,32,113,117,101,115,116,105,0 text1 db "capter 1",0 text2 db "capter 2",0 .DATA? hInstance dd ? .CONST IDM_C1 equ 1 IDM_C2 equ 2 IDM_EXIT equ 3 IDC_EXIT equ 103 IDC_EDIT equ 3000 .CODE start: invoke GetModuleHandle, NULL mov hInstance,eax invoke DialogBoxParam, hInstance, ADDR DlgName,NULL,addr DlgProc,NULL invoke ExitProcess,eax DlgProc PROC hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD .IF uMsg == WM_INITDIALOG invoke SetDlgItemText,hWnd,IDC_EDIT,addr text0 .ELSEIF uMsg == WM_CLOSE invoke EndDialog, hWnd,NULL .ELSEIF uMsg == WM_COMMAND mov eax,wParam .IF ax == IDM_C1 invoke SetDlgItemText,hWnd,IDC_EDIT,addr text1 .ELSEIF ax == IDM_C2 invoke SetDlgItemText,hWnd,IDC_EDIT,addr text2 .ELSEIF ax == IDM_EXIT invoke SendMessage,hWnd,WM_CLOSE,NULL,NULL .ELSEIF ax==IDC_EXIT invoke SendMessage,hWnd,WM_CLOSE,NULL,NULL .ENDIF .ELSE mov eax,FALSE ret .ENDIF mov eax,TRUE ret DlgProc endp END start #rc file #include "resource.h" #define IDM_C1 1 #define IDM_C2 2 #define IDM_EXIT 3 #define IDc_EXIT 103 #define IDC_EDIT 3000 MyIcon ICON "ICON.ICO" 600 BITMAP "Bitmap_1.bmp" MyDialog DIALOG 10, 10, 250, 250 STYLE DS_MODALFRAME | 0x804L | WS_OVERLAPPED | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX CAPTION " --- EBOOK" MENU MyMenu FONT 8, "MS Sans Serif" { CONTROL "", IDC_EDIT, "EDIT", ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP, 5, 65, 240, 150 CONTROL 600, -1, STATIC, SS_BITMAP | SS_CENTERIMAGE | SS_REALSIZEIMAGE | WS_CHILD | WS_VISIBLE, 5, 2, 240, 59 , 0x00020000 CONTROL "EBOOK", 105, STATIC, SS_CENTER | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_GROUP, 46, 230, 71, 12 CONTROL "&About", 102, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 6, 230, 37, 15 , 0x00020000 CONTROL "E&xit", 103, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 120, 230, 37, 15 , 0x00020000 } MyMenu MENU { POPUP " EBOOK" { MENUITEM "&Captitolo I", IDM_C1 MENUITEM "&Capitolo II", IDM_C2 MENUITEM SEPARATOR MENUITEM "&Exit", IDM_EXIT } } Thanks a lot g
Posted on 2001-03-05 10:48:00 by Giorgio

.const
PB_ABOUT    equ 102 ;As defined in the .rc file

...

invoke GetDlgItem, hWnd, PB_ABOUT
;Get handle of the PushButton "About"
invoke SetFocus, eax
;Or similar (no docs @ work blah blah blah)!
That should do it! Mirno
Posted on 2001-03-05 11:03:00 by Mirno
Could you, please, show me exactly where I have to put this portion of code. It seem that it don't work for me... Thanks a lot for your patience... g.
Posted on 2001-03-05 11:57:00 by Giorgio
That would depend on when you want it to happen! eg.

DlgProc PROC hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD

...

.IF uMsg == WM_INITDIALOG 
    invoke SetDlgItemText,hWnd,IDC_EDIT,addr text0
    invoke GetDlgItem, hWnd, 102 ;Get handle of About button
    invoke SetFocus, eax
.ELSEIF ....
Will only perform the SetFocus when you initialise the Dialog (at startup), you may wish to perform this on, say a button press, or selection of a menu, in which case the code must be inserted in the appropriate place! Mirno
Posted on 2001-03-05 12:54:00 by Mirno
Thanks I did what you told me but... don't work for me the text in the edit control, at beginning, remain in blue. And the text is blue because it's focused... I only want the text should be not selected, not in blue. Any suggestions? Thanks a lot. g.
Posted on 2001-03-05 14:29:00 by Giorgio
try to send a EM_SETSEL to the edit control to eliminate the selection.
Posted on 2001-03-05 16:39:00 by BlackHorus
Thanks... But don't work... Any other suggestions? Thanks... g.
Posted on 2001-03-05 22:20:00 by Giorgio
well u have to get focus away from the text box, so....

DlgProc PROC hWndWORD, uMsgWORD, wParamWORD, lParamWORD

.IF uMsg == WM_INITDIALOG 
invoke SetFocus,hWnd
invoke SetDlgItemText,hWnd,IDC_EDIT,addr text0
Im just thinking calling SetFocus with the window handle befor or after the SetDlgItemText should do it. -brad
Posted on 2001-03-06 00:03:00 by Rage9
i also supose if that does not work, go the extra mile and learn to fill out a WNDCLASSEX structure when createing a window, things seem to go much smoother that way. -brad
Posted on 2001-03-06 00:09:00 by Rage9
Take a look at the following code (it works on both 2k and 98, although 98 was my development machine). 8<-------------------------------------------------------------

.386
.model flat,stdcall
option casemap:none

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

include windows.inc
include user32.inc
include kernel32.inc
include gdi32.inc
includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib

.const
M_EXIT      equ         1000
.data
AppName     db          "Auto-book",0
ClassName   db          "AB",0
EditClass   db          "EDIT",0
Chapter     db          "CH01",0
File        db          "&File",0
Chap        db          "&Chapter",0,0,0,0
Exit        db          "E&xit",0

.data?
hInstance   HINSTANCE   ?
hEdit       HWND        ?
hMenu       HMENU       ?
hFileMenu   HMENU       ?
hChapMenu   HMENU       ?

.code
start:
        invoke GetModuleHandle, NULL
        mov hInstance, eax

        invoke WinMain, eax, NULL, NULL, SW_SHOWDEFAULT

        invoke ExitProcess, eax

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
        LOCAL wc:WNDCLASSEX
        LOCAL msg:MSG
        LOCAL hwnd:HWND

        mov wc.cbSize, SIZEOF WNDCLASSEX
        mov wc.style, CS_HREDRAW or CS_VREDRAW
        mov wc.lpfnWndProc, OffSet MainProc
        mov wc.cbClsExtra, NULL
        mov wc.cbWndExtra, NULL
        push hInst
        pop wc.hInstance
        mov wc.hbrBackground, NULL
        mov wc.lpszMenuName, NULL
        mov wc.lpszClassName, OffSet ClassName
        invoke LoadIcon, NULL, IDI_APPLICATION
        mov wc.hIcon, eax
        mov wc.hIconSm, eax
        invoke LoadCursor, NULL, IDC_ARROW
        mov wc.hCursor, eax
        invoke RegisterClassEx, ADDR wc
	  invoke CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
           WS_OVERLAPPEDWINDOW or WS_CLIPCHILDREN,CW_USEDEFAULT,\
           CW_USEDEFAULT,400,300,NULL,NULL,\
           hInst,NULL
        mov hwnd, eax

        invoke ShowWindow, eax,SW_SHOWNORMAL
	  invoke UpdateWindow, hwnd
	  .WHILE TRUE
                invoke GetMessage, ADDR msg,NULL,0,0
                .BREAK .IF (!eax)
                invoke TranslateMessage, ADDR msg
                invoke DispatchMessage, ADDR msg
	  .ENDW
	  mov eax,msg.wParam
	  ret
WinMain endp

MainProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
      LOCAL Lo    :BYTE
      LOCAL Hi    :BYTE

	.IF uMsg == WM_DESTROY
		invoke PostQuitMessage,NULL

      .ELSEIF uMsg == WM_CREATE
            invoke CreateMenu
            mov hMenu, eax

            invoke CreateMenu
            mov hFileMenu, eax

            invoke AppendMenu, hMenu, MF_POPUP, eax, ADDR File
            invoke AppendMenu, hFileMenu, MF_STRING, M_EXIT, ADDR Exit

            invoke CreateMenu
            mov hChapMenu, eax
            invoke AppendMenu, hMenu, MF_POPUP, eax, ADDR Chap

            mov Lo, 49
            mov Hi, 48
            .WHILE TRUE
                invoke FindResource, NULL, ADDR Chapter, RT_RCDATA
                .BREAK .IF eax == 0
                mov eax, Offset Chap
                mov BYTE PTR , " "
                mov ecx, 10000h
                mov ch, Lo
                mov cl, Hi
                mov WORD PTR , cx
                invoke AppendMenu, hChapMenu, MF_STRING, ecx, ADDR Chap + 1

                inc Lo
                .IF Lo > 57
                    mov Lo, 48
                    inc Hi
                    .BREAK .IF Hi > 57
                .ENDIF
                mov eax, Offset Chapter
                mov ch, Lo
                mov cl, Hi
                mov WORD PTR , cx
            .ENDW

            invoke SetMenu, hWnd, hMenu

            invoke CreateWindowEx, WS_EX_CLIENTEDGE,\
                ADDR EditClass, NULL,\
                WS_CHILD or WS_VISIBLE or WS_VSCROLL or \
                ES_LEFT or ES_MULTILINE or ES_READONLY,\
                0, 0, 0, 0,\
                hWnd, NULL, hInstance, NULL
Posted on 2001-03-06 06:06:00 by Mirno