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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Windows Programming Question

Windows Programming Question

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
5 Posts 2 Posters 0 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.
  • A Offline
    A Offline
    Alan Chambers
    wrote on last edited by
    #1

    Hi all, I am in a bit of a Dilemma. My app currently takes the format: Declare Globals. function InitApp(). function UpdateFrame(). function CallBack WindowProc(). function WinMain(). I would like to incorporate a CD3DApp class which WinMain() would create, initialise and set the Run() function. The CD3DApp class would then handle its own messages in a similar style to the code: while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); ProcessMessage(&msg); } which obviously uses the WindowProc CallBack function (so I could specify which buttons do what etc.). I DO NOT want to use MFC. I would like to make my InitApp(), UpdateFrame() and Run() a part of the CD3DApp class and also the global variables as member variables (I think the code is much cleaner then). However, if I put the messaging code listed above in the Run() the CallBack WindowProc cannot access the member variables of the CD3DApp class because the object hasn't been passed through to it (whereas before they were global which allowed for access). There is a timer in the WindowProc which is used to create an animation, which is why I would like access to the CD3DApp class. What I would like to know is: 1.) Is there any way of creating a class that has its own WindowProc function, so that it can access the member variables? 2.) If not, is there any better way to go about solving this problem of getting the code cleaner (losing the globals)? "When I left you I was but the learner, now I am the master" - Darth Vader

    M 1 Reply Last reply
    0
    • A Alan Chambers

      Hi all, I am in a bit of a Dilemma. My app currently takes the format: Declare Globals. function InitApp(). function UpdateFrame(). function CallBack WindowProc(). function WinMain(). I would like to incorporate a CD3DApp class which WinMain() would create, initialise and set the Run() function. The CD3DApp class would then handle its own messages in a similar style to the code: while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); ProcessMessage(&msg); } which obviously uses the WindowProc CallBack function (so I could specify which buttons do what etc.). I DO NOT want to use MFC. I would like to make my InitApp(), UpdateFrame() and Run() a part of the CD3DApp class and also the global variables as member variables (I think the code is much cleaner then). However, if I put the messaging code listed above in the Run() the CallBack WindowProc cannot access the member variables of the CD3DApp class because the object hasn't been passed through to it (whereas before they were global which allowed for access). There is a timer in the WindowProc which is used to create an animation, which is why I would like access to the CD3DApp class. What I would like to know is: 1.) Is there any way of creating a class that has its own WindowProc function, so that it can access the member variables? 2.) If not, is there any better way to go about solving this problem of getting the code cleaner (losing the globals)? "When I left you I was but the learner, now I am the master" - Darth Vader

      M Offline
      M Offline
      Michael P Butler
      wrote on last edited by
      #2

      Have a look at this, it should help you build a mini-framework. http://www.dilascia.com/wpp.htm Michael :-) Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor

      A 1 Reply Last reply
      0
      • M Michael P Butler

        Have a look at this, it should help you build a mini-framework. http://www.dilascia.com/wpp.htm Michael :-) Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor

        A Offline
        A Offline
        Alan Chambers
        wrote on last edited by
        #3

        Thanks for the link Michael, I've downloaded the resource and am going to try and rip it apart to get what I need. Essentially, I'd like to do my own framework and just need a little guidance, so hopefully this will be it. Many Thanks, Alan. "When I left you I was but the learner, now I am the master" - Darth Vader

        M 1 Reply Last reply
        0
        • A Alan Chambers

          Thanks for the link Michael, I've downloaded the resource and am going to try and rip it apart to get what I need. Essentially, I'd like to do my own framework and just need a little guidance, so hopefully this will be it. Many Thanks, Alan. "When I left you I was but the learner, now I am the master" - Darth Vader

          M Offline
          M Offline
          Michael P Butler
          wrote on last edited by
          #4

          I have a copy of the book and I used it to build my own little DirectX framework. The book is well worth reading if you can find a copy. Michael :-) Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor

          A 1 Reply Last reply
          0
          • M Michael P Butler

            I have a copy of the book and I used it to build my own little DirectX framework. The book is well worth reading if you can find a copy. Michael :-) Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor

            A Offline
            A Offline
            Alan Chambers
            wrote on last edited by
            #5

            Cheers Michael, will keep my eyes peeled for it when I'm in Waterstones or Blackwells next:-D "When I left you I was but the learner, now I am the master" - Darth Vader

            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