News:

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

I think I have had enough

Started by metron9, October 02, 2007, 03:34:32 AM

Previous topic - Next topic

metron9

Is there something wron with this code? It compiles and links and runs fine but when I add

hButton HWND in the .data section

and the following two lines in the OnResize method

Invoke GetWindowItem, [hButton], IDC_WINMAIN_BUTTON1
Invoke SetText, [hButton], Addr clientDimension

I get

Compiling resources...
Assembling: winMain
Linking...

Error!  The system could not make the output file (firstwindow.exe)  Output file not made 

Errors ocurred.

Then I unchecked debug info for the build and it compiled linked and ran but no output to button text. Then it would not compile again. If I save it and reload the program it compiles and links again.


I think it is all due to Vista i am afraid. So, for now I am going to go to command line only using my old BoxerEditor and give MASM32 a whirl.


Geesh, I downloaded the turbo c$ and installed it, but realized I had downloaded the c++ version a few days ago, I installed the c++ and now the borland licence checker wont allow me to run C#.  Oh well I guess I can download VSC# from microsoft as I can't begin to find an email for borland support.



Ramon Sala

Hi metron9,

The GetWindowItem method returns the handle (in Eax) of any child control inside a window. The first parameter (hButton in your example) has to be the handle of the window. If hButton has no value, GetWindowItem returns NULL. Anyway, the returned value (the handle of the IDC_WINMAIN_BUTTON1 control) is in register Eax, so try the following:

Invoke GetWindowItem, [hButton], IDC_WINMAIN_BUTTON1
Invoke SetText, Eax, Addr clientDimension

That will work ONLY if hButton is the handle of the window. If not, if you just declared hButton and it has no value, then try the following code:

Invoke GetWindowItem, [hWnd], IDC_WINMAIN_BUTTON1
Invoke SetText, Eax, Addr clientDimension

Greetings from Catalonia

metron9

Here is the code, I really think its just windows vista that is the problem.   I tried it, it did run but did not change the text in Button1. Then I looked behind the main easy code window and there is a popup that says easy code is not working, so vista sucks for this me thinks.



.Const

.Data

MESSAGES DD WM_CREATE, OnCreate
DD WM_CLOSE, OnClose
DD WM_SIZE, OnResize

clientrect RECT

hButton hWnd

clientDimensions DB 11 Dup 0


.Code

winMainProcedure Frame hWnd, uMsg, wParam, lParam
Mov Eax, [uMsg]
Mov Ecx, SizeOf MESSAGES / 8
Mov Edx, Addr MESSAGES
: Dec Ecx
Js >L2
Cmp [Edx + Ecx * 8], Eax
Jne <
Call [Edx + Ecx * 8 + 4]
Ret
L2: Return (FALSE)
EndF

OnCreate:
UseData winMainProcedure
;==================================
;Write the initialization code here
;==================================
Return (TRUE)
EndU

OnClose:
UseData winMainProcedure
;=========================
;Write the final code here
;=========================
Invoke IsModal, [hWnd]
Or Eax, Eax ;Cmp Eax, FALSE
Jz >
Invoke EndModal, [hWnd], IDCANCEL
Mov Eax, TRUE ;Return (TRUE)
: Ret
EndU

mainwindowGroup1 Frame hWnd, uMsg, wParam, lParam
Return (FALSE)
EndF

winMainStatic1 Frame hWnd, uMsg, wParam, lParam
Return (FALSE)
EndF

winMainButton1 Frame hWnd, uMsg, wParam, lParam
Return (FALSE)
EndF
OnResize:
UseData winMainProcedure

Invoke GetClientRect, [hWnd], Addr clientrect
Invoke String, [clientrect.right], Addr clientDimensions, ecDecimal
Invoke SetText, [hWnd], Addr clientDimensions

Invoke GetWindowItem, [hButton], IDC_WINMAIN_BUTTON1
Invoke SetText, Eax, Addr clientDimensions

Return (TRUE)

EndU




Ramon Sala

Hi metron9,

Please pay attemtion. After looking at your code, I can see hButton is a declared variable which has no valid value. As a result,  in the OnResize message when you call:

   Invoke GetWindowItem, [hButton], IDC_WINMAIN_BUTTON1

it returns NULL because no valid handle has been passed (hButton is nothing). To get the handle of Button1 properly, pass the handle of winMain (hWnd) to the GetWindowItem method and everything will work fine. So in the piece of code:

   Invoke GetWindowItem, [hButton], IDC_WINMAIN_BUTTON1
   Invoke SetText, Eax, Addr clientDimensions


just replace hButton with hWnd like this:

   Invoke GetWindowItem, [hWnd], IDC_WINMAIN_BUTTON1
   Invoke SetText, Eax, Addr clientDimensions


Now it works!


Here is the modified code:

.Const

.Data

MESSAGES   DD WM_CREATE, OnCreate
         DD WM_SIZE, OnResize
         DD WM_CLOSE, OnClose

clientrect   RECT

hButton      hWnd

clientDimensions   DB 11 Dup 0


.Code

winMainProcedure Frame hWnd, uMsg, wParam, lParam
   Mov Eax, [uMsg]
   Mov Ecx, SizeOf MESSAGES / 8
   Mov Edx, Addr MESSAGES
:   Dec Ecx
   Js >L2
   Cmp [Edx + Ecx * 8], Eax
   Jne <
   Call [Edx + Ecx * 8 + 4]
   Ret
L2:   Return (FALSE)
EndF

OnCreate:
   UseData winMainProcedure
   ;==================================
   ;Write the initialization code here
   ;==================================
   Return (TRUE)
EndU

OnClose:
   UseData winMainProcedure
   ;=========================
   ;Write the final code here
   ;=========================
   Invoke IsModal, [hWnd]
   Or Eax, Eax      ;Cmp Eax, FALSE
   Jz >
   Invoke EndModal, [hWnd], IDCANCEL
   Mov Eax, TRUE   ;Return (TRUE)
:   Ret
EndU

winMainGroup1 Frame hWnd, uMsg, wParam, lParam
   Return (FALSE)
EndF

winMainStatic1 Frame hWnd, uMsg, wParam, lParam
   Return (FALSE)
EndF

winMainButton1 Frame hWnd, uMsg, wParam, lParam
   Return (FALSE)
EndF

OnResize:
   UseData winMainProcedure
   
   Invoke GetClientRect, [hWnd], Addr clientrect
   Invoke String, [clientrect.right], Addr clientDimensions, ecDecimal
   Invoke SetText, [hWnd], Addr clientDimensions

   ;hButton has been replaced with hWnd
   Invoke GetWindowItem, [hWnd], IDC_WINMAIN_BUTTON1
   Invoke SetText, Eax, Addr clientDimensions

   Return (TRUE)

EndU


Greetings from Catalonia

metron9

Hey i tried it and it works, thanks. I need to study how these handles work. That really helps me though to get past these bumps, I appreciate it.