News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Child window problem

Started by fushiyun, February 01, 2008, 03:45:38 PM

Previous topic - Next topic

fushiyun

i attemp to create a window with two child window.
this can be done by using CreateWindow mehod with WS_CHILD.
but i like to add a EDIT to each child window.

the problem is that the child window and EDIT can't work correctly.
first: EDIT can not obtain a focus when i use mouse
second: child window can't re-paint

who can get me some suggestion about how to implement this.
thank you.

before, i attemp to modify "masm32\examples\exampl04\multiwin" source code, as follows:

       invoke CreateWindowEx,WS_EX_LEFT,
                            ADDR szClassName,
                            ADDR tChild1,
                            WS_CHILD or WS_OVERLAPPEDWINDOW,
                            50,50,150,100,
                            hWnd,NULL,
                            hInst,NULL
      mov hChild1, eax
     
      invoke CreateWindowEx,WS_EX_LEFT,
                            ADDR szEditName,
                            ADDR tChild1,
                            WS_CHILD or WS_VISIBLE or WS_BORDER,
                            0,0,50,50,
                            hChild1,NULL,
                            hInst,NULL
      mov hEdit1, eax

jj2007

Quote from: fushiyun on February 01, 2008, 03:45:38 PM
                            ADDR szClassName,
                            ADDR tChild1,
                            ...
                            ADDR szEditName,
                            ADDR tChild1,
It might help if you showed which names you are actually using.

fushiyun

thank jj2007 reply.


szClassName and szEditName show as follows:
szClassName,"Project_Class",0
szEditName db "EDIT",0


Notice that szClassName is a registered class by using RegisterClass in "masm32\examples\exampl04\multiwin"
i don't modify it.
i only add CreateWindow for EDIT in multiwin.asm

jj2007

Hi Fushiyun,
You create a child of a child:
      invoke CreateWindowEx,WS_EX_LEFT,
                            ADDR szEditName,
                            ADDR tChild1,
                            WS_CHILD or WS_VISIBLE or WS_BORDER,
                            0,0,50,50,
                            hChild1,NULL,  ; <------
                            hInst,NULL


Try replacing hChild1 with hWnd. For me it works...

fushiyun

thank jj2007 answer.

but it isn't that i want. :red
i hope to create a EDIT window with system menu and title bar.
therefore, i think that i can create a window and then attach a EDIT on it.
but i suffer from some problems as previous post.

i know that the MDI interface can achieve this task.
but it is so complex that i think i can create many EDIT window with system menu and title bar.
it seem easy to implement for me. :bg

the attachment is the modify source code from "masm32\examples\exampl04\multiwin".
you can try to execute it and click mouse on EDIT. thank.


[attachment deleted by admin]

MichaelW

Take a look at masm32\examples\exampl01\regkey\regkey.asm. The example uses CreateWindowEx to create 3 static controls, 3 single line edit controls, and one button, all as child controls in a main window, also created with CreateWindowEx.
eschew obfuscation

fushiyun

thank MichaelW reply.

i am sorry.
it isn't that i want again. :(

because no any title bar and system menu on each child control.

i hope that i can create a child control with system menu and title bar.
and this child control must be attached a EDIT control on itself.

my problem maybe is that i don't know how to re-paint the EDIT control.
so, hope some body get me some suggestion, thank. :bg

MichaelW

You may be able to make something like this work without MDI, but by the time you do I think you will have more time and effort in it than would be required to do it with MDI.
eschew obfuscation

fushiyun

Thank MichaelW and jj2007.  :U

ha-ha
i think that it may be a more easy task by using MDI interface.

i like this forum because you are very friendly towards newcomers.
although my english is poor, i will like to post when i suffer from some problems.
thank you. :U

jj2007

Don't give up too early... try the code below. I used .IF 1 ... else ... endif to let you compare between yours and mine.


    ; ------------------------------------------------------
    ; Because the second window uses the same classname it
    ; also uses the same WndProc for message processing.
    ; ------------------------------------------------------
      invoke CreateWindowEx,WS_EX_LEFT,
                            ADDR szClassName,
                            ADDR tChild1,
                            WS_CHILD or WS_OVERLAPPEDWINDOW,
                            15000,50,150,100,
                            hWnd,NULL,
                            hInst,NULL
      mov hChild1, eax
     
.if 1
invoke CreateWindowEx,WS_EX_LEFT,
                            ADDR szEditName,
                            ADDR tChild1,
                            WS_VISIBLE or WS_BORDER,
                            0,0,120,50,
                            hChild1,NULL,
                            hInst,NULL
mov hEdit1, eax
invoke GetWindowLong, hEdit1, GWL_STYLE
or eax, WS_OVERLAPPEDWINDOW ; the trick
invoke SetWindowLong, hEdit1, GWL_STYLE, eax
invoke SetParent, hEdit1, hWnd
; no effect: invoke ShowWindow, hChild1, SW_MINIMIZE

.else

      invoke CreateWindowEx,WS_EX_LEFT,
                            ADDR szEditName,
                            ADDR tChild1,
                            WS_CHILD or WS_VISIBLE or WS_BORDER,
                            0,0,120,50,
                            hChild1,NULL,
                            hInst,NULL
      mov hEdit1, eax

.endif

    ; ------------------------------
    ; menu attached to child window
    ; ------------------------------

jj2007

One more - this should come extremely close to what you want.

[attachment deleted by admin]

fushiyun

oh! my god!

i can't believe that i am success! :bg
very very very thank jj2007. :U

before soon time, i am able to give up that.
because i know that i just only a choice, that is, MDI.
i can't believe SetParent() can achieve that function i want.

i am very happy.:bg

but now, i have a new question about the difference between WS_CHILD and SetParent()
i specify a WS_CHILD flag in CreateWindow and set the parameter of hWndParent as hWnd.
is this difference compared with SetParent() ?
why the SetParent() can achieve that task ?

the attachment is that i want. :lol

[attachment deleted by admin]

ToutEnMasm

Hello,
SDI are abble to work with all the controls  that you want.
There is rules to make them.
The class name must be unique.
Styles and extanded styles couldn't be what you want.
for mother window
WS_EX_LEFT
WS_OVERLAPPEDWINDOW or WS_CLIPCHILDREN
for child windows
WS_CHILD or WS_OVERLAPPEDWINDOW

The IDE i write use only SDI windows with many controls on it.There is no limitations on SDI,that is wrong.
Following rules,SDI can be write very easily.
The only problem is that everyone think he is abble to write his windows as he want.
That is the very wrong idea.
Microsoft is the one who can use styles,extended styles without problems.
Follow his samples and you have no problems.






fushiyun

thank ToutEnMasm  to reply.

i am sorry about that i don't understand what you mean.

1. SDI are abble to work with all the controls  that you want.
2. The IDE i write use only SDI windows with many controls on it.There is no limitations on SDI,that is wrong.


for 1., i use SDI and specific the style of WS_OVERLAPPEDWINDOW or WS_CLIPCHILDREN to create a main window
and then i created a child window, the style of which are WS_CHILD or WS_OVERLAPPEDWINDOW.
but i use the class name of "EDIT" for the child window.
i hope that i can create a EDIT child window with a title bar and system menu.
however, the result is same as previous one i posted. :( (the EDIT can't be typed by keyboard)

for 2., the IDE you written whether they have with a title bar and system menu.
and what you mean as followig sentence.
There is no limitations on SDI,that is wrong.

thank you.


ToutEnMasm

Hello,
You can't use  the name 'EDIT' for the child window.It's a reserved word for the 'EDIT' control.
Rename your child window and the problem will be solved with the EDIT control.