Hi everybody, I made a dialog using a resource file. When I use CreateWindowEx,in the code, to create a button or an edit control, it doesn't work : it returns 0, not the handle. Please What is the problem ???
Posted on 2001-04-22 17:09:00 by Vom-bonjour:-()
did you specify a class name in your resource ? .rc: CLASS "myWindowClass" .asm: WindowClass db "myWindowClass",0 ;pointer for your windowclass HOPE THAT HELPS OLLI This message was edited by Typhoon, on 4/22/2001 10:12:23 PM
Posted on 2001-04-22 22:10:00 by Typhoon
No that's not what I wanted to say: -I have a dialog made by a resource file. -I want to put a button in it using the code, not using the resource. The dialog is well-displayed but when, in the code, I use CreateWindowEx API, it returns 0, so it doesn't display a button. I checked the classes, ... Maybe the style of the dialog is wrong, I don't know. But I can't create the button. Mail me if you wan't to help me, and I will send you the code. Thanx very much. PS:if I use CreateWindowEx and RegisterClass to create my window instead of using resource, it works. I could do like that, but I would like to know what the matter is. My mail:cool:
Posted on 2001-04-23 07:40:00 by Vom-bonjour:-()
The following code works for me:

DlgProc     PROTO :DWORD,:DWORD,:DWORD,:DWORD

.DATA
DlgName     db "MyDlg",0
EditClass   db "BUTTON",0
Buffer      db 64 dup (0)

.DATA?
hInstance   dd ?

.CODE

start:
    invoke GetModuleHandle, NULL
    mov    hInstance,eax                     
    invoke DialogBoxParam, eax, ADDR DlgName, NULL, addr DlgProc, NULL           
    invoke ExitProcess, eax

DlgProc PROC hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
    .IF uMsg == WM_INITDIALOG		
        invoke CreateWindowEx, NULL,\
                ADDR EditClass, NULL,\
                WS_CHILD or WS_VISIBLE,\
                100, 100, 100, 100,\
                hWnd, NULL, hInstance, NULL
        
        mov ecx, 32
        .REPEAT
            xor edx, edx
            shl ax, 1
            adc dl, 48
            mov Buffer, dl
            dec ecx
        .UNTIL ecx == 0

        invoke MessageBox, NULL, ADDR Buffer, NULL, MB_OK

    .ELSEIF uMsg == WM_CLOSE
        invoke EndDialog, hWnd, NULL

    .ELSE
        mov eax,FALSE
        ret
    .ENDIF

    mov eax,TRUE
    ret           
DlgProc endp

END start
With an rsrc.rc of:

#include "resource.h"
MyDlg DIALOG 10, 10, 277, 252
STYLE DS_MODALFRAME | 0x804L | WS_OVERLAPPED | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
CAPTION "Title"
{
}
Mirno
Posted on 2001-04-23 08:36:00 by Mirno
Thanx, I found my problem. You will laugh: I forgot to put "addr " before the caption of the button. maybe I was dreaming when I wrote this !:rolleyes:
Posted on 2001-04-23 16:11:00 by Vom-bonjour:-()
........where could I get good tutorial on dialog boxes???
Posted on 2001-04-23 16:20:00 by *unknown*
I read all Iczelion´s tutotials. It helped me a lot with DIALOG BOXES, either with rc either with direct method: CreateWindowEx. Try it. Hope this help. :)
Posted on 2001-04-25 06:24:00 by wolfao