Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu


Started by shankle, May 29, 2014, 03:29:04 AM

Previous topic - Next topic


szdisplayname1  db 'blah',0
AppName          db  30 dup (0)
HoldBottom1     dd  0
hInst         ( in the Frame statement)
hWnd        ( in the Local statement)

    invoke CreateWindowEx, NULL,addr szDisplayName1,addr AppName,\
          WS_VSCROLL or WS_OVERLAPPEDWINDOW,[RR.left],[],[RR.right],\
    mov Q[hWnd],rax

This code has worked in many GoAsm programs. Same code works in MASM32.
GetLastError and I do not get along well.


you have to register the window class, using the AppName string
then, when you CreateWindowEx, it will find the registered class with the same string



notice that you need a WndProc to register
the WM_CREATE handler in WndProc should return a 0
if it returns -1, the window is not created


My 1st example was pitiful. I apologize.
I think this one includes all necessary code.

This code makes szDisplayName1 and AppName the same.
RegisterClassEx was moved after filling those 2 fields.
It didn't work.

BytesRead         dq   0
hFile4               dq   0
holdbottom1      dd   0
savemiddleofY    dd   0       ; vertical middle of screen
AppName          db   30 dup (0)
prog1               db   30 dup (0)
szDisplayName1   db   30 dup (0)

    FRAME hInst,hPrevInst,CmdLine,CmdShow
   mov   D[ovl.cbSize],SIZEOF WNDCLASSEXA
   mov   rax,offset ScrnWndProc1
   mov   Q[ovl.lpfnWndProc],rax
   mov   D[ovl.cbClsExtra],NULL
   mov   D[ovl.cbWndExtra],NULL
   push  [hInst]
   pop   [ovl.hInstance]
   mov   Q[ovl.hIcon], rax   
    invoke LoadCursor,NULL,IDC_ARROW
   mov   Q[ovl.hCursor],rax
   invoke CreateSolidBrush,[colorbk]          ; background color
    mov   Q[hBrush],rax
   mov   Q[ovl.hbrBackground],rax
   mov   Q[ovl.lpszMenuName],NULL
   mov   Q[ovl.lpszClassName],offset szDisplayName1
   mov   Q[ovl.hIconSm],0
    invoke ReadFile, [hFile4],addr prog1,30,addr BytesRead,NULL
    xor rsi,rsi
    cmp rsi,30         ; this puts the keyed in name to AppName
    jge >>.n3
    mov al,B[prog1+rsi]
    mov B[AppName+rsi],al
    mov B[szDisplayName1+rsi],al
    inc rsi
   jmp <.n1
    mov eax,[RR.bottom]
    shr eax,1
    mov D[holdbottom1],eax      ; vertical middle of screen
    invoke RegisterClassEx, addr ovl
    invoke SystemParametersInfo, SPI_GETWORKAREA,0,addr RR,0
    invoke CreateWindowEx, NULL,addr szDisplayName1,addr AppName,\
          WS_VSCROLL or WS_OVERLAPPEDWINDOW,[RR.left],[],[RR.right],\
    mov Q[hWnd],rax


well - it's 64-bit and GoAsm
i live in 32-bit Masm world   :lol:

first - i don't see any code that initializes the WNDCLASSEX structure

second - you must use the same string you used to register the class as you do to create the window
you can change the window title, but not the class string
if you want to use a specific class name (from file), intialize it before RegisterClassEx

finally, the dimension arguments for CreateWindowEx are not left,top,right,bottom
they are left,top,width,height
just use some constants to get it going - then set them to variables


I have added the WINDCLASS Code in the above example.


you still have the same problem, Jack
in the WNDCLASSEX structure is a pointer to a string
i think it's called lpszClassName or something like that

you want to read the file to initialize AppName (before RegisterClassEx)
then, initialize lpszClassName with a pointer to AppName
then register the class

when you create the window, you want to pass a pointer to the same string
those strings have to match
that's how Windows finds the class you want to use to create the window


   mov   Q[ovl.hIcon], rax
   mov   Q[ovl.hIconSm],rax            ;initialize both icon handles


I have modified #2 again and still no luck.

Seems my problem might have something to do with Unicode and Ansi.
I have many programs that work in 64 bit without worrying about this condition.
So one wonders why now.