News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Question About List Box Controls

Started by dicky96, July 30, 2006, 04:32:53 PM

Previous topic - Next topic

dicky96

Hi guys.

I'm just starting on a new windows app and I want to display a list of data in columns .  Here is a .JPG screenshot taken from an app which uses the same sort of Windows Control I want to use in my app.  I'm using a dialog as main window. 

Is this a List Box Control? 

On this example there are buttons to add or deelte an entry, these bring up a child window where the user enters data. As an aside, can I program one like this where the user can type data directly into the spreadsheet style columns rather than using a separate clhild window to add data in text boxes? 

If I can do that, does it make it harder to verify the entered data is valid? 

Once i know for sure which type of windows control to use, I am sure I can go friom there.

Thanks in Advance

dicky



[attachment deleted by admin]

Shantanu Gadgil

The control shown in the scrennshot is a "Listview" control. The questions you are asking seem encouraging as you want to learn and know _what_ you want to do. :U :U
But...I would suggest you to go through the examples and samples to familiarize yourself with Win32 programming and you would be able to do this yourself!

Also do check up on the listview reference from MSDN (if possible).

Cheers and best of luck with whatever you are trying!!!  :thumbu :thumbu

Regards,
Shantanu
To ret is human, to jmp divine!

ToutEnMasm

Hello,

It's a listview,that sure.
To create it I can give you the starting point,view the code.
can modify data "on line" directly ?,download  the helper on common controls in the workshop.
The style LVS_EDITLABELS seems to be the answer,try it.

All you have to do with the sample code is:
Put each segment at his place,.const with constants,.data with datas ...
Define the titles (titre) and define the lenght of the title in % of the client area of the listview
The number of titles and the number of lenght must be the same.

The result is a  empty listview with the title you have choose.

Any more questions ?,continue this post.
                                   ToutEnMasm













.const
;declarations

Listview_DATA STRUCT
TableEntete dd ?
TableLargeEntete dd ?
posX dd ? ;conserver dans l'ordre
posY dd ?
largeur dd ?
hauteur dd ?
Handle dd ?
NbCol dd ? ;ne pas remplir
Listview_DATA ENDS

DIM_CREATEWIN STRUCT
posX dd ?
posY dd ?
largeur  dd ?
hauteur dd ?
DIM_CREATEWIN ENDS

Creer_Listview PROTO  :DWORD ,:DWORD
;dans librairie
;PourCent et TransformePourCent

.data

Entete_Col_listview_nom db "titre1",0
    db "titre2",0
    db "titre3",0,0 ;double zero,fin des titres

Entete_Col_listview_large dd  33 ;en % ,33+33+34=100
dd  33 ;100% / 3
dd  34 ;le dernier récupère le reste
dd  0 ;fin des largeurs


;le seul cas ou la somme des pourcentages ne doit pas faire 100
;ce sont les dimensions de la listview passé a CreateWindowEx ,,,PosX,PosY,largeur,hauteur,,
;pour centrer la fenetre 2 * posX + largeur = 100
; 2 * posY + hauteur = 100

Listview Listview_DATA <Entete_Col_listview_nom,Entete_Col_listview_large,10,10,80,80,,>
.code

;dans WM_CREATE
invoke Creer_Listview,hwnd,addr Listview


;################################################################
Creer_Listview PROC uses esi edi ebx hwnd:DWORD,pListview:DWORD
Local   Nbcol:DWORD
Local   CPT:DWORD,largemere,hautmere,largelsv
Local   rect:RECT
;local  lvitem:LVITEM
local NBLVligne:DWORD
local lvc:LV_COLUMN
;local lvi:LV_ITEM
Local  retour:DWORD
ZEROLOCALES retour

mov ebx,pListview
;vérifier les paramètres
.if hwnd == 0 || pListview == 0
jmp FindeCreer_Listview
.endif
;compter le nombre de colonnes et de largeur
mov esi,[Listview_DATA.TableEntete][ebx]
@@:
invoke lnstr,esi
inc Nbcol
add esi,eax
inc esi
mov al,BYTE ptr [esi]
.if al != 0
jmp @B
.endif
;------------------------------------------
mov esi,[Listview_DATA.TableLargeEntete][ebx]
@@:
.if dword ptr [esi] != 0
inc CPT
add esi,4
jmp @B
.endif
mov eax,CPT
.if eax != Nbcol
jmp FindeCreer_Listview
.endif
PuPo [Listview_DATA.NbCol][ebx],Nbcol
;si hwnd null,le controle doit avoir la propriété child
;si non child ,corrigé les paramètres posx et pos y
;donné en fonction de l'écran et non de la feuille mère
invoke TransformePourCent,hwnd,addr Listview.posX
;------------------  créer listview -----------------------------------
;attention a l'évènement resize,si il est utilisé
;il vous faudra tenir compte de la listview
invoke CreateWindowEx,NULL,SADR ("SysListView32"),NULL,\
WS_CHILD or WS_VISIBLE or WS_VSCROLL or WS_HSCROLL or LVS_REPORT,\
Listview.posX,Listview.posY,Listview.largeur,Listview.hauteur,\
hwnd,NULL,Hinstance,NULL
;CW_USEDEFAULT
mov retour,eax
mov [Listview_DATA.Handle][ebx],eax
.if eax == 0
jmp FindeCreer_Listview
.endif
mov     eax, LVS_EX_FULLROWSELECT or LVS_EX_HEADERDRAGDROP or\
LVS_EX_GRIDLINES
INVOKE     SendMessage, retour, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, eax
;positionner pointeurs
mov esi,[Listview_DATA.TableEntete][ebx]
mov edi,[Listview_DATA.TableLargeEntete][ebx]
mov eax,[Listview_DATA.largeur][ebx]
mov largelsv,eax
;définir les colonnes
xor eax,eax
mov NBLVligne,eax
mov lvc.imask,LVCF_TEXT+LVCF_WIDTH ;utile
mov CPT,0
.while (Nbcol)
inc CPT
mov lvc.pszText,esi
mov edx,[edi]
invoke PourCent,largelsv,edx
mov lvc.lx,eax
invoke SendMessage,retour, LVM_INSERTCOLUMN,CPT,addr lvc
dec Nbcol
.if Nbcol != 0
invoke lnstr,esi
add esi,eax
inc esi
add edi,4
.endif
.endw
FindeCreer_Listview:
         mov eax,retour
         ret
Creer_Listview endp
;------------------------------------------------------------------






PourCent proc source:DWORD, percent:DWORD
; invoke   PourCent,Xresolution,80         ;80 % de Xresolution
LOCAL var1:DWORD

mov var1, 100   ; to divide by 100
FINIT   ; l'instruction qui manque dans lib masm32
fild source     ; load source integer
fild var1       ; load 100
fdiv            ; divide source by 100
fild percent    ; load required percentage
fmul            ; multiply 1% by required percentage
fist var1       ; store result in variable
mov eax, var1

ret
PourCent endp







dicky96

Thanks guys.  I have written some other apps (well ok.... TWO other apps) in win32asm so I have some idea of what I'm doing....  Well OK, I have a VAGUE idea of what i'm doing  :bdg 

I've just not been around this board for a while, I pestered you lot enough last year with that winsockapp I wote. LOL

Thanks for the code example.  I'll also have a good look at Iczelion Tutorial 31 now.  It's just I was not sure if that thing was a list view control or not, it looks so different from the one when you run Iczelion example.

I'll be back I'm sure.

dicky

Shantanu Gadgil

To be sure what type of control it is you would need to know the "class" of the control, which can be found out using some (any) WinSpy type of application.  :bg :bg

This much info should help you get on your way, I think!!!  :U :U
To ret is human, to jmp divine!