flat assembler
Message board for the users of flat assembler.

Index > Windows > Create a table inside Window

Author
Thread Post new topic Reply to topic
3ric



Joined: 19 Dec 2013
Posts: 14
3ric
Can you guys help me to create a table inside the windows with x no. rows and y no. of columns

Code:
format PE GUI 4.0
entry start

include 'C:\Fasm\INCLUDE\win32axp.inc'

IDM_FILE        EQU 100
IDM_START       EQU 105
IDM_STOP        EQU 110
IDM_EXIT        EQU 115
IDM_EDIT        EQU 200
IDM_PREFS       EQU 205
IDM_COLS        EQU 210
IDM_HELP        EQU 300
IDM_INSTRUCTS   EQU 305
IDM_ABOUT       EQU 310

section '.text' code readable executable

    start:
        invoke  GetModuleHandle, 0
        mov     [wc.hInstance],eax
        invoke  RegisterClass, wc
        invoke  LoadMenu, [wc.hInstance], 20
        mov     [menuHnd], eax
        invoke  CreateWindowEx, 0, testClass, testTitle, WS_VISIBLE+WS_OVERLAPPEDWINDOW, 300, 300, 300, 200, NULL, eax, [wc.hInstance], NULL
        mov     [hWndMain], eax
        jmp     msgLoop
;--------------------------------------------------------------------------------------------------

  msgLoop:
        invoke  GetMessage, msg, NULL, 0, 0
        cmp     eax, 1
        jb      endLoop
        jne     msgLoop
        invoke  TranslateMessage, msg
        invoke  DispatchMessage, msg
        jmp     msgLoop
    endLoop:
        invoke  ExitProcess, [msg.wParam]

;--------------------------------------------------------------------------------------------------

proc WindowProc hWnd, wMsg, wParam, lParam

        push    ebx esi edi
        cmp     [wMsg], WM_COMMAND
        je      .wmCommand
        cmp     [wMsg], WM_DESTROY
        je      .wmDestroy
    .defWndProc:
        invoke  DefWindowProc, [hWnd], [wMsg], [wParam], [lParam]
        jmp     .wmFinish
    .wmCommand:
        mov     eax, [wParam]
        and     eax, 0x0FFFF
        cmp     eax, IDM_START
        je      .start
        cmp     eax, IDM_STOP
        je      .stop
        cmp     eax, IDM_EXIT
        je      .wmDestroy
        jmp     .defWndProc
      .start:
                mov     [mii.cbSize], sizeof.MENUITEMINFO
                mov     [mii.fMask], MIIM_DATA + MIIM_ID + MIIM_STRING
                mov     [mii.dwTypeData], stopStr
                invoke  lstrlen, stopStr
                mov     [mii.cch], eax
                mov     [mii.wID], IDM_STOP
                invoke  GetSubMenu, [menuHnd], 0
                invoke  SetMenuItemInfo, eax, 0, TRUE, mii
                jmp     .wmCommandFinish
      .stop:
                mov     [mii.cbSize], sizeof.MENUITEMINFO
                mov     [mii.fMask], MIIM_DATA + MIIM_ID + MIIM_STRING
                mov     [mii.dwTypeData], startStr
                invoke  lstrlen, startStr
                mov     [mii.cch], eax
                mov     [mii.wID], IDM_START
                invoke  GetSubMenu, [menuHnd], 0
                invoke  SetMenuItemInfo, eax, 0, TRUE, mii
      .wmCommandFinish:
        xor     eax, eax
        jmp     .wmFinish
    .wmDestroy:
        invoke  PostQuitMessage, 0
        xor     eax, eax
    .wmFinish:
        pop     edi esi ebx
        ret
endp

;**************************************************************************************************
section '.data' data readable writeable

wc              WNDCLASS 0, WindowProc, 0, 0, NULL, NULL, NULL, COLOR_BTNFACE+1, NULL, testClass
msg             MSG
hWndMain        dd 0
testClass       db "testClass", 0
testTitle       db "Test application", 0
menuHnd         dd ?
stopStr         db '&Stop', 0
startStr        db '&Start',0
mii             MENUITEMINFO

;**************************************************************************************************
section '.idata' import data readable writeable

library kernel32,'KERNEL32.DLL',\
        user32,  'USER32.DLL'

include 'C:\Fasm\INCLUDE\api\Kernel32.inc'
include 'C:\Fasm\INCLUDE\api\User32.inc'

;**************************************************************************************************
section '.rsrc' resource data readable

  ; resource directory

  directory RT_MENU,menus

  ; resource subdirectories

  resource menus, 20, LANG_ENGLISH + SUBLANG_DEFAULT, testMenu

  menu testMenu
       menuitem '&File', IDM_FILE, MFR_POPUP
                menuitem '&Start', IDM_START
                menuseparator
                menuitem 'E&xit', IDM_EXIT, MFR_END
       menuitem '&Edit', IDM_EDIT, MFR_POPUP
                menuitem '&Colours', IDM_COLS
                menuitem '&Preferences', IDM_PREFS, MFR_END
       menuitem '&Help', IDM_HELP, MFR_POPUP + MFR_END
                menuitem '&Instructions', IDM_INSTRUCTS
                menuitem '&About...', IDM_ABOUT, MFR_END    


Description:
Download
Filename: 2.asm
Filesize: 4.48 KB
Downloaded: 141 Time(s)

Post 30 Sep 2019, 12:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
That is a good start.

To show a grid of values/text/pictures/whatever all you need to do is to start drawing things at defined X and Y coordinates. There is the DrawText (IIRC) API function for printing text. Also various Lines and other shapes can be drawn with the inbuilt APIs. Or just a custom picture.

You can have a loop for X and an inner loop for Y (or the other way around) and successively draw each grid's position within the WM_PAINT message.
Post 30 Sep 2019, 12:50
View user's profile Send private message Visit poster's website Reply with quote
3ric



Joined: 19 Dec 2013
Posts: 14
3ric
Thanks, Let me try
Post 30 Sep 2019, 15:45
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.