Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.4 kB
2
Indexable
Never
.386
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive

include Changle.inc


.code

start:

	invoke GetModuleHandle,NULL
	mov		hInstance,eax

    invoke InitCommonControls
	invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
	invoke ExitProcess,0

;########################################################################

DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
	LOCAL ofn:OPENFILENAME
	LOCAL hExe, hRes, hResLoad, hResUpdate,lpResLock,hUpdateRes:DWORD
	LOCAL buf[MAX_PATH]:byte
		
	mov		eax,uMsg
	.if eax==WM_INITDIALOG
		invoke LoadIcon,hInstance,1000
		invoke SendMessage,hWin,WM_SETICON,ICON_BIG,eax
		
		invoke SetDlgItemText,hWin,1003,szText("Change Icon !!!",10,13,"/\  /\",10,13,"< ^_^ >",10,13,"("") , ("")")			
	.elseif eax==WM_COMMAND
		.if wParam==1003;change icon :)
			;szText name_res,"MAINICON"
			invoke LoadLibrary,addr NewIcon
			mov hExe,eax
			invoke FindResource,eax,1\;addr name_res
			,RT_ICON;RT_GROUP_ICON
			mov hRes,eax
			invoke LoadResource,hExe,eax
			mov hResLoad,eax
			invoke LockResource,eax
			mov lpResLock,eax
			invoke BeginUpdateResource,addr AppIcon,0
			mov hUpdateRes,eax
			invoke SizeofResource,hExe,hRes			
			invoke UpdateResource,hUpdateRes,RT_ICON,1\;RT_GROUP_ICON,addr name_res
						,0,lpResLock,eax
			invoke EndUpdateResource,hUpdateRes,0
			invoke FreeLibrary,hExe
			invoke ExtractIcon,0,addr AppIcon,0
			invoke SendDlgItemMessage,hWin,1001,STM_SETIMAGE,IMAGE_ICON,eax
			
		.elseif wParam==1005;AppIcon
			lea edx,ofn
			mov ecx,sizeof ofn
		@@:	mov byte ptr [edx],0
			inc edx
			loop @B
			invoke GetModuleFileName,hInstance,addr buf,260
			lea edi,buf
			mov ecx,MAX_PATH
		@@:	.if byte ptr[edi+ecx-1]=='\'
				mov byte ptr[edi+ecx],0	
				jmp @F
			.endif
			loop @B
		@@:	mov ofn.lpstrInitialDir,edi	
			mov ofn.lStructSize,sizeof OPENFILENAME
			mov ofn.hwndOwner,0
			mov ofn.hInstance,0
			mov ofn.lpstrFilter,offset szFilterFile
			mov ofn.lpstrTitle,offset szOpenTitle
			mov ofn.Flags,OFN_FILEMUSTEXIST or OFN_LONGNAMES
			lea edx,AppIcon
			mov byte ptr [edx],0
			mov ofn.lpstrFile,edx
			mov ofn.nMaxFile,sizeof AppIcon
			invoke GetOpenFileName,addr ofn
			invoke ExtractIcon,0,addr AppIcon,0
			invoke SendDlgItemMessage,hWin,1001,STM_SETIMAGE,IMAGE_ICON,eax
			
		.elseif wParam==1006;NewIcon
			lea edx,ofn
			mov ecx,sizeof ofn
		@@:	mov byte ptr [edx],0
			inc edx
			Loop @B
			invoke GetModuleFileName,hInstance,addr buf,260
			lea edi,buf
			mov ecx,MAX_PATH
		@@:	.if byte ptr[edi+ecx-1]=='\'
				mov byte ptr[edi+ecx],0	
				jmp @F
			.endif
			loop @B
		@@:	mov ofn.lpstrInitialDir,edi	
			mov ofn.lStructSize,sizeof OPENFILENAME
			mov ofn.hwndOwner,0
			mov ofn.hInstance,0
			mov ofn.lpstrFilter,offset szFilterFile
			mov ofn.lpstrTitle,offset szOpenTitle
			mov ofn.Flags,OFN_FILEMUSTEXIST or OFN_LONGNAMES

			lea edx,NewIcon
			mov byte ptr [edx],0
			mov ofn.lpstrFile,edx
			mov ofn.nMaxFile,sizeof NewIcon
			invoke GetOpenFileName,addr ofn
			invoke ExtractIcon,0,addr NewIcon,0
			invoke SendDlgItemMessage,hWin,1002,STM_SETIMAGE,IMAGE_ICON,eax
		.endif
			
	.elseif eax==WM_CLOSE
		
		invoke EndDialog,hWin,0
	.else
		mov		eax,FALSE
		ret
	.endif
	mov		eax,TRUE
	ret

DlgProc endp

end start