flat assembler
Message board for the users of flat assembler.

Index > Windows > text editor

Author
Thread Post new topic Reply to topic
Ali.Z



Joined: 08 Jan 2018
Posts: 233
Ali.Z
im trying to make a simple text editor, but the problem is there is no edit box.

note:
if you click some keys you will hear some sound.

Code:
format PE GUI 4.0
entry start

include 'win32a.inc'

section '.text' code executable

start:

    invoke      GetModuleHandle,0
    mov         [wc.hInstance],eax

    invoke      LoadCursor,0,IDC_IBEAM
    mov         [wc.hCursor],eax
    invoke      CreateFont,16,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH+FF_DONTCARE,NULL
    mov         [hfont],eax
    xor         eax,eax
    mov         [wc.style],eax
    mov         [wc.lpfnWndProc],MainWindow
    mov         [wc.cbClsExtra],eax
    mov         [wc.cbWndExtra],eax
    mov         [wc.hbrBackground],COLOR_WINDOW
    mov         [wc.lpszMenuName],eax
    mov         [wc.lpszClassName],_class
    invoke      RegisterClass,wc
    invoke      LoadAccelerators,[wc.hInstance],IDA_MAIN
    mov         [hkeys],eax
    invoke      LoadMenu,[wc.hInstance],IDM_MAIN
    invoke      CreateWindowEx,0,_class,_caption,WS_TILEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS,25,25,244,152,NULL,eax,[wc.hInstance],NULL
    mov         [hwnd_main],eax
    invoke      ShowWindow,eax,SW_SHOW
    invoke      UpdateWindow,[hwnd_main]

msg_loop:
    invoke      GetMessage,msg,NULL,0,0
    or          eax,eax
    jz          end_loop
    invoke      TranslateAccelerator,[hwnd_main],[hkeys],msg
    or          eax,eax
    jnz         msg_loop
    cmp         [msg.message],WM_KEYDOWN
    jz          msg_dispatch
    invoke      TranslateMessage,msg
msg_dispatch:
    invoke      DispatchMessage,msg
    jmp         msg_loop

end_loop:
    invoke      ExitProcess,[msg.wParam]

proc MainWindow hwnd,msg,wparam,lparam
    push        ebx esi edi
    cmp         [msg],WM_CREATE
    jz          wmcreate
    cmp         [msg],WM_SIZE
    jz          wmsize
    cmp         [msg],WM_SETFOCUS
    jz          wmsetfocus
    cmp         [msg],WM_COMMAND
    jz          wmcommand
    cmp         [msg],WM_CLOSE
    jz          wmclose
    cmp         [msg],WM_DESTROY
    jz          wmdestroy
    invoke      DefWindowProc,[hwnd],[msg],[wparam],[lparam]
    jmp         finish
  wmcreate:
    invoke      GetClientRect,[hwnd],rct
    invoke      CreateWindowEx,0,_edit_class,0,WS_CHILD,WS_VISIBLE,ES_MULTILINE,WS_VSCROLL,WS_HSCROLL,ES_AUTOVSCROLL,ES_AUTOHSCROLL,[rct.left],[rct.top],[rct.right],[rct.bottom],[hwnd],NULL,[wc.hInstance],NULL
    mov         [hedit],eax
    invoke      SendMessage,[hedit],WM_SETFONT,[hfont],0
    jmp         ok
  wmsize:
    invoke      GetClientRect,[hwnd],rct
    invoke      MoveWindow,[hedit],[rct.left],[rct.top],[rct.right],[rct.bottom],TRUE
    jmp         ok
  wmsetfocus:
    invoke      SetFocus,[hedit]
    jmp         ok
  wmcommand:
    mov         eax,[wparam]
    and         eax,0ffffh
    cmp         eax,IDM_NEW
    jz          ok
    cmp         eax,IDM_EXIT
    jz          wmclose
    cmp         eax,IDM_ABOUT
    jz          about_dlg
    jmp         ok
    about_dlg:
    invoke      DialogBoxParam,[wc.hInstance],IDD_ABOUT,[hwnd],AboutDialog,0
    jmp         ok
  wmclose:
    invoke      DeleteObject,[hfont]
    invoke      DestroyWindow,[hwnd]
    jmp         ok
  wmdestroy:
    invoke      WinHelp,[hwnd],0,HELP_QUIT,0
    invoke      PostQuitMessage,0
  ok:
    xor         eax,eax
  finish:
    pop         edi esi ebx
    ret
endp

proc AboutDialog hwnd,msg,wparam,lparam
    push        ebx esi edi
    cmp         [msg],WM_CLOSE
    jz          .close
    xor         eax,eax
    jmp         .finish
  .close:
    invoke      EndDialog,[hwnd],0
    mov         eax,1
  .finish:
    pop         edi esi ebx
    ret
endp

section '.data' data readable writeable

  wc WNDCLASS
  msg MSG
  rct RECT

  hwnd_main dd ?
  hfont     dd ?
  hedit     dd ?
  hkeys     dd ?

section '.rdata' data readable

  _class db 'CES',0
  _edit_class db 'SEDIT',0
  _caption db 'Fasm Example',0

section '.idata' import data readable

  library kernel32,'kernel32.dll',\
          user32,'user32.dll',\
          advapi32,'advapi32.dll',\
          shell32,'shell32.dll',\
          gdi32,'gdi32.dll',\
          comctl32,'comctl32.dll',\
          comdlg32,'comdlg32.dll'

  include 'api\kernel32.inc'
  include 'api\user32.inc'
  include 'api\advapi32.inc'
  include 'api\shell32.inc'
  include 'api\gdi32.inc'
  include 'api\comctl32.inc'
  include 'api\comdlg32.inc'

section '.rsrc' resource data readable

  directory RT_MENU,menus,\
            RT_ACCELERATOR,accelerators,\
            RT_DIALOG,dialogs

  resource menus,\
           IDM_MAIN,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu

  resource accelerators,\
           IDA_MAIN,LANG_ENGLISH+SUBLANG_DEFAULT,hot_keys

  resource dialogs,\
           IDD_ABOUT,LANG_ENGLISH+SUBLANG_DEFAULT,about_dialog

  IDA_MAIN      = 101
  IDM_MAIN      = 201
  IDM_NEW       = 202
  IDM_EXIT      = 203
  IDM_ABOUT     = 204
  IDD_ABOUT     = 301

  _ equ ,09,

  menu main_menu
       menuitem '&File',0,MFR_POPUP
                menuitem '&New' _ 'Ctrl+N',IDM_NEW,0,MFS_GRAYED,0
                menuseparator
                menuitem '&Exit' _ 'Alt+X',IDM_EXIT,MFR_END
       menuitem '&Help',0,MFR_POPUP+MFR_END
                menuitem '&About' _ 'Shift+H',IDM_ABOUT,MFR_END

  accelerator hot_keys,\
              FVIRTKEY+FNOINVERT+FCONTROL,'N',IDM_NEW,\
              FVIRTKEY+FNOINVERT+FALT,'X',IDM_EXIT,\
              FVIRTKEY+FNOINVERT+FSHIFT,'H',IDM_ABOUT

  dialog about_dialog,'About..',50,50,100,100,WS_SYSMENU+WS_CAPTION+WS_POPUP+DS_MODALFRAME
    dialogitem 'STATIC','Win32 GUI example',-1,25,25,50,50,WS_VISIBLE+SS_CENTER
  enddialog

section '.reloc' fixups data readable discardable    

_________________
Asm For Wise Humans
Post 18 Oct 2018, 13:02
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 604
Location: Belarus
DimonSoft
Ali.A wrote:
im trying to make a simple text editor, but the problem is there is no edit box.

Something wrong went here, at least:
Code:
    invoke      CreateWindowEx,0,_edit_class,0,WS_CHILD,WS_VISIBLE,ES_MULTILINE,WS_VSCROLL,WS_HSCROLL,ES_AUTOVSCROLL,ES_AUTOHSCROLL,[rct.left],[rct.top],[rct.right],[rct.bottom],[hwnd],NULL,[wc.hInstance],NULL    
Post 18 Oct 2018, 16:24
View user's profile Send private message Visit poster's website Reply with quote
Walter



Joined: 26 Jan 2013
Posts: 136
Walter
In order to see your input, you are going to need:

In CreateWindowEx:

WS_CHILD+WS_VISIBLE+ES_MULTILINE+WS_VSCROLL+WS_HSCROLL+ES_AUTOVSCROLL+ES_AUTOHSCROLL

Class:

_edit_class db 'EDIT',0

and in msg_loop:

; cmp [msg.message],WM_KEYDOWN
; jz msg_dispatch
Post 18 Oct 2018, 16:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16904
Location: In your JS exploiting you and your system
revolution
If you check the return values from each API call then you can narrow down each problem more easily. Print some sort of simple message (or better, use a debugger) when any of the API calls fails. Fix up each call one-by-one until they all execute successfully.
Post 18 Oct 2018, 17:22
View user's profile Send private message Visit poster's website Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 233
Ali.Z
ok found my issue after debugging:
Code:
WS_CHILD,WS_VISIBLE,ES_MULTILINE,WS_VSCROLL,WS_HSCROLL,ES_AUTOVSCROLL,ES_AUTOHSCROLL    

used comma instead of '+' plus sign.

and why i cant get a custom name for _edit_class? why it have to be 'edit'?

and why im limited in the editbox? i cant write many characters!

also
; cmp [msg.message],WM_KEYDOWN
; jz msg_dispatch

didnt work, i had to change it to:

Code:
msg_loop:
    invoke      GetMessage,msg,NULL,0,0
    or          eax,eax
    jz          end_loop
    cmp         [msg.message],WM_KEYDOWN
    jz          msg_translate
    invoke      TranslateAccelerator,[hwnd_main],[hkeys],msg
    or          eax,eax
    jnz         msg_loop
    cmp         [msg.message],WM_KEYDOWN
    jz          msg_dispatch
msg_translate:
    invoke      TranslateMessage,msg
msg_dispatch:
    invoke      DispatchMessage,msg
    jmp         msg_loop    


but the issue now is i cant receive hotkeys with shift or ctrl, only alt key.

Code:
menu main_menu
       menuitem '&File',0,MFR_POPUP
                menuitem '&New' _ 'Alt+N',IDM_NEW,0,MFS_GRAYED,0
                menuseparator
                menuitem '&Exit' _ 'Alt+X',IDM_EXIT,MFR_END
       menuitem '&Help',0,MFR_POPUP+MFR_END
                menuitem '&About' _ 'Alt+H',IDM_ABOUT,MFR_END

accelerator hot_keys,\ ; cant use FCONTROL
              FVIRTKEY+FNOINVERT+FALT,'N',IDM_NEW,\
              FVIRTKEY+FNOINVERT+FALT,'X',IDM_EXIT,\
              FVIRTKEY+FNOINVERT+FALT,'H',IDM_ABOUT    

how could i solve this?
Post 18 Oct 2018, 20:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16904
Location: In your JS exploiting you and your system
revolution
Ali.A wrote:
and why i cant get a custom name for _edit_class? why it have to be 'edit'?
The "EDIT" class is provided by the Windows standard DLLS. You don't have to use it if you don't want to. You can create a custom class with any name. But then you have to write the code to support the class.

Have a look at the FEDIT.ASM source for the "FEDIT" class.
Post 18 Oct 2018, 21:14
View user's profile Send private message Visit poster's website Reply with quote
MacroZ



Joined: 12 Oct 2018
Posts: 30
MacroZ
More text editors are always useful. I hope it will have syntax highlighting for asm. Keep up the good work.

_________________
The king auto-generates two things to degrade dangerous artists and intellectuals. The King reserves the right to be king and has made the culprits in advance. Half of the time or more, they are auto-generated.
Post 19 Oct 2018, 12:05
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 233
Ali.Z
MacroZ wrote:
More text editors are always useful. I hope it will have syntax highlighting for asm. Keep up the good work.

yeah that what i wanted to make, but seems the project will be discarded.

revolution wrote:
Have a look at the FEDIT.ASM source for the "FEDIT" class.

couldnt understand a single line, both fasmw and fedit are large in file size and total of 5000+ lines of code.

seems Win GUI programming isnt suitable for me, its better to stick with consoles. (but i would say i was very happy for creating a window tho)

_________________
Asm For Wise Humans
Post 19 Oct 2018, 21:15
View user's profile Send private message Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 119
catafest
The code is an old code I saw on the internet ...
The debugger is the first tool to understand assembler ...
I don't know the english language very well !

Ali.A wrote:
im trying to make a simple text editor, but the problem is there is no edit box.

note:...
Post 21 Oct 2018, 09:16
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 233
Ali.Z
catafest wrote:
The code is an old code I saw on the internet ...
The debugger is the first tool to understand assembler ...
I don't know the english language very well !

useless + stupid post, by creating a new account on this forum doesnt mean im new assembley.
i used to be a reverse engineer for something like 10 years, plus the code isnt a snippet from web its my own code.

just failing to understand win gui programming doesnt mean im new to programming nor the code is stolen from web.

_________________
Asm For Wise Humans
Post 21 Oct 2018, 13:40
View user's profile Send private message Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 119
catafest
1. I don't like rude people.
Ali.A wrote:

useless + stupid post, by creating a new account on this forum doesnt mean im new assembley...


I find a similar source code on internet.
I cannot give the link because I don't have it.
2. Reply to @DimonSoft idea :
I used WS_OVERLAPPEDWINDOW but you can used any part of MSDN SDK!
The window is an overlapped window. Same as the WS_TILEDWINDOW style.
Code:
invoke CreateWindowEx,0,szClass,szTitle,WS_OVERLAPPEDWINDOW,\
                              CW_USEDEFAULT,CW_USEDEFAULT,\
                              600,600,NULL,[h_menu],[wcex.hInstance],NULL      

The edit control can be done with :
Code:
 invoke CreateWindowEx,WS_EX_CLIENTEDGE,szEdit,0,\
        WS_VISIBLE+WS_CHILD+WS_VSCROLL+ES_AUTOVSCROLL+ES_MULTILINE,\
        0,0,0,0,[hwnd],0,[wcex.hInstance],NULL       

3. FASM is very flexible... Cool
Post 21 Oct 2018, 14:48
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1436
Furs
Ali, you should read some books or tutorials on Win32 GUI programming, even if they're not in assembler, because the concepts are more general.

For example, you asked why you can't use a different class name. Well, a "class" in Windows is sort of like a "class" in C++, but for windows (note that all controls are also "windows"). You create windows (i.e. objects, instances of that class) from it, that have properties of that class. Most important such property is the "WNDPROC" which is a callback that receives a lot of messages from various places (the Win32 GUI system is event-driven) and defines most of what the window will do based upon various events.

For example, when the Window gets destroyed, it receives (in its WNDPROC) a WM_DESTROY message so it can do whatever. The class defines the callback function that the window uses.

"Edit" is the name of the class provided by Windows, its builtin edit control. Obviously, "_edit_control" does not exist because you didn't register this class, so it fails. It's like using a class in C++ that doesn't exist, or a label in asm, whatever. Don't think of it as a name but rather as an identifier. It's a shame they used strings for it, though.


You can technically override the WNDPROC (this is called subclassing) after the window gets created with it, but that's more advanced concept, for now focus on basics. Wink
Post 21 Oct 2018, 15:01
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 604
Location: Belarus
DimonSoft
catafest wrote:
2. Reply to @DimonSoft idea :
I used WS_OVERLAPPEDWINDOW but you can used any part of MSDN SDK!
The window is an overlapped window. Same as the WS_TILEDWINDOW style.
Code:
invoke CreateWindowEx,0,szClass,szTitle,WS_OVERLAPPEDWINDOW,\
                              CW_USEDEFAULT,CW_USEDEFAULT,\
                              600,600,NULL,[h_menu],[wcex.hInstance],NULL      

The edit control can be done with :
Code:
 invoke CreateWindowEx,WS_EX_CLIENTEDGE,szEdit,0,\
        WS_VISIBLE+WS_CHILD+WS_VSCROLL+ES_AUTOVSCROLL+ES_MULTILINE,\
        0,0,0,0,[hwnd],0,[wcex.hInstance],NULL       

Are you sure I don’t know this stuff? Are you sure you’ve understood why my post contained the line with CreateWindowEx? We can also talk about using + instead of or some time later.
Post 21 Oct 2018, 17:45
View user's profile Send private message Visit poster's website Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 233
Ali.Z
Furs wrote:
Ali, you should read some books or tutorials on Win32 GUI programming, even if they're not in assembler, because the concepts are more general.

i read some, but most of them provide code samples and not explaining much stuff.

Furs wrote:
For example, you asked why you can't use a different class name. Well, a "class" in Windows is sort of like a "class" in C++, but for windows (note that all controls are also "windows"). You create windows (i.e. objects, instances of that class) from it, that have properties of that class. Most important such property is the "WNDPROC" which is a callback that receives a lot of messages from various places (the Win32 GUI system is event-driven) and defines most of what the window will do based upon various events.

thanks for this one man, didnt know other controls are considered as "window" .. yeah i noticed that when debugging lot of stuff are sent in [msg] to main window procedure and 90% of the messages are unknown to me, and i dont handle them.

Furs wrote:
"Edit" is the name of the class provided by Windows, its builtin edit control. Obviously, "_edit_control" does not exist because you didn't register this class, so it fails. It's like using a class in C++ that doesn't exist, or a label in asm, whatever. Don't think of it as a name but rather as an identifier. It's a shame they used strings for it, though.

i tried later then to register a custom class name for the edit control, but failed.
also tried to learn some from fasmw.asm and fedit.inc but couldnt understand much.

Furs wrote:
for now focus on basics. Wink

thats right, i learnt some basics and im happy but thats not enough .. i wanna learn more advanced stuff.

you probably will understand this:
its like i was in a small room called "console programming" and that room fits me and my needs as well.
and then went to big hall called "win gui programming" its kinda im lost.

i would say win gui is similar to BF (brain f*ck) programming lol.
btw thanks for the info Furs.

_________________
Asm For Wise Humans
Post 22 Oct 2018, 01:29
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1436
Furs
Ali.A wrote:
i read some, but most of them provide code samples and not explaining much stuff.
Well most of them assume you know some basic C/C++ I think. If you know asm, it's not that difficult to learn C at least to be able to read it, since it's pretty simple language. Then code samples will be very good for you Wink

Ali.A wrote:
thanks for this one man, didnt know other controls are considered as "window" .. yeah i noticed that when debugging lot of stuff are sent in [msg] to main window procedure and 90% of the messages are unknown to me, and i dont handle them.
Yeah even something like a radio button is a "window", actually a child window of some dialog box or whatever. Child windows are part of another window (they can't move outside) and usually have no border or whatever.

For unknown messages you should simply call DefWindowProc which handles default processing for such messages. So if it's a message you don't handle just pass it to DefWindowProc and return with its return value (from the callback).

Ali.A wrote:
i tried later then to register a custom class name for the edit control, but failed.
also tried to learn some from fasmw.asm and fedit.inc but couldnt understand much.
Did you populate the class structure properly before registering? Can you show the code?

BTW, Win32 GUI programming is event-driven so pretty much "object oriented" in design but with messages instead of vtables. I'm guessing you don't have much experience with OO concepts.

It boils down to: window receives events (messages) based on whatever (user input, system stuff, or even custom messages). In a window you process these messages. There's no definite "flow chart" that you know, all you care about is inputs (message and parameters) and act accordingly. It doesn't matter when you get called. Since it's a callback.

It's not as "linear" as console programming. Think of it as a function getting executed by the CPU when something happens (like interrupts) but at a much higher level. Wink
Post 22 Oct 2018, 12:11
View user's profile Send private message Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 119
catafest
@DimonSoft : I read your replay and is ok!
Post 22 Oct 2018, 12:19
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 233
Ali.Z
Furs wrote:
Well most of them assume you know some basic C/C++ I think. If you know asm, it's not that difficult to learn C at least to be able to read it, since it's pretty simple language. Then code samples will be very good for you Wink

yes i can read C/C++ and what i read was C/C++ samples.

Furs wrote:
For unknown messages you should simply call DefWindowProc which handles default processing for such messages. So if it's a message you don't handle just pass it to DefWindowProc and return with its return value (from the callback).

ehm, but i think it cant handle one thing:
when you create a window with a status bar and you resize the window, the status bar wont get auto-resize.
why i have to save if msg = wm_size then get client rect and then call move window function, why not defwndproc do this for me?

Furs wrote:
Did you populate the class structure properly before registering? Can you show the code?

Code:
; i thought this code should be enough
mov         [wc.style],CS_DBLCLKS+CS_GLOBALCLASS
    mov         [wc.lpfnWndProc],CESedit
    mov         [wc.lpszClassName],_edit_class
    invoke      RegisterClass,wc
; then i did this
invoke      CreateWindowEx,0,_edit_class,0,WS_CHILD+WS_VISIBLE+ES_MULTILINE+WS_VSCROLL+WS_HSCROLL+ES_AUTOVSCROLL+ES_AUTOHSCROLL,[rct.left],[rct.top],[rct.right],[rct.bottom],[hwnd],NULL,[wc.hInstance],NULL
    mov         [hedit],eax    


Furs wrote:
I'm guessing you don't have much experience with OO concepts.

exactly, maybe thats why im facing difficulties to understand and program Win32 GUI?

Furs wrote:
It's not as "linear" as console programming. Think of it as a function getting executed by the CPU when something happens (like interrupts) but at a much higher level. Wink

yes i noticed that the day i started writing some gui code, also got stuck for the first couple hours saying exact same thing:
its not linear as console.

thanks for this, didnt think of it as case similar to interrupt.
but now i can think of it properly, where WndProc is similar to OS-interrupt handling function and WM_? is similar to interrupt number.

ehm Furs i learnt from these two sites and fasmw.asm and fedit.inc:

zetcode
winprog

so read these and i feel like i got 90% of the tutorial, then i tried to write my own code.

(do you know any better source providing examples and explaining some concepts)

_________________
Asm For Wise Humans
Post 22 Oct 2018, 21:38
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 604
Location: Belarus
DimonSoft
Ali.A wrote:
ehm, but i think it cant handle one thing:
when you create a window with a status bar and you resize the window, the status bar wont get auto-resize.
why i have to save if msg = wm_size then get client rect and then call move window function, why not defwndproc do this for me?

What if you don’t want a control to resize when its parent gets resized? Having less code is better since you can write one for your preferred behaviour. If DefWindowProc did resize child windows that would pose a lot of questions. Say, should font sizes also change? What if this also changes the way window text is split into lines in a button or edit control? What if there’s no font of appropriate size? What if it’s a button with an icon (which is raster image)? What if resized child window starts showing on several monitors after the resize? And then, if all the questions were solved and DefWindowProc somehow implemented this behaviour (this way or that) there still would be people who need different behaviour and they would have to fight against DefWindowProc. It is sometimes easier to write zero lines of code than to write some and have to support them although nearly everyone just doesn’t use it.

Ali.A wrote:
Code:
; i thought this code should be enough
mov         [wc.style],CS_DBLCLKS+CS_GLOBALCLASS
    mov         [wc.lpfnWndProc],CESedit
    mov         [wc.lpszClassName],_edit_class
    invoke      RegisterClass,wc
; then i did this
invoke      CreateWindowEx,0,_edit_class,0,WS_CHILD+WS_VISIBLE+ES_MULTILINE+WS_VSCROLL+WS_HSCROLL+ES_AUTOVSCROLL+ES_AUTOHSCROLL,[rct.left],[rct.top],[rct.right],[rct.bottom],[hwnd],NULL,[wc.hInstance],NULL
    mov         [hedit],eax    

Not enough to tell the exact reason. Possible ones are:
* class name is already taken by a system-wide class (if you use EDIT as the name);
* cbSize field is not properly initialized.

GetLastError will answer your question.

Ali.A wrote:
(do you know any better source providing examples and explaining some concepts)

MSDN. It requires some experience reading official documentation but the only way to have the experience is to actually read the docs. Besides, it’s the original source for everything you’re going to find in the Internet. And, unlike third-party sources, this information is contractual, while third parties can have mistakes and misunderstandings by the authors themselves.
Post 23 Oct 2018, 07:54
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1436
Furs
Ali.A wrote:
ehm, but i think it cant handle one thing:
when you create a window with a status bar and you resize the window, the status bar wont get auto-resize.
why i have to save if msg = wm_size then get client rect and then call move window function, why not defwndproc do this for me?
Well it doesn't know how to move child windows.

What if they should be static and the window itself is just a canvas for child windows? (e.g. a dialog box, which is also a window).

What if they're supposed to also be resized along with the parent? Not just "stick to an edge"? It can't know any of these things, so it doesn't do them.

Ali.A wrote:
Code:
; i thought this code should be enough
mov         [wc.style],CS_DBLCLKS+CS_GLOBALCLASS
    mov         [wc.lpfnWndProc],CESedit
    mov         [wc.lpszClassName],_edit_class
    invoke      RegisterClass,wc
; then i did this
invoke      CreateWindowEx,0,_edit_class,0,WS_CHILD+WS_VISIBLE+ES_MULTILINE+WS_VSCROLL+WS_HSCROLL+ES_AUTOVSCROLL+ES_AUTOHSCROLL,[rct.left],[rct.top],[rct.right],[rct.bottom],[hwnd],NULL,[wc.hInstance],NULL
    mov         [hedit],eax    
Set cbClsExtra and cbClsExtra to zero if you don't need it. The various handles (cursor, brush, icon) should also be set to NULL unless you need them.

Also, note that the [rct.right] and [rct.bottom] are wrong. The window expects width and height, not a rectangle. So you need something like rct.right - rct.left for the width.

Ali.A wrote:
(do you know any better source providing examples and explaining some concepts)
MSDN is good, but not that friendly to beginners. One mistake a lot of people make is they only look at the Function Reference, but in fact, MSDN has a lot of Overview sections as well, which is what you should be reading in this situation.

I don't know that many sources for beginners, unfortunately.

You can try books like "Programming Windows 5th Edition" by Charles Petzold and start from Chapter 3 (I assume you know the basics so skip the first two). It's pretty old but the concepts are the same so it doesn't matter.

(pretty sure you can get it for free if you look hard enough if you don't want to pay for it -- though of course, if it's useful to you consider paying for it to support the author)
Post 23 Oct 2018, 15:20
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 233
Ali.Z
ehm, thanks DimonSoft and Furs.

yeah thats true its not friendly, and i was only looking into Docs section -> Function Reference
Post 25 Oct 2018, 06:34
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.