Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to Implement a Virtual Grid [modified]

How to Implement a Virtual Grid [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
csharpcssvisual-studiojsonhelp
14 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Stuck At Zero

    Thanks Led. I have an OnNotify function in my code, but I don't know what to do with it. Part of that problem is my confusion over what I need to inside of it as well as feed it. My root problem is the virtual grid. I can turn it on, but after that, I do not know how to add data. Once I can get that going, I guess I can tackle the OnNotify to try and get the cells to actually display in Virtual mode. For now, I don't even know what to feed an OnNotify at least from glossing over what you referred me to, nor do I know what to do inside of an OnNotify function to get the desired effect. I also noted that some of the info you pointed me too is VB. I forgot to mention I'm using Visual C++. Sorry for that oversight on my part. Thanks for the tip on how a hyperlink works. :laugh:

    L Offline
    L Offline
    led mike
    wrote on last edited by
    #4

    Stuck At Zero wrote:

    For now, I don't even know what to feed an OnNotify

    That is specific to each control/message combination. You have to refer to the documentation for the specific control to discover that. In your case it is the CGridControl yes? I haven't worked with it for a few years but you should find lot's of information here on CodeProject about it. Did you look through the  CodeProject Articles?

    S 2 Replies Last reply
    0
    • L led mike

      Stuck At Zero wrote:

      For now, I don't even know what to feed an OnNotify

      That is specific to each control/message combination. You have to refer to the documentation for the specific control to discover that. In your case it is the CGridControl yes? I haven't worked with it for a few years but you should find lot's of information here on CodeProject about it. Did you look through the  CodeProject Articles?

      S Offline
      S Offline
      Stuck At Zero
      wrote on last edited by
      #5

      I have tried looking at the GridControl v2.26 (if I recall correctly), but it's very general information. It's great if I've had experience on CGridControl. It assumes I know what to do on the Callback function. The other problem I have ran into is that it seems CGridCtrl has been ditched in favor of CListCtrl or something like that in other searches I have done via Google / MSDN. If there is a CGridCtrl tutorial that would be appropriate for my situation, I'm more than happy to check it out. I have not been successful in finding what I need in the articles. I'm hoping that someone in the forums knows of a great site that I cannot find via simply googling. If I can find a "Stumble Upon" nudge in the direction of an good site, it would be appreciated.

      1 Reply Last reply
      0
      • L led mike

        Stuck At Zero wrote:

        For now, I don't even know what to feed an OnNotify

        That is specific to each control/message combination. You have to refer to the documentation for the specific control to discover that. In your case it is the CGridControl yes? I haven't worked with it for a few years but you should find lot's of information here on CodeProject about it. Did you look through the  CodeProject Articles?

        S Offline
        S Offline
        Stuck At Zero
        wrote on last edited by
        #6

        I went back and queried for CGridCtrl and the closest thing I get that would be of any help is Chris Maunder's MFC Grid Control 2.26. Because I'm such a newb, I do not totally understand all of the details. I do google those, but nothing that cements everything together... I've got a warm fuzzy. So what I did just now is simply copied and pasted Chris' GridCallback and OnNotify functions one at a time and rebuilt my solution. There is no change. While my worker thread is parsing through the source file, I have it periodically GetCallback after it has been registered (which was after I made the grid into a virtual grid). The other concept I am struggling with is the idea of adding data to a cell that does not exist. With a regular grid control, it was really straightforward. Here, I do not know what I am not doing right. Is there an actual article on CodeProject that goes into more detail into how to implement a Virtual Grid? Maybe Chris has spelled it out, but if it's "obvious", it's not clicking due to my lack of knowledge of all things MFC.

        L 1 Reply Last reply
        0
        • S Stuck At Zero

          I went back and queried for CGridCtrl and the closest thing I get that would be of any help is Chris Maunder's MFC Grid Control 2.26. Because I'm such a newb, I do not totally understand all of the details. I do google those, but nothing that cements everything together... I've got a warm fuzzy. So what I did just now is simply copied and pasted Chris' GridCallback and OnNotify functions one at a time and rebuilt my solution. There is no change. While my worker thread is parsing through the source file, I have it periodically GetCallback after it has been registered (which was after I made the grid into a virtual grid). The other concept I am struggling with is the idea of adding data to a cell that does not exist. With a regular grid control, it was really straightforward. Here, I do not know what I am not doing right. Is there an actual article on CodeProject that goes into more detail into how to implement a Virtual Grid? Maybe Chris has spelled it out, but if it's "obvious", it's not clicking due to my lack of knowledge of all things MFC.

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #7

          Chris Maunders MFC Grid Control is the only CGridCtrl I am aware of. If that is NOT what you are using I don't know where you can find information. If it is Chris's control then the Virtual mode operation is spelled out in the Articl[^]e for the control here on CodeProject.

          Stuck At Zero wrote:

          Because I'm such a newb, I do not totally understand all of the details.

          Any documentation for a control or an API or samples are not going to be trying to help you understand fundamental concepts. They are going to assume you already understand those fundamental concepts because you shouldn't even be trying to do "whatever" unless you already have programming fundamentals required to do it.  :doh:  Which leads to the obvious question, if you are a novice as you state, a newb, why are working on a project that is above your knowledge level?

          S 1 Reply Last reply
          0
          • L led mike

            Chris Maunders MFC Grid Control is the only CGridCtrl I am aware of. If that is NOT what you are using I don't know where you can find information. If it is Chris's control then the Virtual mode operation is spelled out in the Articl[^]e for the control here on CodeProject.

            Stuck At Zero wrote:

            Because I'm such a newb, I do not totally understand all of the details.

            Any documentation for a control or an API or samples are not going to be trying to help you understand fundamental concepts. They are going to assume you already understand those fundamental concepts because you shouldn't even be trying to do "whatever" unless you already have programming fundamentals required to do it.  :doh:  Which leads to the obvious question, if you are a novice as you state, a newb, why are working on a project that is above your knowledge level?

            S Offline
            S Offline
            Stuck At Zero
            wrote on last edited by
            #8

            I am struggling to see where virtual mode implementation is spelled out. The link you sent me is the same I've been looking at. I see descriptions of what each function does and I see code examples of OnNotify and CallBack. There's no explanation I see that explains exactly how data is added to a virtual cell other than saying OnNotify and CallBack are needed for this operation. What I have at the moment is a working non-virtual grid. I need to make it virtual for the reasons Chris explained as to why one is needed. I can populate this non-virtual grid with data. But when I flip the switch for Virtual, poof! Nothing. As for why I'm trying to implement a virtual grid, it's because I was told that this would be needed in order to accomplish listing lots of data on a grid control. No one around me has tried this feature so I'm left on my own to figure it out. If I am a novice as I state? You sound like you don't believe me. :laugh: I get the idea of what Chris is trying to convey, but I don't understand the implementation.

            L 1 Reply Last reply
            0
            • S Stuck At Zero

              I am struggling to see where virtual mode implementation is spelled out. The link you sent me is the same I've been looking at. I see descriptions of what each function does and I see code examples of OnNotify and CallBack. There's no explanation I see that explains exactly how data is added to a virtual cell other than saying OnNotify and CallBack are needed for this operation. What I have at the moment is a working non-virtual grid. I need to make it virtual for the reasons Chris explained as to why one is needed. I can populate this non-virtual grid with data. But when I flip the switch for Virtual, poof! Nothing. As for why I'm trying to implement a virtual grid, it's because I was told that this would be needed in order to accomplish listing lots of data on a grid control. No one around me has tried this feature so I'm left on my own to figure it out. If I am a novice as I state? You sound like you don't believe me. :laugh: I get the idea of what Chris is trying to convey, but I don't understand the implementation.

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #9

              Stuck At Zero wrote:

              There's no explanation I see that explains exactly how data is added to a virtual cell

              Are you blind? From the article sample code in the "Virtual Mode" section:

              pDispInfo->item.strText.Format(_T("Message %d,%d")

              Stuck At Zero wrote:

              No one around me has tried this feature

              No one in your shop knows how callbacks or OnNotify work or knows how to read and understand the sample code in the article? Is this a school project?

              S 1 Reply Last reply
              0
              • L led mike

                Stuck At Zero wrote:

                There's no explanation I see that explains exactly how data is added to a virtual cell

                Are you blind? From the article sample code in the "Virtual Mode" section:

                pDispInfo->item.strText.Format(_T("Message %d,%d")

                Stuck At Zero wrote:

                No one around me has tried this feature

                No one in your shop knows how callbacks or OnNotify work or knows how to read and understand the sample code in the article? Is this a school project?

                S Offline
                S Offline
                Stuck At Zero
                wrote on last edited by
                #10

                I suppose I am blind but I still don't totally understand that line. Chris says "If no callback function is specified then the grid will send a GVN_GETDISPINFO message to it's parent" This led me to believe this works under the hood, or so I thought. I have come to CodeProject because there seems to be little information out there that can explain things more for the novice. I'm not asking to be spoon fed, but I think this is your impression. I am truly sorry if the obvious for you is not obvious for me. I did say I am a novice and I am trying to do what I was told to implement. I did not say people at my place of work did not know how OnNotify or Callbacks work. I said no one has ever done a Virtual Grid before so they do not know. I really wished this was a school project. At least I could go straight to the teacher and ask the dumb questions. From what you're telling me, this one line will magically populate all my cells with ease. As I explained before, I have copied this into my code and I get no change in behavior. I assumed from the quote I provided above that this all worked "under the hood". Prior to trying to add this feature, I have never heard of OnNotify or Callback functions. What I still do not know is how a particular virtual cell gets the specific bit of data it needs. Also, I do not know if this could be a problem, but my solution is based on CFormView.

                L 1 Reply Last reply
                0
                • S Stuck At Zero

                  I suppose I am blind but I still don't totally understand that line. Chris says "If no callback function is specified then the grid will send a GVN_GETDISPINFO message to it's parent" This led me to believe this works under the hood, or so I thought. I have come to CodeProject because there seems to be little information out there that can explain things more for the novice. I'm not asking to be spoon fed, but I think this is your impression. I am truly sorry if the obvious for you is not obvious for me. I did say I am a novice and I am trying to do what I was told to implement. I did not say people at my place of work did not know how OnNotify or Callbacks work. I said no one has ever done a Virtual Grid before so they do not know. I really wished this was a school project. At least I could go straight to the teacher and ask the dumb questions. From what you're telling me, this one line will magically populate all my cells with ease. As I explained before, I have copied this into my code and I get no change in behavior. I assumed from the quote I provided above that this all worked "under the hood". Prior to trying to add this feature, I have never heard of OnNotify or Callback functions. What I still do not know is how a particular virtual cell gets the specific bit of data it needs. Also, I do not know if this could be a problem, but my solution is based on CFormView.

                  L Offline
                  L Offline
                  led mike
                  wrote on last edited by
                  #11

                  Stuck At Zero wrote:

                  What I still do not know is how a particular virtual cell gets the specific bit of data it needs.

                  The GV_DISPINFO.item member "is" the cell the OnNotify or Callback, which ever one you are using, is called for "each cell". You have the responsibility of figuring out what data needs to go into that cell.

                  Stuck At Zero wrote:

                  I suppose I am blind but I still don't totally understand that line.

                  It just sets the text value of the  cell . I don't know how  more  clear that  can be.

                  Stuck At Zero wrote:

                  Chris says "If no callback function is specified then the grid will send a GVN_GETDISPINFO message to it's parent" This led me to believe this works under the hood, or so I thought.

                  Yes that behavior is "internal" to the CGridCtrl. When you "turn on" Virtual Mode, the control will send OnNotify messages if no Callback has been registered.

                  Stuck At Zero wrote:

                  I'm not asking to be spoon fed, but I think this is your impression. I am truly sorry if the obvious for you is not obvious for me.

                  No that is not my point at all. My point is, and we see it  here at  CodeProject all the time, is that  beginners should NOT  be developing production code. They are just not capable and this  instance with you  is  yet another example. People  should actually learn how to  develop software  before  working on production projects. No  one is born  knowing what is required to develop software, it is not  someones  fault that they don't  know,  however it is someone's  fault, I don't know who,  that a person that is not qualified to work on  production projects is.

                  S 1 Reply Last reply
                  0
                  • L led mike

                    Stuck At Zero wrote:

                    What I still do not know is how a particular virtual cell gets the specific bit of data it needs.

                    The GV_DISPINFO.item member "is" the cell the OnNotify or Callback, which ever one you are using, is called for "each cell". You have the responsibility of figuring out what data needs to go into that cell.

                    Stuck At Zero wrote:

                    I suppose I am blind but I still don't totally understand that line.

                    It just sets the text value of the  cell . I don't know how  more  clear that  can be.

                    Stuck At Zero wrote:

                    Chris says "If no callback function is specified then the grid will send a GVN_GETDISPINFO message to it's parent" This led me to believe this works under the hood, or so I thought.

                    Yes that behavior is "internal" to the CGridCtrl. When you "turn on" Virtual Mode, the control will send OnNotify messages if no Callback has been registered.

                    Stuck At Zero wrote:

                    I'm not asking to be spoon fed, but I think this is your impression. I am truly sorry if the obvious for you is not obvious for me.

                    No that is not my point at all. My point is, and we see it  here at  CodeProject all the time, is that  beginners should NOT  be developing production code. They are just not capable and this  instance with you  is  yet another example. People  should actually learn how to  develop software  before  working on production projects. No  one is born  knowing what is required to develop software, it is not  someones  fault that they don't  know,  however it is someone's  fault, I don't know who,  that a person that is not qualified to work on  production projects is.

                    S Offline
                    S Offline
                    Stuck At Zero
                    wrote on last edited by
                    #12

                    Okay, I will try and figure out how get what I need into the GV_DISPINFO.item member to absorb what I already pass to cells in the non-virtual mode. How do I set item.row and item.col for pDispInfo? Out of frustration I tried using Callback and OnNotify at the same time. It seems I never have to call OnNotify because MSDN says "The framework calls this member function to inform the parent window of a control that an event has occurred in the control or that the control requires some kind of information." Did I understand this correctly or must I actually call on OnNotify? Understood on the beginners comment and I don't disagree. They pay my bills so I'm willing to learn. :-D It's probably not the most efficient way of doing things but it's the OJT or self-discovery mentality. It works sometimes. Other times not. This is one of those other times for me. For now my work is restricted to MFC stuff and unmanaged code which I'm not so sure the importance of that is, but learn I must. Thanks for the help. This may be the nudge in the right direction I needed. Is there a really good MFC book out there you'd recommend for a newb like me?

                    L D 2 Replies Last reply
                    0
                    • S Stuck At Zero

                      Okay, I will try and figure out how get what I need into the GV_DISPINFO.item member to absorb what I already pass to cells in the non-virtual mode. How do I set item.row and item.col for pDispInfo? Out of frustration I tried using Callback and OnNotify at the same time. It seems I never have to call OnNotify because MSDN says "The framework calls this member function to inform the parent window of a control that an event has occurred in the control or that the control requires some kind of information." Did I understand this correctly or must I actually call on OnNotify? Understood on the beginners comment and I don't disagree. They pay my bills so I'm willing to learn. :-D It's probably not the most efficient way of doing things but it's the OJT or self-discovery mentality. It works sometimes. Other times not. This is one of those other times for me. For now my work is restricted to MFC stuff and unmanaged code which I'm not so sure the importance of that is, but learn I must. Thanks for the help. This may be the nudge in the right direction I needed. Is there a really good MFC book out there you'd recommend for a newb like me?

                      L Offline
                      L Offline
                      led mike
                      wrote on last edited by
                      #13

                      Stuck At Zero wrote:

                      How do I set item.row and item.col for pDispInfo?

                      No, you "get" the column and row, that's what you use to know what information goes into that specific cell. Also note the ODCACHEHINT message which will give you the entire range of cells that are going to be asked for in the subsequent GVN_GETDISPINFO messages. The idea there is that you would query a database or read a file for all the cell data required and cache it for use in the subsequent GETDISPINFO messages rather than doing all that work for each cells message.

                      Stuck At Zero wrote:

                      Is there a really good MFC book out there you'd recommend for a newb like me?

                      Oh i wouldn't know any longer, I started back in the 90's and there where decent books then. There are tutorials on MSDN and such but issues like callbacks are before MFC, they are basic C concepts and OnNotify is also something you have to understand conceptually. You need, as with all beginners, some basic programming concepts studying. I started out in school learning how processors and systems worked like how they accesses memory, disks, IO ports, video memory, the stack, jumps, registers etc. Everything else is built on top of that so when you got to a high level language like C, everything just mapped back to those fundamental things so it was relatively easy to understand. It's whole new world now where people start right out with IDEs, drag and drop, and high level languages and then try to learn things going backwards towards the fundamentals after they are already developing production code and run into the issues. You can see how I have no experience with that so it is difficult to advise how to do it that way.

                      1 Reply Last reply
                      0
                      • S Stuck At Zero

                        Okay, I will try and figure out how get what I need into the GV_DISPINFO.item member to absorb what I already pass to cells in the non-virtual mode. How do I set item.row and item.col for pDispInfo? Out of frustration I tried using Callback and OnNotify at the same time. It seems I never have to call OnNotify because MSDN says "The framework calls this member function to inform the parent window of a control that an event has occurred in the control or that the control requires some kind of information." Did I understand this correctly or must I actually call on OnNotify? Understood on the beginners comment and I don't disagree. They pay my bills so I'm willing to learn. :-D It's probably not the most efficient way of doing things but it's the OJT or self-discovery mentality. It works sometimes. Other times not. This is one of those other times for me. For now my work is restricted to MFC stuff and unmanaged code which I'm not so sure the importance of that is, but learn I must. Thanks for the help. This may be the nudge in the right direction I needed. Is there a really good MFC book out there you'd recommend for a newb like me?

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #14

                        Stuck At Zero wrote:

                        Did I understand this correctly...

                        Yes.

                        Stuck At Zero wrote:

                        ...must I actually call on OnNotify?

                        No. It's a virtual function that the framework calls. When you respond to the notification from within the OnNotify() method, you are telling the grid control what to display. Think of it this way. With a non-virtual control, you tell the control what to display and where, and it goes off and does so. With a virtual control, it will tell you that it needs something to display at such-and-such row/column, and it's up to you to provide that. Any clearer?


                        "A good athlete is the result of a good and worthy opponent." - David Crow

                        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups