Can anyone help?

I wanted to create a simple ObjAsm32 MDI application, with minimal functionality.

First I copied the MDI example (Demo06) from the objasm32 package to to a new folder.
Then I copied the MdiApp.inc file from the \masm32\objasm32\code\objects folder to
the project folder, so I could add some debugging code to it if necessary.
Therefore in Demo06.asm I changed the line "LoadObjects MdiApp" to "include MdiApp.inc".

After building, and executing the project, everything was fine, as expected.

Now I wanted to replace DemoApp06's by a much simpler object.
So I decided to remove the Demo06.inc file from the project, and instead use a new
file: "MyMdiApp", which I added to the project

The main file for the project now looks like this:


%include @Environ(OA32_PATH)\\Code\\Macros\\Model.inc       ;Include & initialize standard modules
SysSetup OOP_WINDOWS;, DEBUG(WND, RESGUARD)                ;Loads OOP files and OS related objects

include Demo06_Globals.inc                                  ;Includes application globals
% include &MacPath&UStrings.inc                            ;Includes Unicode support for DlgTmpl
% include &MacPath&DlgTmpl.inc                              ;Includes Dlg Template macros for XMenu
IncludeBoth HtmlHelp

LoadObjects Stream, Collection                              ;Loads or builds the following objects
LoadObjects Button, Hyperlink
LoadObjects Dialog, DialogModal, DialogModalIndirect, DialogAboutIndirect
LoadObjects SimpleImageList, MaskedImageList
LoadObjects MsgInterceptor, XMenu
LoadObjects WinControl, Toolbar, Rebar, Statusbar, Tooltip
;LoadObjects MdiApp
include MdiApp.inc

.code
;include Demo06.inc                                          ;Includes DemoApp06 object
include MyMdiApp.inc

start:                                                      ;Program entry point
    SysInit                                                ;Runtime initialization of OOP model

    ResGuard_Start                                          ;Activates ResGuard
;    OCall @DemoApp06::DemoApp06.Init                        ;Initialize the object data
;    OCall @DemoApp06::DemoApp06.Run                        ;Execute the application
;    OCall @DemoApp06::DemoApp06.Done                        ;Finalize it
    OCall @MyMdiApp::MyMdiApp.Init                        ;Initialize the object data
    OCall @MyMdiApp::MyMdiApp.Run                        ;Execute the application
    OCall @MyMdiApp::MyMdiApp.Done                        ;Finalize it
    ResGuard_Show                                          ;Shows ResGuard results

    SysDone                                                ;Runtime finalization of the OOP model
    invoke ExitProcess, 0                                  ;Exits program returning 0 to the OS
end start


MyMdiApp.inc looks like this:


CLSSTYLE  equ   CS_BYTEALIGNWINDOW or CS_BYTEALIGNCLIENT or CS_VREDRAW or CS_HREDRAW

Object MyMdiApp,80000000,MdiApp
BoundMethod Startup
ObjectEnd

CStr szMyMdiApp, "MyMdiApp"

Method MyMdiApp.Startup
    local WC:WNDCLASSEX

@invoke MessageBox,NULL,"Starting up...","MyMdiApp",MB_OK

    mov WC.cbSize, sizeof WNDCLASSEX
    mov WC.style, CLSSTYLE
    m2m WC.lpfnWndProc, $MethodAddr(MyMdiApp.WndProc)
    mov WC.cbClsExtra, 0
    mov WC.cbWndExtra, 0
    m2m WC.hInstance, hInstance
    mov WC.hbrBackground, NULL
    mov WC.lpszMenuName, NULL
    mov WC.lpszClassName, offset szMyMdiApp
    mov WC.hIcon, $invoke(LoadImage, hInstance, "ICON_APP_32", IMAGE_ICON, 0, 0, LR_LOADREALSIZE)
    mov WC.hCursor, $invoke(LoadCursor, NULL, IDC_ARROW)
    mov WC.hIconSm, $invoke(LoadImage, hInstance, "ICON_APP_16", IMAGE_ICON, 0, 0, LR_LOADREALSIZE)

    invoke RegisterClassEx, addr WC
MethodEnd


Running this application I expected at least the frame window to show up.
The Startup method was executed, but the frame window didn't show up.
Now I put some debugging code in MdiApp.Init


Method MdiApp.Init, uses esi
    local dWwd:dword, dWht:dword
    local dWtx:dword, dWty:dword

    SetObject esi
    ACall esi::MdiApp.Init, NULL, NULL
    mov .pCommandLine, $invoke(GetCommandLine)

    ;Create the MDI Frame window
    mov dWwd, 600
    mov dWht, 450
    mov dWtx, $invoke(CenterForm, dWwd, $invoke(GetSystemMetrics, SM_CXSCREEN))
    mov dWty, $invoke(CenterForm, dWht, $invoke(GetSystemMetrics, SM_CYSCREEN))

    invoke CreateWindowEx, WS_EX_OVERLAPPEDWINDOW or WS_EX_APPWINDOW, \
          offset szMdiApp, offset szAppTitle, WS_OVERLAPPEDWINDOW, \
          dWtx, dWty, dWwd, dWht, NULL, NULL, hInstance, esi  ;Pass instance pointer


DbgDec eax ;This didn't produce any output, so I added the next few lines.
.if eax == 0
@invoke MessageBox,NULL,offset szMdiApp,offset szAppTitle,MB_OK
.endif


    invoke ShowWindow, .hWnd, SW_SHOWNORMAL
    invoke UpdateWindow, .hWnd

MethodEnd


The debugging code was executed, so the exit code of CreateWindowEx was zero.
That means: The frame window wasn't created at all.
At the same time the requested information on the strings was given:

szAppTitle  Value: "Demo06"
szMdiApp    Value: "MdiApp"


I don't understand why the frame window is not created. Am I forgetting something?
Does anyone have a clue?

Friendly regard,
mdevries.
Posted on 2006-11-18 14:01:11 by mdevries
Hi mdevries
The answer is so easy that you will not believe it?
I give you a hint? enable debugging, put DbgApiError after CreateWindowEx in the MdiApp.inc file and run the app again. The answer will be displayed.

?
invoke CreateWindowEx, WS_EX_OVERLAPPEDWINDOW or WS_EX_APPWINDOW, \
           offset szMdiApp, offset szAppTitle, WS_OVERLAPPEDWINDOW, \
           dWtx, dWty, dWwd, dWht, NULL, NULL, hInstance, esi   ;Pass instance pointer
DbgApiError
?


Regards,

Biterider

Attachments:
Posted on 2006-11-18 15:39:15 by Biterider
Hi Biterider,

Now I see. The window class that was registered is "MyMdiApp", while the creation of the window used "MdiApp" as classname.
So I changed

CStr szMyMdiApp, "MyMdiApp"


to

CStr szMyMdiApp, "MdiApp"


and now it works. Thanks!

Friendly regards,
mdevries.
Posted on 2006-11-19 09:41:49 by mdevries