i have a button that when i click it, it opens up a open file dialog. from there im having problems displaying the text from my file into my listview. the text file only contains one word. so far it only displays grabage characters. can someone help me out.
.386
.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\comctl32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\shell32.inc
include \masm32\include\gdi32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\comctl32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\gdi32.lib

.const
ButtonID   equ 1
MAXSIZE    equ 260
EditID     equ 2
MAXSIZE    equ 260
MEMSIZE    equ 65535

.data
ClassName         db "SimpleButton",0
AppName           db "A Push Button",0
ButtonClassName   db "button",0
EditClassName     db "EDIT",0
ListViewClassName db "SysListView32",0
ButtonText        db "Press Me",0
FilterString      db "ALL FILES",0
buffer            db  MAXSIZE dup(0)
Heading1          db "LIST OF STUFF",0
;Item1            db "TEST",0
ofn OPENFILENAME  <>

.data?
hInstance     HINSTANCE ?
hButton       HWND ?
hEdit         HWND ?
hList         HWND ?
hFile         HWND ?
hMemory       HWND ?
pMemory       DWORD ?
SizeReadWrite DWORD ?

.code
start:
	invoke  GetModuleHandle, NULL
	mov     hInstance,eax
	invoke  WinMain,hInstance,NULL,NULL,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_BTNFACE+1
	mov     wc.lpszMenuName,OFFSET NULL
	mov     wc.lpszClassName,OFFSET ClassName
	invoke  LoadIcon,NULL,IDI_APPLICATION
	mov     wc.hIcon,eax
	mov     wc.hIconSm,eax
	invoke  LoadCursor,NULL,IDC_ARROW
	mov     wc.hCursor,eax
	invoke  RegisterClassEx,ADDR wc
	invoke  CreateWindowEx,	NULL,\
							ADDR ClassName,\
							ADDR AppName,\
             				WS_OVERLAPPEDWINDOW,\
							CW_USEDEFAULT,\
             				CW_USEDEFAULT,\
							400,\
							250,\
							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

InsertColumn proc
	LOCAL lvc:LV_COLUMN
	mov lvc.imask,LVCF_TEXT+LVCF_WIDTH
	mov lvc.pszText,offset Heading1
	mov lvc.lx,150
	invoke SendMessage,hList, LVM_INSERTCOLUMN,0,addr lvc
	or lvc.imask,LVCF_FMT	
	ret		
InsertColumn endp

InsertRow proc
	LOCAL item:LV_ITEM
	mov   item.imask,LVIF_TEXT
        mov   item.iItem,0
        mov   item.iSubItem,0
        mov   item.pszText,offset pMemory
        mov   item.cchTextMax,eax
	invoke SendMessage,hList, LVM_INSERTITEM,0,addr item
	ret
InsertRow endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL item:LV_ITEM
	.IF uMsg==WM_DESTROY
		invoke PostQuitMessage,NULL
	.ELSEIF uMsg==WM_CREATE
		invoke CreateWindowEx, 	NULL,                               ;<-----BUTTON
						    	ADDR ButtonClassName,
						    	ADDR ButtonText,
                            	WS_CHILD+WS_VISIBLE+BS_DEFPUSHBUTTON,
                            	140,
						    	190,
						    	140,
						    	25,
						    	hWnd,
						    	ButtonID,
						    	hInstance,
						    	NULL
		mov hButton,eax
		invoke CreateWindowEx, 	NULL,                               ;<--
Posted on 2001-04-12 01:15:00 by smurf
I'm not quite sure, but try replacing: mov item.pszText,offset pMemory with mov item.pszText,pMemory
Posted on 2001-04-12 02:23:00 by JimmyClif
just tried it and i get an invalid operand assemble error. also forgot to say before that there isnt a resource file the complete program is posted. thanks for your reply.
Posted on 2001-04-12 02:38:00 by smurf
Erm... What about : push pMemory pop item.pszText
Posted on 2001-04-12 02:46:00 by JimmyClif
yes that did the trick... thank you. now i just have to figure out how to do it if more word is in a text file. smurf
Posted on 2001-04-12 02:54:00 by smurf
As said before once, Stefan Krause @ win32asmnewbies.cjb.net has an example about inserting words from a file into a listbox, you can easily apply it to your listview. But before you try doing this, ask yourself why following didn't work: mov item.pszText,OFFSET pMemory mov item.pszText,pMemory And create a macro like this: m2m MACRO arg, arg2 push arg2 pop arg m2m ENDM It works like a mov: m2m item.pszText,pMemory JimmyClif ( is giving homework ;P )
Posted on 2001-04-12 03:57:00 by JimmyClif