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. problem with trivial MFC app

problem with trivial MFC app

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptestingbeta-testingquestion
5 Posts 3 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.
  • M Offline
    M Offline
    Mister Transistor
    wrote on last edited by
    #1

    As testing for a real MFC application I made a trivial one, but ran in to problems. To my mind this exemplifies the difficulties faced by the newbie to MFC and doc/view. I wanted a single-window MFC doc/view app with a static control on the window. I used AppWizard to make an MFC EXE. It ran and showed an empty window. I put my static control in the view .h file private: CStatic Statcontrol; Now I made my ..Create() in the view .cpp file RECT rect = {100,100,200,200}; Statcontrol.Create("hello",WS_CHILD | WS_VISIBLE | SS_CENTER,rect,this,ID_STAT); But where do I put this code? In the view constructor it fails. In PreCreateWindow() it fails. All I get is a FALSE return - not much diagnostics. (But I guess 'this' is wrong). In the OnDraw() handler it works! But then it's called multiple times. Help! Why is something so simple so difficult? MFC books never help with things like this. Andrew MisterTransistor - germanium is King

    G A 2 Replies Last reply
    0
    • M Mister Transistor

      As testing for a real MFC application I made a trivial one, but ran in to problems. To my mind this exemplifies the difficulties faced by the newbie to MFC and doc/view. I wanted a single-window MFC doc/view app with a static control on the window. I used AppWizard to make an MFC EXE. It ran and showed an empty window. I put my static control in the view .h file private: CStatic Statcontrol; Now I made my ..Create() in the view .cpp file RECT rect = {100,100,200,200}; Statcontrol.Create("hello",WS_CHILD | WS_VISIBLE | SS_CENTER,rect,this,ID_STAT); But where do I put this code? In the view constructor it fails. In PreCreateWindow() it fails. All I get is a FALSE return - not much diagnostics. (But I guess 'this' is wrong). In the OnDraw() handler it works! But then it's called multiple times. Help! Why is something so simple so difficult? MFC books never help with things like this. Andrew MisterTransistor - germanium is King

      G Offline
      G Offline
      Gary Kirkham
      wrote on last edited by
      #2

      Try putting it in your view class OnInitialUpdate function leave CStatic Statcontrol in the header...should work Gary Kirkham A working Program is one that has only unobserved bugs I thought I wanted a career, turns out I just wanted paychecks

      M 1 Reply Last reply
      0
      • M Mister Transistor

        As testing for a real MFC application I made a trivial one, but ran in to problems. To my mind this exemplifies the difficulties faced by the newbie to MFC and doc/view. I wanted a single-window MFC doc/view app with a static control on the window. I used AppWizard to make an MFC EXE. It ran and showed an empty window. I put my static control in the view .h file private: CStatic Statcontrol; Now I made my ..Create() in the view .cpp file RECT rect = {100,100,200,200}; Statcontrol.Create("hello",WS_CHILD | WS_VISIBLE | SS_CENTER,rect,this,ID_STAT); But where do I put this code? In the view constructor it fails. In PreCreateWindow() it fails. All I get is a FALSE return - not much diagnostics. (But I guess 'this' is wrong). In the OnDraw() handler it works! But then it's called multiple times. Help! Why is something so simple so difficult? MFC books never help with things like this. Andrew MisterTransistor - germanium is King

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        There is no such thing as a "trival MFC" app. That's why it is EOL;P

        1 Reply Last reply
        0
        • G Gary Kirkham

          Try putting it in your view class OnInitialUpdate function leave CStatic Statcontrol in the header...should work Gary Kirkham A working Program is one that has only unobserved bugs I thought I wanted a career, turns out I just wanted paychecks

          M Offline
          M Offline
          Mister Transistor
          wrote on last edited by
          #4

          Gary, thanks - that has indeed fixed it. You don't by chance know a good book/article that explains the principles of MFC programming rather than just showing which menus to click? cheers Andrew

          G 1 Reply Last reply
          0
          • M Mister Transistor

            Gary, thanks - that has indeed fixed it. You don't by chance know a good book/article that explains the principles of MFC programming rather than just showing which menus to click? cheers Andrew

            G Offline
            G Offline
            Gary Kirkham
            wrote on last edited by
            #5

            I am kind of partial to "Inside Visual C++" by Kruglinski. I have found that the best way to learn MFC is by doing. I have never learned much from reproducing book examples. I came from a C, Basic, FORTRAN, assembly language background. I learned the most by taking one of my old programs and making a MFC application out of it. I already knew how the meat of the program worked, so I could just concentrate on the GUI interface. I would use the programming books I bought (I own quite a few) and use the coding examples that applied to the program I was writting. It may not be the best way to learn MFC, but it worked for me. Gary Kirkham A working Program is one that has only unobserved bugs I thought I wanted a career, turns out I just wanted paychecks

            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