I put these codes at WM_CREATE in WinProc function


invoke CreateWindowEx, NULL, ADDR ListViewClassName, NULL,
WS_CHILD or WS_VISIBLE or LVS_REPORT or LVS_SHOWSELALWAYS,
LIST_START_X, LIST_START_Y, LIST_WIDTH, LIST_HEIGHT, hWnd, ListID, NULL, NULL
mov hwndList, EAX


The variables and contants are checked carefully but I can't see it on my window. Nothing ! Can anyone give me a hint ? Thanks !
Posted on 2003-09-25 05:53:07 by hcm2k3
Use InitCommonControls (or InitCommonControlsEx) prior to creating ListView
Posted on 2003-09-25 05:59:49 by Morris

Use InitCommonControls (or InitCommonControlsEx) prior to creating ListView


U dont need InitCommonControls to create a simple Listview



;---------- [Create a Listview Reportstyle with gridlines ] ----------
INVOKE CreateWindowEx, WS_EX_CLIENTEDGE, addr ListClass, NULL,\
WS_CHILD or WS_VISIBLE or LVS_REPORT or LVS_SHAREIMAGELISTS or LVS_SORTASCENDING,\
0, 0, 260, 100, hWin, 45, hInstance, NULL

test eax, eax
mov hWndList, eax
Posted on 2003-09-25 06:24:49 by Ranma_at


U dont need InitCommonControls to create a simple Listview



You have to use InitCommonControls or InitCommonControlsEx in order to use any of the common controls (ListView, TreeView, HotKey etc.)
Posted on 2003-09-25 06:46:47 by Morris



You have to use InitCommonControls or InitCommonControlsEx in order to use any of the common controls (ListView, TreeView, HotKey etc.)


NO You dont. Just tried it in radasm and it works fine !!!!!!!!!
Posted on 2003-09-25 06:58:47 by Ranma_at



NO You dont. Just tried it in radasm and it works fine !!!!!!!!!


'In RadASM' - you mean in a RadASM plugin?
Posted on 2003-09-25 07:00:25 by Morris
here is my code



[size=9]
;Dialog.asm
.386
.model flat,stdcall
option casemap:none

include Dialog.inc

.code

start:

invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetCommandLine

invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG

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,DLGWINDOWEXTRA
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,OFFSET MenuName
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 CreateDialogParam,hInstance,addr DlgName,NULL,addr WndProc,NULL
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

WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov eax,uMsg
.if eax==WM_INITDIALOG
push hWin
pop hWnd

;---------- [Create a Listview Reportstyle with gridlines ] ----------
INVOKE CreateWindowEx, WS_EX_CLIENTEDGE, addr ListClass, NULL,\
WS_CHILD or WS_VISIBLE or LVS_REPORT or LVS_SHAREIMAGELISTS or LVS_SORTASCENDING,\
0, 0, 260, 100, hWin, 45, hInstance, NULL

test eax, eax
mov hWndList, eax

.elseif eax==WM_COMMAND
mov eax,wParam
and eax,0FFFFh
.if eax==IDM_FILE_EXIT
invoke SendMessage,hWin,WM_CLOSE,0,0
.elseif eax==IDM_HELP_ABOUT
invoke ShellAbout,hWin,addr AppName,addr AboutMsg,NULL
.endif
; .elseif eax==WM_SIZE
.elseif eax==WM_CLOSE
invoke DestroyWindow,hWin
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret

WndProc endp

end start


;Dialog.inc

include windows.inc
include user32.inc
include kernel32.inc
include shell32.inc


includelib user32.lib
includelib kernel32.lib
includelib shell32.lib


WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

.const

IDM_FILE_EXIT equ 10001
IDM_HELP_ABOUT equ 10101

.data

ClassName db 'DLGCLASS',0
MenuName db 'MyMenu',0
DlgName db 'MyDialog',0
AppName db 'Dialog as main',0
AboutMsg db 'MASM32 RadASM Dialog as main',13,10,'Copyright ? MASM32 2001',0
ListClass db 'SysListView32',0

.data?

hInstance dd ?
CommandLine dd ?
hWnd dd ?
hWndList dd ?
[/size]



no common controls needed !

but maybe its my NT4.0 again , strange behavior sometimes :grin:
Posted on 2003-09-25 07:02:13 by Ranma_at
OK, do this little test: remove the call to ShellAbout and try again.
Posted on 2003-09-25 07:18:09 by Morris

OK, do this little test: remove the call to ShellAbout and try again.


thats weird, i thought commoncontrols for listview are just needed for the extendet styles of the listview

i dont get it :confused:
Posted on 2003-09-25 07:22:20 by Ranma_at



thats weird, i thought commoncontrols for listview are just needed for the extendet styles of the listview

i dont get it :confused:


ListView is a common control itself.

Apparently shell32.dll does a call to InitCommonControlsEx in its DllMain. I just tried this: instead of calling InitCommonControls() I called LoadLibrary("shell32.dll") and I was able to create a ListView :)
Posted on 2003-09-25 07:27:01 by Morris
Thank you all ! After calling InitCommonControls, it appears now ;-)
Posted on 2003-09-25 07:44:33 by hcm2k3
this is what im doing with one of my list box's and it works for me..

  

ListBoxProc PROTO :DWORD,:DWORD,:DWORD,:DWORD


.data?
hList1 dd ?
hList2 dd ?
lpLstBox1 dd ?

invoke ListBox,20,40,200,566,hWin,501
mov hList2, eax
invoke SetWindowLong,hList2,GWL_WNDPROC,ListBoxProc
mov lpLstBox1, eax


ListBox proc a:DWORD,b:DWORD,wd:DWORD,ht:DWORD,hParent:DWORD,ID:DWORD

szText lstBox,"LISTBOX"

invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR lstBox,0,
WS_VSCROLL or WS_VISIBLE or WS_TABSTOP or \
WS_BORDER or WS_CHILD or \
LBS_HASSTRINGS or LBS_NOINTEGRALHEIGHT or \
LBS_SORT or LBS_DISABLENOSCROLL,
a,b,wd,ht,hParent,ID,hInstance,NULL

ret

ListBox endp

ListBoxProc proc hCtl :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD

LOCAL IndexItem :DWORD
.if uMsg == WM_LBUTTONDBLCLK
jmp DoIt
.elseif uMsg == WM_CHAR
.if wParam == 13
jmp DoIt
.endif
.endif
jmp EndDo

DoIt:

invoke SendMessage,hCtl,LB_GETCURSEL,0,0
mov IndexItem, eax
mov eax,offset Buffer
invoke SendMessage,hCtl,LB_GETTEXT,IndexItem,ADDR Buffer+8h
mov eax, hList1
.if hCtl == eax
.endif

EndDo:

invoke CallWindowProc,lpLstBox1,hCtl,uMsg,wParam,lParam

ret

ListBoxProc endp
Posted on 2003-09-25 13:39:18 by devilsclaw
Hi, everyone.
I would like to point out a few things, that may help in this discussion:

1) RadAsm's addins do not need to call InitCommonControls or InitCommonControlsEx, because RadAsm.exe does it already.

2) ListBOX is not a ListVIEW. They are two completely different controls. ListView is one of the common controls (refer to shellcc.chm in the MSDN CD for more details on all of the common controls), while ListBox is one of the standard controls (the ones inherited from 16 bits Windows versions).

3) I did not know of any way to use listviews without initializing the library. So Morris must be right: shell32.dll internally calls comctl32.dll for some (?) pourpose. So I've learned something today ;)
One thing though, we still have to find out for wich versions of shell32.dll this works... Morris, could you please post your test program? So we can try it in different OSs to see how it reacts, and post our conclusions here. :)
Posted on 2003-09-25 17:16:51 by QvasiModo
Here's the code:



.386
.model flat,stdcall
option casemap:none

include windows.inc
include kernel32.inc
include user32.inc

includelib kernel32.lib
includelib user32.lib

.data?
hList dd ?
hInst dd ?
hShell dd ?

.code
szShellDll db "shell32.dll",0
WC_LISTVIEW db "SysListView32",0

WSTYLE equ WS_POPUP or WS_VISIBLE or LVS_REPORT

start:
invoke LoadLibrary,addr szShellDll ;this way I init ListView class (instead of InitCommonControls)
mov hShell,eax

invoke GetModuleHandle,NULL
mov hInst,eax
invoke CreateWindowEx, 0, addr WC_LISTVIEW, 0, WSTYLE, 100, 100, 260, 100, 0, 0, hInst, 0
mov hList,eax
invoke Sleep,3000
invoke DestroyWindow,hList
invoke FreeLibrary,hShell
invoke ExitProcess,0
end start


Tested on Shell32.dll version 4.72.3612.1700, on WinNT4 WS SP6a IE 6.0.2800.1106
Posted on 2003-09-26 00:35:33 by Morris