Hi,
my rsrc.rc file is
Quote
// file rsrc.rc
// ***************
#define IDM_Caso1 1000
#define IDM_Close 1800
#define IDM_Help 1900
MENUWINDOWS1 MENU
{
POPUP "&Caso1"
{
MENUITEM "&Caso 1 ", IDM_Caso1
}
POPUP "&Help"
{
MENUITEM "&About ", IDM_Help
MENUITEM "&Close ", IDM_Close
}
// MENUITEM "&Close", IDM_Close
}
my main prog is
Quote
.586 ; minimum processor needed for 32 bit
.model flat, stdcall ; FLAT memory model & STDCALL calling
option casemap :none ; set code to case sensitive
; #############################################################
include \masm32\include\windows.inc
include \masm32\macros\macros.asm
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
;..............................................
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
; ###################################################
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
; ###################################################
; defined in resource file
;
IDM_Caso1 equ 1000
IDM_Close equ 1800
IDM_Help equ 1900
; ############################################################
.data
_MenuName db "MENUWINDOWS1", 0 ; definido em rsrc.rc
_ClassName db "Generic_Class", 0
_DisplayName db "Windows 1", 0
_TheMsg db "Programa em Assembler", 0
_hWnd dd 0
_hInstance dd 0
.data?
_msg MSG <?>
_wc WNDCLASSEX <>
; ######################################################
.code
; -----------------------------------------------------------------------
_start:
invoke GetModuleHandle, 0
mov _hInstance, eax
invoke WinMain, _hInstance, 0, 0, SW_SHOWDEFAULT
invoke ExitProcess, 0
; #############################################################
WinMain proc hInst:DWORD, hPrevInst:DWORD, CmdLine:DWORD, CmdShow:DWORD
LOCAL wc :WNDCLASSEX
LOCAL msg:MSG
mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc, offset WndProc ; address of WndProc
mov wc.cbClsExtra, 0
mov wc.cbWndExtra, 0
mov eax, hInst
mov wc.hInstance, eax
mov wc.hbrBackground, COLOR_BTNFACE+1 ; system color
mov wc.lpszMenuName, offset _MenuName ; menu name in resource file
mov wc.lpszClassName, offset _ClassName ; window class name
mov wc.hIcon, 0
invoke LoadCursor, 0, IDC_ARROW ; system cursor
mov wc.hCursor, eax
mov wc.hIconSm, 0
invoke RegisterClassEx, ADDR wc ; register the window class
invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,
ADDR _ClassName,
ADDR _DisplayName,
WS_OVERLAPPEDWINDOW,
100,100,500,350,
0, 0, hInst, 0
mov _hWnd, eax
invoke ShowWindow, _hWnd, SW_SHOWNORMAL ; display the window
invoke UpdateWindow, _hWnd ; update the display
_StartLoop:
invoke GetMessage, ADDR msg, 0,0,0 ; get each message
cmp eax, 0 ; exit if GetMessage()
je _ExitLoop ; returns zero
invoke TranslateMessage, ADDR msg ; translate it
invoke DispatchMessage, ADDR msg ; send it to message proc
jmp _StartLoop
_ExitLoop:
WinMain endp
; ######################################################
WndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
switch uMsg
case WM_COMMAND
switch wParam
case IDM_Help
invoke MessageBox, hWnd, ADDR _TheMsg, ADDR _DisplayName, MB_OK
endsw
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
case WM_CLOSE
;invoke DestroyWindow, hWnd <<<<------ IF i uncomment, doesnt WORK
case WM_DESTROY
invoke PostQuitMessage, 0
;popad <<<<------ IF i uncomment it, IT WORKS CORRECTLY !!!!
mov eax, 0
ret
endsw
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
_exit: mov eax, 0
ret
WndProc endp
; #############################################################
end _start
the problem is: when i try to close it gives me an error, the prog makes an error.
where ? why ? Can anyone tell me . Note that i have not a pushad before the popad !
PS: with popad the system destroys the window, closes and doesnt say anything !
without popad it says the prog makes an error bla..bla..bla
Rui
I see no ret instruction at the end of WinMain.
Quote from: MichaelW on October 29, 2008, 08:50:48 PM
I see no ret instruction at the end of WinMain.
Hi MichaelW, how are you
Thats right ! I am sure i need another pair of glasses ! Thanks.
I was working with up-down controls. Here is my work
Rui
[attachment deleted by admin]