Not sure if Iczelion still browses these pages but thanks for the time invested in these tutorials and making the information available to others.

I stumbled on the tutorials about a week ago.  So this is the extent of my experience with assembler programming of any kind.
Fun, and  wow - tiny executables!

I wanted to know if there is a way to make a second window without the "canned" dialogs shown.  Hmm, I mean created like the first proc is made:

;.386
.486
.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

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
Child1 proto :HWND, :DWORD, :DWORD, :DWORD ; for Child window
;Child1 proto :DWORD, :DWORD, :DWORD, :DWORD ; for Child window


.data
ClassName db "WinClass",0
AppName  db "Test",0
ButtonClassName db "Button",0
ButtonText1 db "Hello",0
ChildClassName db "ChildWindow",0
ChildName1 db "Work",0
;hwndChild dd 0            ; Handle to child window box, rename to hwndChild1 ??
ButtonText3 db "Whatever",0 ; this goes here?


.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hwndButton HWND ?
hwndChild HWND ?

.const
ButtonID1 equ 1
ChildID2 equ 2
ButtonID3 equ 3 ; this goes here?

.code
start:
invoke GetModuleHandle, NULL
mov    hInstance,eax
invoke GetCommandLine ; omit if no command line option
mov    CommandLine,eax ; omit if
invoke WinMain, hInstance, NULL, CommandLine, 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 WndProc
mov  wc.cbClsExtra, NULL
mov  wc.cbWndExtra, NULL
; push  hInstance ;should be hInst ?
        push  hInst
pop  wc.hInstance
mov  wc.hbrBackground, COLOR_BACKGROUND
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,CW_USEDEFAULT,\
          CW_USEDEFAULT,300,200,NULL,NULL,\
          hInst,NULL
mov  hwnd, eax
invoke ShowWindow, hwnd, SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.while TRUE
invoke GetMessage, ADDR msg, NULL, 0, 0
.BREAK .IF (!eax)
;if to endif, is required only for child window that doesn't wait for response
        ;      .if hwndChild!=0
          ;              invoke IsDialogMessage,hwndChild,ADDR msg
          ;            .if eax==TRUE
            ;                    .continue
            ;          .endif
              ;  .endif
invoke TranslateMessage, ADDR msg ; not required if no keyboard input
invoke DispatchMessage, ADDR msg
.endw
mov    eax,msg.wParam
ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_DESTROY
invoke PostQuitMessage, NULL
; Button and textbox control:
.elseif uMsg==WM_CREATE
invoke CreateWindowEx,NULL, ADDR ButtonClassName,ADDR ButtonText1,\
                        WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\
                        50,50,120,35,hWnd,ButtonID1,hInstance,NULL
mov  hwndButton,eax

.elseif uMsg==WM_COMMAND
mov eax,wParam
.if ax==ButtonID1
shr eax,16
.if ax==BN_CLICKED
;do something
invoke CreateWindowEx,NULL,ADDR ChildClassName,ADDR ChildName1,\
          WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
        CW_USEDEFAULT,100,100,hWnd,ChildID2,\
      hInstance,NULL
mov hwndChild,eax
; invoke ShowWindow, hwndChild, SW_SHOWNORMAL
; invoke UpdateWindow, hwndChild

.endif
.endif

.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
.endif
xor eax,eax
ret
WndProc endp

;Child1 proc hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM
Child1 proc hWnd:HWND,iMsg:UINT,wParam:WPARAM, lParam:LPARAM

        .if iMsg==WM_INITDIALOG
invoke SetFocus,eax
        .elseif iMsg==WM_CLOSE
invoke EndDialog,hWnd,NULL
mov hwndChild,0 ;this was missing from the wait for response version, so ???
.elseif iMsg==WM_CREATE
invoke CreateWindowEx,NULL, ADDR ButtonClassName,ADDR ButtonText3,\
                        WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\
                        50,50,120,35,hWnd,ButtonID3,hInstance,NULL
mov  hwndButton,eax

        .elseif iMsg==WM_COMMAND
.if ax==ButtonID3
shr eax,16
.if ax==BN_CLICKED
;do something

.endif
.endif

 
        .else
mov eax,FALSE
ret
        .endif
        mov  eax,TRUE
        ret
Child1 endp
end start

Does this make sense?  Can you do this and how to make the 2nd window show?
Thankyou, Squeeto
Posted on 2006-03-04 16:09:47 by Squeeto
Squeeto,

I attached a program in the following post:

http://www.masmforum.com/simple/index.php?topic=2942.0

It's in FASM syntax but should be clear, I hope it's what you can use.

farrier
Posted on 2006-03-04 17:35:27 by farrier
Hey Farrier,
Thanks, got tabwindows.zip.
Will get back to you.
Posted on 2006-03-05 10:45:40 by Squeeto
Attached is a small example creating a window, with a few child windows which can be tabbed from one to the other.


Ok, no way for me to compile this but it creates a few new window frames?!  Except for the MessageBox, I can't see it.  Remember that I am about a week old.
I definitely do want two frames showing on the desktop.
Posted on 2006-03-05 19:17:29 by Squeeto
Squeeto,

The code for Creating Windows is pretty standard.  If you are using MASM32, you can translate.  Or, go to Flatassembler.net/download and download the FASM for Windows.  It is small, fast, open source and actively supported.  The code is very similar to MASM32.

farrier

Attachment contains .asm file and .exe

The key to making the tabs work was the following in the message loop:

.while TRUE
invoke GetMessage, msg, NULL, 0, 0
.if eax, e, 0
jmp @f
.endif
invoke TranslateAccelerator, , , msg
.if eax, e, 0
invoke IsDialogMessage, , msg              ;<-Needed for tab handling!!!
.if eax, e, 0
invoke TranslateMessage, msg
invoke DispatchMessage, msg
.endif
.endif
.endw
@@:
mov eax,
invoke ExitProcess, 0
Attachments:
Posted on 2006-03-05 20:08:01 by farrier
Attachment contains .asm file and .exe

Must have been changed.  TabWindows.zip contains only the .asm file.  Could you post the .exe?
Posted on 2006-03-05 23:27:55 by Squeeto
I am probably not using the correct assembler terms so...
I have attached an executable to show what I want.?  Compiled/linked with gcc (875k yikes!) :shock:

I'll bet this can be done under 4k with fasm/masm.

Sorry can't post .... too large.  Pointless ....

I could post the code but it's in java SWT
Posted on 2006-03-05 23:43:35 by Squeeto
Squeeto,

Not sure what happened :shock:

Here it is:

farrier
Attachments:
Posted on 2006-03-06 00:26:22 by farrier
hi, farrier!
your example fails on w2k: it says "kernel32 not found". you have to add extensions (".dll") there into the import declaration.
regards!
Posted on 2006-03-07 05:16:27 by Shoo
Shoo,

I've haven't seen that before.  The previous exe ran--as is--on 95 and xp.  I don't have w2k.

I added the .dll extension to all, and included the source and exe in this attachment.  Let me know.

farrier
Attachments:
Posted on 2006-03-07 08:53:32 by farrier
Yes, your latest prog now runs on W2K :)

The tabbing works fine but, as I suspected, it doesn't create a 2nd frame on the desktop except for the messagebox.

I am currently playing with dialogs; the predispositioned ones that come with a resource file and called from CreateDialogParam or DialogBoxParam.  But instead, I would like to create another fully functioning window frame (yet still a child of the first), modeless or modal.  Haven't seen this done yet so I am not sure that it is possible.

My code above does compile and link without error but pushing the button doesn,t 'show' the 2nd frame.

Sorry to the moderator if this code is out-of -place for this forum:
If it were java (SWT) I would-

...
      button1.addSelectionListener(new SelectionAdapter()
      {
        public void widgetSelected(SelectionEvent event)
        {
          Sub1 sub1 = new Sub1(shell);
          sub1.open();
        }
      });

    shell.open();
    return shell;
  }

  class Sub1 extends Dialog
  {
    Shell shell;
...




Posted on 2006-03-08 16:37:22 by Squeeto
I'm not exactly sure, I've just now looked at this thread, but from the above code Squeeto posted, he's trying to simply create a child window without using dialogs or messagebox... If that is the case I just coded up a quick example that does that in Masm32. Squeeto, check this out and let me know if that's what you were looking for. The source is pretty easy and if you have any questions about it post back here.

Regards,
Bryant Keller
Attachments:
Posted on 2006-03-08 18:23:26 by Synfire
@Synfire
Thanks, perfect :D
And only 4k in size.  I am going to attempt a project to see how long the coding process takes.
ASM is surely for those who want complete control.

Thanks and sorry Farrier for not responding very quickly to your uploads.  I would check back but never saw the attachment clip.
I just realized today, after others were getting downloads that I needed to be logged on to see them. 
Is this typical for everyone?  I know that maybe because I run the Opera Browser exclusively that I may miss out on some features.

Squeeto
Posted on 2006-03-09 11:18:06 by Squeeto
Squeeto,

My curiosity is killing me!  Why do you need the separate "WndProc" for each control?

???

farrier
Posted on 2006-03-09 14:31:59 by farrier

Squeeto,

My curiosity is killing me!  Why do you need the separate "WndProc" for each control?

???

farrier


What he was looking for is a way to make child windows (similar to MDI) but not encapsulated into the parent control. I use this myself instead of dialogs just because I like to minimize what's in the resource section. The sub window isn't a control specifically, it's just another window like the primary one, except the primary one owns it and can send messages to it directly. I just figured from his post he just wanted to build his child windows (like for example an About window) from scratch without loading up a dialog for it in the resource section. Also, if multiple child windows deal with the same messages they can all use the same wndproc so it's not like you have to code a seperate wndproc for each child in all circumstances.



        .if ax==BN_CLICKED
            ;do something
            invoke CreateWindowEx,NULL,ADDR ChildClassName,ADDR ChildName1,\
                  WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
                CW_USEDEFAULT,100,100,hWnd,ChildID2,\
                  hInstance,NULL
            mov hwndChild,eax
        ;  invoke ShowWindow, hwndChild, SW_SHOWNORMAL
        ;  invoke UpdateWindow, hwndChild



Squeeto,
Btw, the error there is that you need to register a new window class for your child window. You are simply calling CreateWindowEx, this function is failing because there is no window class registered for the "ChildWindow" class yet. In my source you will notice I build the WNDCLASSEX structure and register the new window before trying to create it.

Regards,
Bryant Keller
Posted on 2006-03-09 15:17:20 by Synfire

My curiosity is killing me!  Why do you need the separate "WndProc" for each control?

Synfire pretty much covered it.  I also (eventually) want to code a gui for many of the command line apps I use to video edit (I have a dv camera and a 3 year old daughter).  There are so many steps and possible directions (and message boxes) you need to take when you author a dvd that I only found it simple to achieve with multiple frames working side by side.
I have it coded in java now but, statically compiled and linked, it comes in over a meg (just the gui)!

Synfire
I battled with this for a while; sometimes it's even as simple as a capital instead of a small letter.  Until you have seen it once....
And why reinvent the wheel?  I'll probably be back with something else later. ;)

Thanks guys
Posted on 2006-03-09 18:55:06 by Squeeto