Author Topic: CreateWindowEX  (Read 4903 times)

shankle

  • Member
  • ****
  • Posts: 837
CreateWindowEX
« on: May 29, 2014, 03:29:04 AM »
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.top],[RR.right],\
          [holdbottom1],NULL,NULL,[hInst],NULL
    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.

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: CreateWindowEX
« Reply #1 on: May 29, 2014, 03:44:15 AM »
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

RegisterClassEx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633587%28v=vs.85%29.aspx

WNDCLASSEX
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633577%28v=vs.85%29.aspx

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

shankle

  • Member
  • ****
  • Posts: 837
Re: CreateWindowEX
« Reply #2 on: May 29, 2014, 06:11:18 AM »
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)

WinMain:
    FRAME hInst,hPrevInst,CmdLine,CmdShow
   LOCAL ovl:WNDCLASSEXA,RR:RECT,hWnd
-------------------------------   
   mov   D[ovl.cbSize],SIZEOF WNDCLASSEXA
   mov   D[ovl.style],CS_BYTEALIGNWINDOW | CS_HREDRAW | CS_VREDRAW
   mov   rax,offset ScrnWndProc1
   mov   Q[ovl.lpfnWndProc],rax
   mov   D[ovl.cbClsExtra],NULL
   mov   D[ovl.cbWndExtra],NULL
   push  [hInst]
   pop   [ovl.hInstance]
   invoke LoadIcon,NULL,IDI_APPLICATION
   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
.n1   
    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
.n3
-----------
    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.top],[RR.right],\
          [holdbottom1],NULL,NULL,[hInst],NULL
    mov Q[hWnd],rax
« Last Edit: May 29, 2014, 10:30:35 AM by shankle »

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: CreateWindowEX
« Reply #3 on: May 29, 2014, 07:08:41 AM »
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

shankle

  • Member
  • ****
  • Posts: 837
Re: CreateWindowEX
« Reply #4 on: May 29, 2014, 08:02:56 AM »
I have added the WINDCLASS Code in the above example.

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: CreateWindowEX
« Reply #5 on: May 29, 2014, 08:23:45 AM »
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

also....

Code: [Select]
   invoke LoadIcon,NULL,IDI_APPLICATION
   mov   Q[ovl.hIcon], rax
   mov   Q[ovl.hIconSm],rax            ;initialize both icon handles

shankle

  • Member
  • ****
  • Posts: 837
Re: CreateWindowEX
« Reply #6 on: May 29, 2014, 10:31:28 AM »
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.
« Last Edit: May 30, 2014, 07:43:18 AM by shankle »