Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Visual Table

  1. #1
    New Coder
    Join Date
    Nov 2003
    Thanked 0 Times in 0 Posts

    Visual Table

    Hey I got an assignment that involves creating a 10x10 table in C then adding stuff to that table.
    but instead of doing it in the console I would like to create it visually??

    Can anyone help me,
    Thanks alot

  • #2
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Sydney, Australia
    Thanked 1 Time in 1 Post
    I guess you mean you want to make a gui for it.
    Well, I dunno how others would do it. But I'd just use my custom control lib for it .. But you don't have that luxury.

    Basically, once you have created your window you need to create your custom control. Register it in the same way that you would a normal window.

    You will need a struct (being just in C) that will contain the 100 values for each cell in the table.

    So something like-
    struct {
      char *data[100];
    } datstruct;
    (Actually, I'm unsure of the C implementation of a struct)

    Next you just handle your WM_PAINT message and using the appropriate GDI functions draw the table, moving +11 in the array for each new row of data.

    Oh, and you will need to store a pointer to the struct in the window class's memory, unless of course you'd rather some sort of hash table (like MFC) or maybe just an icky global scope to the variable.

    So make sure that you give it enough bytes in the window registration to hold it.

    And at the beginning of your window proc just grab it out of memory, or if it's the first time through (ie WM_CREATE) then you'll actually need to allocate the pointer and SetWindowLong at that stage. Not forgetting to free the memory when you hit WM_DESTROY.

    You'll have to define a message of your own for WM_USER+3000 or so, and you can handle changing of any of the data that way by accepting a string pointer in WPARAM and an index in LPARAM or maybe a struct pointer in either.

    ...I think you should stick to console.
    Omnis mico antequam dominus Spookster!


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts