Hey on my window (not dialog) i have a button which i made with: invoke CreateWindowEx,0,ADDR chkClass,addr Text8,BS_PUSHBUTTON or WS_VISIBLE or WS_CHILD or BS_NOTIFY,\ 470,130,80,28,hWnd,NULL,hInstance,NULL and i want to have it run the code that it runs when you click on Open from the menu so how do i do this? thanx the code for the open bit is: .ELSEIF uMsg==WM_COMMAND .if lParam==0 mov eax,wParam .endif ;============================ ;OPEN MENU ;============================ .if ax==IDM_OPEN mov ofn.lStructSize,SIZEOF ofn push hWnd pop ofn.hWndOwner push hInstance pop ofn.hInstance mov ofn.lpstrFilter, OFFSET FilterString mov ofn.lpstrFile, OFFSET buffer mov ofn.nMaxFile,MAXSIZE mov ofn.Flags, OFN_FILEMUSTEXIST or \ OFN_PATHMUSTEXIST or OFN_LONGNAMES or\ OFN_EXPLORER or OFN_HIDEREADONLY mov ofn.lpstrTitle, OFFSET OurTitle invoke GetOpenFileName, ADDR ofn .if eax==TRUE invoke SetWindowText,hwndEdit,0 invoke lstrcat,offset OutputString,ofn.lpstrFile invoke SetWindowText,hwndEdit,eax invoke RtlZeroMemory,offset OutputString,eax .else invoke PostQuitMessage,NULL .endif .endif
Posted on 2001-04-15 02:19:00 by Kezza
take a look at iczelions tutorial #12 it will show you how to do it.
Posted on 2001-04-15 05:21:00 by smurf
invoke CreateWindowEx,0,ADDR chkClass,addr Text8,BS_PUSHBUTTON or WS_VISIBLE or WS_CHILD or BS_NOTIFY,\ 470,130,80,28,hWnd,IDM_OPEN,hInstance,NULL
Posted on 2001-04-16 01:33:00 by The Svin
The Svin! THANKYOU HEAPS!
Posted on 2001-04-16 03:54:00 by Kezza
Actually i cant get it to werk! maybe i should try it before i post stuff anyways does anyone have any suggestions? it makes the exe alright but when i click ont the button it just dont werk? thanks
Posted on 2001-04-16 04:38:00 by Kezza
remove .if lParam == 0 and subsiquent .endif in the case when you push button with WM_COMMAND in lParam will be ID of control. In this case there will be IDM_OPEN too. The Svin. This message was edited by The Svin, on 4/16/2001 6:26:05 AM
Posted on 2001-04-16 06:25:00 by The Svin
Thanks Svin! it is working but now it opens it twice for some reason?? i've got: .if ax==IDB_OPEN mov ofn.lStructSize,SIZEOF ofn push hWnd pop ofn.hWndOwner push hInstance pop ofn.hInstance mov ofn.lpstrFilter, OFFSET FilterString mov ofn.lpstrFile, OFFSET buffer mov ofn.nMaxFile,MAXSIZE mov ofn.Flags, OFN_FILEMUSTEXIST or \ OFN_PATHMUSTEXIST or OFN_LONGNAMES or\ OFN_EXPLORER or OFN_HIDEREADONLY mov ofn.lpstrTitle, OFFSET OurTitle ;invoke BrowseForFolder,hWnd,ADDR OurTitle,0,ssfPROGRAMS invoke GetOpenFileName, ADDR ofn .if eax==TRUE invoke SetWindowText,hwndEdit,0 invoke lstrcat,offset OutputString,ofn.lpstrFile invoke SetWindowText,hwndEdit,eax invoke RtlZeroMemory,offset OutputString,eax .endif
Posted on 2001-04-16 19:39:00 by Kezza

;rsrc.rc res file
100 MENU
{ POPUP "File"
  	{
	MENUITEM "Open",20
	MENUITEM "Exit",21
	}
}

module file
.586
.model flat,stdcall
option casemap:none
include C:\masm32\include\windows.inc
include C:\masm32\include\user32.inc
include C:\masm32\include\kernel32.inc
includelib kernel32.lib
includelib user32.lib
.data
ClassName db 1,0
wc WNDCLASSEX 

.data?
msg MSG <>
hInstance dd ?
.code
start:
	invoke GetModuleHandle,0
	mov wc.hInstance,eax
	mov hInstance,eax
	push eax
	invoke LoadCursor,0,IDC_ARROW
	mov wc.hCursor,eax
	invoke RegisterClassEx,addr wc
	and eax,0FFFFh
	pop edx
	invoke CreateWindowEx,0,eax,\
	offset ClassName+1,WS_OVERLAPPEDWINDOW or WS_VISIBLE,\
	40,40,300,200,0,0,edx,0
	xor ebx,ebx
	mov edi,offset msg
@@:	invoke GetMessage,edi,ebx,ebx,ebx
	or eax,eax
	je @F
	invoke TranslateMessage,edi
	invoke DispatchMessage,edi
	jmp @B
@@:
	call ExitProcess
WndProc proc uses ebx edi esi hWnd,uMsg,wParam,lParam
	mov eax,uMsg
	xor ebx,ebx	
.IF eax == WM_CREATE 

.data
bclass db 'button',0
IDM_OPEN equ 20
IDM_EXIT equ 21
.code
	mov eax,offset bclass
	invoke CreateWindowEx,ebx,
	eax, eax,WS_CHILD or WS_VISIBLE,
	20,20,150,25,hWnd,IDM_OPEN,hInstance,NULL
.ELSEIF eax == WM_COMMAND
	mov eax,wParam
	.IF al == IDM_OPEN
	call GetCommandLine
	invoke MessageBox,ebx,eax,eax,ebx
	.ELSEIF al == IDM_EXIT
	mov uMsg,WM_CLOSE
	jmp d
	.ENDIF
.ELSEIF eax == WM_DESTROY
	 invoke PostQuitMessage,ebx
.ELSE
d:	invoke DefWindowProc,hWnd,uMsg,wParam,lParam
	jmp r
.ENDIF
	xor eax,eax
r:	ret
WndProc endp

	
	end start
Posted on 2001-04-18 12:00:00 by The Svin