News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Problem with wc.cbSize

Started by majid1605, December 13, 2011, 10:32:59 AM

Previous topic - Next topic

majid1605

Hi
what is the problem program with wc.cbSize

Height does not change the window size

.486
.model flat,stdcall
option casemap:none
 
     
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
 
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\msvcrt.inc ;crt__ultoa
include     \masm32\macros\macros.asm


includelib  \masm32\lib\user32.lib
includelib  \masm32\lib\kernel32.lib
includelib \masm32\lib\msvcrt.lib  ;crt__ultoa


     
     
.data
ClassName db "SimpleWinClass",0
AppName  db "Local Time",0


MyString      DB 20 dup(' '),0

LTimeis     db "LocalTime is: "
HTime       DB   2 dup (' ')
SymTime     db ':'
STime       DB   2 dup (' ')
            db 0     


.data?

hInstance HINSTANCE ?
CommandLine LPSTR ?


width_w       WORD ?
height_w   WORD ?

stimestruct STRUCT     
       wYear            WORD ?   
       wMonth           WORD ?
       wDayOfWeek       WORD ?
       wDay             WORD ?
       wHour            WORD ?
       wMinute          WORD ?
       wSecond          WORD ?
       wMilliseconds    WORD ?
    stimestruct EndS
       
    stime stimestruct {}
 
 
     

.code
start:
    invoke GetModuleHandle, NULL
    mov    hInstance,eax
    invoke GetCommandLine
    mov CommandLine,eax
    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  hInst
    pop   wc.hInstance
    mov   wc.hbrBackground,COLOR_WINDOW+1
    mov   wc.lpszMenuName,NULL
    mov   wc.lpszClassName,OFFSET ClassName
    invoke LoadIcon,NULL,IDI_APPLICATION
    mov   wc.hIcon,eax
    mov   wc.hIconSm,0
    invoke LoadCursor,NULL,IDC_ARROW
    mov   wc.hCursor,eax
mov     width_w,200
mov   height_w,200
    invoke RegisterClassEx, addr wc
    INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
           WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
           CW_USEDEFAULT,width_w,height_w,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)
                INVOKE TranslateMessage, ADDR msg
                INVOKE DispatchMessage, ADDR msg
    .ENDW
    mov     eax,msg.wParam
    ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
    LOCAL hdc:HDC
    LOCAL ps:PAINTSTRUCT
    LOCAL rect:RECT
    .IF uMsg==WM_DESTROY
        invoke PostQuitMessage,NULL
    .ELSEIF uMsg==WM_PAINT
        invoke BeginPaint,hWnd, ADDR ps
        mov    hdc,eax
        invoke GetClientRect,hWnd, ADDR rect
        call    LTimep
        invoke DrawText, hdc,ADDR LTimeis,-1, ADDR rect, DT_SINGLELINE or DT_CENTER or DT_VCENTER
        invoke EndPaint,hWnd, ADDR ps
    .ELSE     
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam
        ret
    .ENDIF       
    xor    eax,eax
    ret
WndProc endp

LTimep proc
    lea ebx,stime
    push ebx
    call GetLocalTime
     
    xor eax,eax
    mov al,byte ptr [ebx].stimestruct.wHour
    invoke crt__ultoa,eax,ADDR MyString,10

    mov ax,word ptr MyString
    mov word ptr HTime,ax
    cmp HTime+1,0
    jne next
    mov al,HTime
    xchg HTime+1,al
    mov HTime,' '
next: 
     
    xor eax,eax
    mov  al,byte ptr [ebx].stimestruct.wMinute
    invoke crt__ultoa,eax,ADDR MyString,10
     
     
    mov ax,word ptr MyString
    mov word ptr STime,ax
    cmp STime+1,0
    jne next2
    mov STime,al
next2:


    ret
LTimep endp   
end start

jj2007

mov height_w, 300

Works fine here - what exactly is your problem?

majid1605




The above picture shows everything.give any value to the height ، it's not change

I using Windows 7

Gunner

Createwindow expects a dword for the size not a word?
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

majid1605

Quote from: Gunner on December 13, 2011, 12:22:32 PM
Createwindow expects a dword for the size not a word?
:dazzled:
Thank you very much :clap:

jj2007

Quote from: Gunner on December 13, 2011, 12:22:32 PM
Createwindow expects a dword for the size not a word?

:U

Interestingly enough, ML.exe version 6.14, 6.15 and 8.0 push words, while version 9 and JWasm push a DWORD. That is why my executable worked fine - I use JWasm by default.

kero

but what is the problem with wc.cbSize ?  :)

dedndave

cbSize is a dword that represents the size of the WNDCLASSEX structure, in bytes
it has nothing to do with the size of the window
        mov     wc.cbSize,sizeof WNDCLASSEX   ; =48