News:

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

User defined messages

Started by shuttlebug, September 25, 2005, 12:36:53 AM

Previous topic - Next topic

shuttlebug

Any help?

In the grid example,there is a list of equates in the RAGrid.inc file.
  Example
      GM_ADDCOL      equ      WM_USER+1
      GM_ADDROW    equ      WM_USER+2
      GM_INSROW      equ      WM_USER+2

So when you need to add a column to the grid you use the
       SendMessage,hGrid,GM_ADDCOL,0,addr col.

The message constant GM_ADDCOL is then sent to the Grid procedure.

After looking at the code, I dont understand or am missing is how the program knows where to find the code to create the row. Is WM_USER+1 used by the procedure to go to some predefined windows code or am i missing some user code pointer that shows how to get to the code?

KetilO

Hi

In tho sources for RAGrid (RAGrid.asm) you can find:


.elseif eax==GM_ADDCOL
  call  GetMem
  .if ![ebx].GRID.hmem
    mov    eax,[ebx].GRID.rpitemdata
    lea    edi,[ebx+eax]
    mov    esi,lParam
    mov    eax,[esi].COLUMN.colwt
    mov    [edi].COLUMN.colwt,eax
    mov    eax,[esi].COLUMN.lpszhdrtext
    mov    [edi].COLUMN.lpszhdrtext,eax
    mov    [edi].COLUMN.lpszformat,0
    mov    eax,[esi].COLUMN.halign
    mov    [edi].COLUMN.halign,eax
    mov    eax,[esi].COLUMN.calign
    mov    [edi].COLUMN.calign,eax
    mov    eax,[esi].COLUMN.ctextmax
    mov    [edi].COLUMN.ctextmax,eax
    mov    eax,[esi].COLUMN.hdrflag
    mov    [edi].COLUMN.hdrflag,eax
    mov    eax,[esi].COLUMN.lpszformat
    mov    [edi].COLUMN.lpszformat,eax
    mov    eax,[esi].COLUMN.lParam
    mov    [edi].COLUMN.lParam,eax
    mov    eax,[esi].COLUMN.ctype
    mov    [edi].COLUMN.ctype,eax
    .if eax==TYPE_EDITTEXT
      invoke CreateWindowEx,0,offset szEditClass,NULL,WS_CHILD or WS_BORDER or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or ES_AUTOHSCROLL,0,0,0,0,[ebx].GRID.hlst,NULL,hInstance,0
      mov    [edi].COLUMN.edthwnd,eax
      invoke SetWindowLong,eax,GWL_WNDPROC,offset EdtTextProc
      invoke SetWindowLong,[edi].COLUMN.edthwnd,GWL_USERDATA,eax
      mov    eax,[edi].COLUMN.ctextmax
      .if !eax || eax>511
        mov    eax,511
        mov    [edi].COLUMN.ctextmax,eax
      .endif
      invoke SendMessage,[edi].COLUMN.edthwnd,EM_LIMITTEXT,eax,0
    .elseif eax==TYPE_EDITLONG
      invoke CreateWindowEx,0,offset szEditClass,NULL,WS_CHILD or WS_BORDER or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or ES_AUTOHSCROLL or ES_RIGHT,0,0,0,0,[ebx].GRID.hlst,NULL,hInstance,0
      mov    [edi].COLUMN.edthwnd,eax
      invoke SetWindowLong,eax,GWL_WNDPROC,offset EdtLongProc
      invoke SetWindowLong,[edi].COLUMN.edthwnd,GWL_USERDATA,eax
      mov    eax,[edi].COLUMN.ctextmax
      .if !eax || eax>11
        mov    eax,11
        mov    [edi].COLUMN.ctextmax,eax
      .endif
      invoke SendMessage,[edi].COLUMN.edthwnd,EM_LIMITTEXT,eax,0
    .elseif eax==TYPE_COMBOBOX
      mov    eax,[esi].COLUMN.himl
      mov    [edi].COLUMN.himl,eax
      invoke CreateWindowEx,0,offset szListBoxClass,NULL,WS_CHILD or WS_BORDER or WS_VSCROLL or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or LBS_HASSTRINGS or LBS_SORT or LBS_OWNERDRAWFIXED,0,0,0,0,[ebx].GRID.hlst,NULL,hInstance,0
      mov    [edi].COLUMN.edthwnd,eax
      invoke SetWindowLong,eax,GWL_WNDPROC,offset LstProc
      mov    lplstproc,eax
      invoke SetWindowLong,[edi].COLUMN.edthwnd,GWL_USERDATA,[ebx].GRID.hgrd
      invoke GetDesktopWindow
      invoke SetParent,[edi].COLUMN.edthwnd,eax
      invoke SetWindowLong,[edi].COLUMN.edthwnd,GWL_STYLE,WS_POPUP or WS_BORDER or WS_VSCROLL or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or LBS_HASSTRINGS or LBS_SORT or LBS_OWNERDRAWFIXED
    .elseif eax==TYPE_HOTKEY
      invoke CreateWindowEx,0,offset szHotKeyClass,NULL,WS_CHILD or WS_CLIPCHILDREN or WS_CLIPSIBLINGS,0,0,0,0,[ebx].GRID.hlst,NULL,hInstance,0
      mov    [edi].COLUMN.edthwnd,eax
      invoke SetWindowLong,eax,GWL_WNDPROC,offset HotProc
      invoke SetWindowLong,[edi].COLUMN.edthwnd,GWL_USERDATA,eax
    .elseif eax==TYPE_BUTTON
      mov    [edi].COLUMN.edthwnd,0
    .elseif eax==TYPE_EDITBUTTON
      invoke CreateWindowEx,0,offset szEditClass,NULL,WS_CHILD or WS_BORDER or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or ES_AUTOHSCROLL,0,0,0,0,[ebx].GRID.hlst,NULL,hInstance,0
      mov    [edi].COLUMN.edthwnd,eax
      invoke SetWindowLong,eax,GWL_WNDPROC,offset EdtTextProc
      invoke SetWindowLong,[edi].COLUMN.edthwnd,GWL_USERDATA,eax
      mov    eax,[edi].COLUMN.ctextmax
      .if !eax || eax>511
        mov    eax,511
        mov    [edi].COLUMN.ctextmax,eax
      .endif
      invoke SendMessage,[edi].COLUMN.edthwnd,EM_LIMITTEXT,eax,0
    .elseif eax==TYPE_IMAGE
      mov    eax,[esi].COLUMN.himl
      mov    [edi].COLUMN.himl,eax
    .elseif eax==TYPE_DATE
      invoke CreateWindowEx,0,offset szDateTimeClass,NULL,WS_CHILD or WS_CLIPCHILDREN or WS_CLIPSIBLINGS,0,0,0,0,[ebx].GRID.hlst,NULL,hInstance,0
      mov    [edi].COLUMN.edthwnd,eax
      invoke SetWindowLong,eax,GWL_WNDPROC,offset DateTimeProc
      invoke SetWindowLong,[edi].COLUMN.edthwnd,GWL_USERDATA,eax
    .elseif eax==TYPE_TIME
      invoke CreateWindowEx,0,offset szDateTimeClass,NULL,WS_CHILD or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or DTS_TIMEFORMAT or DTS_UPDOWN,0,0,0,0,[ebx].GRID.hlst,NULL,hInstance,0
      mov    [edi].COLUMN.edthwnd,eax
      invoke SetWindowLong,eax,GWL_WNDPROC,offset DateTimeProc
      invoke SetWindowLong,[edi].COLUMN.edthwnd,GWL_USERDATA,eax
    .elseif eax==TYPE_USER
      mov    eax,[esi].COLUMN.edthwnd
      mov    [edi].COLUMN.edthwnd,eax
      .if eax
        invoke SetParent,eax,[ebx].GRID.hlst
      .endif
    .endif
    mov    eax,[edi].COLUMN.edthwnd
    .if eax
      push  eax
      invoke SendMessage,[ebx].GRID.hlst,WM_GETFONT,0,0
      pop    edx
      invoke SendMessage,edx,WM_SETFONT,eax,FALSE
    .endif
    mov    eax,[ebx].GRID.ccx
    mov    [edi].COLUMN.colxp,eax
    add    eax,[edi].COLUMN.colwt
    mov    [ebx].GRID.ccx,eax
    mov    edx,[ebx].GRID.cols
    inc    [ebx].GRID.cols
    add    [ebx].GRID.rpitemdata,sizeof COLUMN
    mov    eax,[edi].COLUMN.lpszhdrtext
    .if eax
      push  edx
      invoke SendMessage,hWin,GM_SETHDRTEXT,edx,eax
      pop    edx
    .endif
    mov    eax,[edi].COLUMN.lpszformat
    .if eax
      invoke SendMessage,hWin,GM_SETCOLFORMAT,edx,eax
    .endif
    invoke SendMessage,hWin,WM_SIZE,0,0
    mov    eax,[ebx].GRID.cols
    dec    eax
  .else
    ;** Error, data in grid
    mov    eax,LB_ERR
  .endif
  call  RelMem
  jmp    Ex


Quiet a lot of code just to add a column.

KetilO

shuttlebug

Ah i see it now. Thx alot appreciate it.