Writing a grid control with asm ? Ernie suggested before: Draw the 'cells' in a WM_PAINT handler, then run thru the data list and DrawText them in.To actively edit a cell, a single, moveable, sizeable edit window would suffice. This is nice and for me ,a beginner, I hope I can, but how can I retrieve the text written in a certain cell. Thanks.
Posted on 2001-05-01 00:55:00 by a nada
you would have to use an array of bytes which the text that is in the cells is written to.....
Posted on 2001-05-01 05:21:00 by [SaFc0n]
a nada,
but how can I retrieve the text written in a certain cell
No, you can't retrieve the text, you have to retrieve text from edit control and write this text into a memory buffer from which you do your DrawText function. Your edit slot is hovering above the editing cell. So you see the edited text in this edit control, but when ever you move the slot you may to refresh your grid control window. forge
Posted on 2001-05-01 05:56:00 by forge
Thanks for answering. This will work,but 1- If the grid is a huge one isn't this a waste for memory.Or is there another way(Other than grid) 2- If I donot know how many rows I have to insert before running time, like the number of records in a database table How I can size my array and be sure it will suffice. Thanks again for reply. I hope Ernie share in this.
Posted on 2001-05-01 06:39:00 by a nada
a nada, 1- If the grid is a huge one isn't this a waste ? It is only like a window in your program into your database. 2- If I donot know how many rows I have to insert ? As many records as you like, you just scroll them in your grid window. forge
Posted on 2001-05-01 07:23:00 by forge
Thanks Forge I speak about declaration of the buffer, I declare it as array of buffers and later on on run time I fill this array with values which may be huge. Lastly how much element is in this array. in Visual basic I can use ReDim to resize the array,I don't know equivalent in asm. Sorry English is not my native language,I may not explaining my meanings in correct manner. Thanks again Forge array in declaration
Posted on 2001-05-01 09:27:00 by a nada
I speak about declaration of the buffer, I declare it as array of buffers and later on on run time I fill this array with values which may be huge. Lastly how much element is in this array. in Visual basic I can use ReDim to resize the array,I don't know equivalent in asm. ---------------------------------------- Assembly have not an array, everythin is linear. So you have to index linear address by register or pointer. If you make appropriate size of buffer, you don't need to changed its size as you can always save buffer into a file and reload next section of records. This is how you you allocate memory (DIM)

	invoke GlobalAlloc,GMEM_MOVEABLE or
                           GMEM_ZEROINIT,
                           MEMSIZE 
          ;MEMSIZE equ 65535 or whatever
		mov  hMemory,eax
	invoke GlobalLock,hMemory
		mov  pMemory,eax
To change allocated memory size you use "GlobalReAlloc" but I can't see any reson in your case. forge
Posted on 2001-05-01 09:48:00 by forge
You will ONLY show a window from your data set :) the size depends on your visual grid setings...so read data from the database file and when user scrolls reat the next records from the file...then draw them....and so on... i this way you can have a FIXED array in memory... Some caching will sure help ;)
Posted on 2001-05-02 05:21:00 by BogdanOntanu
Instead of a fixed array, use a Sparse Array. If you want grid lines, the listview control can do that and it can handle resizing the columns and your can do some subclassing to resize a row or the rows. Then just have a single combo or edit box that positions itself where the top left corner of the "Cell" is and you'll be okay. It's easy in theory, but I've done this in VB before and it's so simple that I felt like I was missing something. _Shawn
Posted on 2001-05-03 16:02:00 by _Shawn
If you want grid lines, the listview control can do that and it can handle....
You can do that, it is very tempting and easy to start with, but as you grow into a bigger sizes of something with more columns more rows - like spreadsheet, you will encounter different problems - like windows smooth scrolling etc.
I felt like I was missing something.
I did not. I code it, and I felt that I'm playing with poisonous snakes. IMHO - start harder and finish easier.
Posted on 2001-05-03 19:54:00 by forge
I don't know if this will help, but... This is a sample of how to work with 'arrays'. In the true, the things are put in memory one after other. To 'simulate' a 3x3 array we can 'think' this:

.data
  Array DWORD 11,12,13
        DWORD 21,22,23
        DWORD 31,32,33
But, in the memory, will be like this:

.data
  Array DWORD 11,12,13,21,22,23,31,32,33
To access the elements I use:

  mov ecx,5                            ;Fifth element (22)
  mov eax,DWORD PTR [-4] ;Exam.: pointer+5*4-4=p+16 (the position of 22 in the array)
I use this other way to 'think' that the array is of multidimension:

.data
  Matrix QWORD 11,12,13,14,15  ;Without Keanu Reeves :)
         QWORD 21,22,23,24,25
         QWORD 31,32,33,34,35
         QWORD 41,42,43,44,45
         QWORD 51,52,53,54,55
.code
   ;---- If we want load in the FPU the value at Row 3 and Col 4 ---
   mov ebx,3                  ;Row    3
   mov ecx,4                  ;Column 4
   ;---- Determination of Row position ----
   mov eax,ebx
   dec eax
   mul 5                      ;5=number of columns
   shl eax,3                  ;eax=eax*8 (8=8bytes QWORD)
   ;---- Determination of Column position ----
   mov edx,ecx
   dec edx
   shl edx,3                  ;edx=edx*8 (idem)
   ;---- Total 'displacement' to the pointer
 finit
   fld QWORD PTR      ;Loads the value 34 in st(0)
Good luck! :)
Posted on 2001-05-04 21:32:00 by wolfao