Hi,
I want to put an edit control inside my window but i dont know how
I need to create it and what more
Can you help me ?
Thanks
I did this
; File: Edit2.asm
;------------------------------------------------------------------------------------------------------------------
.586
.model flat, stdcall
option casemap :none
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
include \masm32\include\windows.inc
include \masm32\macros\macros.asm
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include \masm32\include\comdlg32.inc ; printer
include \masm32\include\Comctl32.inc
;----------------------------------------------
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\comdlg32.lib ; printer
includelib \masm32\lib\Comctl32.lib
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
WndProcA proto :DWORD,:DWORD,:DWORD,:DWORD
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.const
MAIN_STYLE equ WS_OVERLAPPEDWINDOW or WS_CLIPCHILDREN
MAIN_EXTSTYLE equ 300h
$ECRAWIDTH$ equ 600 ;1280 ;800 ; largura do ecrã
$ECRAHEIGHT$ equ 300 ;800 ;570 ; altura do ecrã
; ««««««««««««««««««««« Data Section «««««««««««««««««««««««««««««««««««««««
.data
; ----------------------------------------------------------------------------------------------
_BUTTON_Class db "BUTTON",0 ;name of window class
_STATIC_Class db "STATIC",0 ;name of window class
_EDIT_Class db "EDIT",0 ;name of window class
_hEDIT1 dd 0
_TxtEDIT1 db 'Text.....', 0
;....................................................................................
_hWnd dd 0
_ClassName db 'WinClass',0
_WindowName db 'Edit Text',0
; «««««««««««««««««««« Data? Section «««««««««««««««««««««««««««««««««
.data?
;---------------------------------------
_hInstance dd ?
_hdc dd ?
;---------------------------------------
_wcx WNDCLASSEX <?>
_msg MSG <?>
; «««««««««««««««« Code Section «««««««««««««««««««««««««««««««««««««««««««
.code
;---------------------------------------
start:
invoke GetModuleHandle, NULL
mov _hInstance, eax
invoke WinMain, _hInstance, NULL, NULL, SW_SHOWDEFAULT
; ################################################
align 16
WinMain proc hInst:DWORD, hPrevInst:DWORD, CmdLine:DWORD, CmdShow:DWORD
LOCAL x,y:DWORD
; Window size and coordinates to center it on the screen
;-------------------------------------------------------
invoke GetSystemMetrics, SM_CXSCREEN
shr eax, 1
sub eax, $ECRAWIDTH$ / 2
mov x, eax
invoke GetSystemMetrics, SM_CXSCREEN
shr eax, 1
sub eax, $ECRAHEIGHT$ / 2
sub eax, 80
mov y, eax
;.................................................................
;
; Preencher a estrutura WNDCLASSEX para a janela 1
; ------------------------------------------------
mov _wcx.cbSize, SIZEOF WNDCLASSEX
mov _wcx.style, 3 or CS_BYTEALIGNCLIENT or CS_OWNDC
mov _wcx.lpfnWndProc, OFFSET WndProcA
mov _wcx.cbClsExtra, NULL
mov _wcx.cbWndExtra, NULL
push _hInstance
pop _wcx.hInstance
mov _wcx.hbrBackground, COLOR_BACKGROUND+1
mov _wcx.lpszMenuName, NULL ; menu name in resource file
mov _wcx.lpszClassName, OFFSET _ClassName ; name of windows class
mov _wcx.hIcon, NULL
mov _wcx.hIconSm, NULL
invoke LoadCursor, NULL, IDC_ARROW
mov _wcx.hCursor, eax
invoke RegisterClassEx, addr _wcx
;
; Cria a janela
; -------------
invoke CreateWindowEx, MAIN_EXTSTYLE, addr _ClassName, addr _WindowName, MAIN_STYLE,
x, y, $ECRAWIDTH$, $ECRAHEIGHT$,
NULL, NULL, hInst, NULL
mov _hWnd, eax
invoke GetDC, _hWnd
mov _hdc, eax
invoke ShowWindow, _hWnd, SW_SHOWNORMAL
invoke UpdateWindow, _hWnd
;###################################################
;
; Loop de espera de mensagens
;
@@: invoke GetMessage, ADDR _msg, NULL, 0, 0
cmp eax,0h ;check if return value=0 => exit
je @F ;go forward @@
invoke TranslateMessage, ADDR _msg
invoke DispatchMessage, ADDR _msg
jmp @B ;go backward @@
;
; Termina o programa
;-------------------
@@: invoke ExitProcess, 0
WinMain endp
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
WndProcA proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
mov edx, wParam
mov eax, uMsg
cmp eax, WM_CREATE
je _WM_CREATE
cmp eax, WM_PAINT
je _WM_PAINT
cmp eax, WM_CLOSE
je _WM_CLOSE
cmp eax, WM_DESTROY
je _WM_DESTROY
cmp eax, WM_SYSCOMMAND
je _WM_SYSCOMMAND
; -----------------------------------------------------------------
_EndProcA:: invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
; -----------------------------------------------------------------
; WM_CREATE
; -----------------------------------------------------------------
_WM_CREATE: invoke CreateWindowEx, 1h, offset _EDIT_Class, 0,
WS_CHILD or WS_TABSTOP or WS_VISIBLE or ES_LEFT or ES_AUTOHSCROLL, ;Style,
10, 20, 100, 10,
_hWnd,
500,
_hInstance,
0
mov _hEDIT1, eax
jmp _ExitProcA
; -----------------------------------------------------------------
; WM_PAINT
; -----------------------------------------------------------------
_WM_PAINT:
invoke SetWindowText, _hEDIT1, addr _TxtEDIT1 ; ????
jmp _ExitProcA
; -----------------------------------------------------------------
; WM_SYSCOMMAND
; -----------------------------------------------------------------
_WM_SYSCOMMAND: cmp edx, SC_CLOSE
jne _EndProcA
; -----------------------------------------------------------------
; WM_CLOSE
; -----------------------------------------------------------------
_WM_CLOSE:: invoke DestroyWindow, hWnd
jmp _ExitProcA
; -----------------------------------------------------------------
; WM_DESTROY
; -----------------------------------------------------------------
_WM_DESTROY: invoke PostQuitMessage, NULL
;
_ExitProcA:: mov eax, 0
ret
WndProcA endp
; ########################################################
end start
Rui
Rui,
Just use the handle of your main window as the parent and create the edit control as a child window using the main window handle as its parent. You can use MoveWindow() to position it if the parent is a normal sizable window.
Quote from: hutch-- on November 16, 2009, 12:46:43 AM
Just use the handle of your main window as the parent and create the edit control as a child window using the main window handle as its parent.
Hutch,
It was just what i did and it doesnt work. The handle of my parent window is _hWnd
and the edit control is a child window
Rui
The handle of your parent window is hWnd:
WndProcA proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
All I had to do was change _hWnd to hWnd.
Quote
All I had to do was change _hWnd to hWnd.
Thanks Hutch & Michael. When we receive WM_CREATE _hWnd=0 !
It works correctly
Can we change the background color ? how ?
Rui
Rui,
Something I learned the hard way was to not create a rich edit control in the WM_CREATE message processing. It should work but it seems that some system hooks interfere with it starting so I put a CreateWindowEx() call for a rich edit control AFTER the main window is created in the procedure that contains the main window code.
Quote from: hutch-- on November 18, 2009, 11:05:56 AM
so I put a CreateWindowEx() call for a rich edit control AFTER the main window is created in the procedure that contains the main window code.
Hi Hutch
Thanks
i wrote a working example.
In
Edit6 i create the edit control in WM_CREATE but i need 2 GetDisplayDC
one before CreateWindowEx and one after CreateWindowEx (to create the main window).
Try to comment out one of them and it doesnt work properly.
In
Edit7 i create the edit control after CreateWindowEx (to create the main window)
and i need only one GetDisplayDC
To use Edit6/7 type some text and use END, Return or Esc
Files: Edit6.zip (asm & exe) , Edit6.zip (asm & exe) rsrc.rc
Rui
largura do ecrã
your codepage is "1252 Western European (Windows)"?
PS. codepages for text file:
37 IBM EBCDIC (US-Canada)
437 United States (DOS)
500 IBM EBCDIC (International)
708 Arabic (ASMO 708)
709 Arabic (ASMO 449+, BCON V4)
710 Arabic (Transparent Arabic)
720 Arabic (DOS)
737 Greek (DOS)
775 Baltic (DOS)
850 Western European (DOS)
852 Central European (DOS)
855 Cyrillic (DOS)
857 Turkish (DOS)
858 Multilingual Latin I (DOS)
860 Portuguese (DOS)
861 Icelandic (DOS)
862 Hebrew (DOS)
863 French Canadian (DOS)
864 Arabic (864)
865 Nordic (DOS)
866 Cyrillic (DOS)
869 Greek, Modern (DOS)
870 IBM EBCDIC (Multilingual Latin-2)
874 Thai (Windows)
875 IBM EBCDIC (Greek Modern)
932 Japanese (Shift-JIS)
936 Chinese Simplified (GB2312)
949 Korean
950 Chinese Traditional (Big5)
1026 IBM EBCDIC (Turkish Latin-5)
1047 IBM Latin-1
1140 IBM EBCDIC (US-Canada-Euro)
1141 IBM EBCDIC (Germany-Euro)
1142 IBM EBCDIC (Denmark-Norway-Euro)
1143 IBM EBCDIC (Finland-Sweden-Euro)
1144 IBM EBCDIC (Italy-Euro)
1145 IBM EBCDIC (Spain-Euro)
1146 IBM EBCDIC (UK-Euro)
1147 IBM EBCDIC (France-Euro)
1148 IBM EBCDIC (International-Euro)
1149 IBM EBCDIC (Icelandic-Euro)
1200 Unicode
1201 Unicode (Big-Endian)
1250 Central European (Windows)
1251 Cyrillic (Windows)
1252 Western European (Windows)
1253 Greek (Windows)
1254 Turkish (Windows)
1255 Hebrew (Windows)
1256 Arabic (Windows)
1257 Baltic (Windows)
1258 Vietnamese (Windows)
1361 Korean (Johab)
10000 Western European (Mac)
10001 Japanese (Mac)
10002 Chinese Traditional (Mac)
10003 Korean (Mac)
10004 Arabic (Mac)
10005 Hebrew (Mac)
10006 Greek (Mac)
10007 Cyrillic (Mac)
10008 Chinese Simplified (Mac)
10010 Romanian (Mac)
10017 Ukrainian (Mac)
10021 Thai (Mac)
10029 Central European (Mac)
10079 Icelandic (Mac)
10081 Turkish (Mac)
10082 Croatian (Mac)
12000 Unicode UCS-4 Little-Endian
12001 Unicode UCS-4 Big-Endian
20000 Chinese Traditional (CNS)
20001 TCA Taiwan
20002 Chinese Traditional (Eten)
20003 IBM5550 Taiwan
20004 TeleText Taiwan
20005 Wang Taiwan
20105 Western European (IA5)
20106 German (IA5)
20107 Swedish (IA5)
20108 Norwegian (IA5)
20127 US-ASCII
20261 T.61
20269 ISO-6937
20273 IBM EBCDIC (Germany)
20277 IBM EBCDIC (Denmark-Norway)
20278 IBM EBCDIC (Finland-Sweden)
20280 IBM EBCDIC (Italy)
20284 IBM EBCDIC (Spain)
20285 IBM EBCDIC (UK)
20290 IBM EBCDIC (Japanese katakana)
20297 IBM EBCDIC (France)
20420 IBM EBCDIC (Arabic)
20423 IBM EBCDIC (Greek)
20424 IBM EBCDIC (Hebrew)
20833 IBM EBCDIC (Korean Extended)
20838 IBM EBCDIC (Thai)
20866 Cyrillic (KOI8-R)
20871 IBM EBCDIC (Icelandic)
20880 IBM EBCDIC (Cyrillic Russian)
20905 IBM EBCDIC (Turkish)
20924 IBM Latin-1
20932 Japanese (JIS 0208-1990 and 0212-1990)
20936 Chinese Simplified (GB2312-80)
20949 Korean Wansung
21025 IBM EBCDIC (Cyrillic Serbian-Bulgarian)
21027 (deprecated)
21866 Cyrillic (KOI8-U)
28591 Western European (iso-8859-1)
28592 Central European (iso-8859-2)
28593 Latin 3 (iso-8859-3)
28594 Baltic (iso-8859-4)
28595 Cyrillic (iso-8859-5)
28596 Arabic (iso-8859-6)
28597 Greek (iso-8859-7)
28598 Hebrew (iso-8859-8)
28599 Turkish (iso-8859-9)
28603 Estonian (iso-8859-13)
28605 Latin 9 (iso-8859-15)
29001 Europa
38598 Hebrew (iso-8859-8-i)
50220 Japanese (JIS)
50221 Japanese (JIS-Allow 1 byte Kana)
50222 Japanese (JIS-Allow 1 byte Kana - SO/SI)
50225 Korean (iso-2022-kr)
50227 Chinese Simplified (ISO-2022)
50229 Traditional Chinese (ISO 2022)
50930 Japanese (Katakana) Extended
50931 US/Canada and Japanese
50933 Korean Extended and Korean
50935 Simplified Chinese Extended and Simplified Chinese
50936 Simplified Chinese
50937 US/Canada and Traditional Chinese
50939 Japanese (Latin) Extended and Japanese
51932 Japanese (EUC)
51936 Chinese Simplified (EUC)
51949 Korean (EUC)
51950 Traditional Chinese (EUC)
52936 Chinese Simplified (HZ)
54936 Chinese Simplified (GB18030)
57002 ISCII Devanagari
57003 ISCII Bengali
57004 ISCII Tamil
57005 ISCII Telugu
57006 ISCII Assamese
57007 ISCII Oriya
57008 ISCII Kannada
57009 ISCII Malayalam
57010 ISCII Gujarati
57011 ISCII Punjabi
65000 Unicode (UTF-7)
65001 Unicode (UTF-8)
65005 Unicode (UTF-32)
65006 Unicode (UTF-32 Big-Endian)
Quote from: UtillMasm on November 19, 2009, 02:32:28 AM
largura do ecrã
your codepage is "1252 Western European (Windows)"?
UtilMasm,
yes, i think it is 1252. When i compile a resource file it uses that codepage
But why ? »largura do ecrã» is screen width
Rui
is it a french word?
PS. it's a strange character to me, i never see it before :wink.
Quote from: UtillMasm on November 19, 2009, 12:18:35 PM
is it a french word?
No, it is portuguese from Portugal :wink.
Rui