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. A simple question...

A simple question...

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
8 Posts 5 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I've begun to learn VC (MFC) few days ago. i want to make something using the "ExtractIcon()" function. the first paramter of this function (as written in MSDN) is a handle to instance of the application. How the hell do i get this handle? what should i send him as this first parameter? thanks a lot RG

    C 1 Reply Last reply
    0
    • L Lost User

      I've begun to learn VC (MFC) few days ago. i want to make something using the "ExtractIcon()" function. the first paramter of this function (as written in MSDN) is a handle to instance of the application. How the hell do i get this handle? what should i send him as this first parameter? thanks a lot RG

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      Call AfxGetInstanceHandle -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

      L 1 Reply Last reply
      0
      • C Chris Losinger

        Call AfxGetInstanceHandle -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        look at this code: ... HICON icon = ExtractAssociatedIcon(AfxGetInstanceHandle() , "D:\\file.fp", 0); ASERT(icon==NULL) static.Create(NULL, WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50), this); static.SetIcon(icon); ... static is CStatic variable. i dont know why, but this code causes an error, the windows error message: "illigal operation" appears. and it happens only after i use this function.... have any ideas? thanks RG

        P A 2 Replies Last reply
        0
        • L Lost User

          look at this code: ... HICON icon = ExtractAssociatedIcon(AfxGetInstanceHandle() , "D:\\file.fp", 0); ASERT(icon==NULL) static.Create(NULL, WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50), this); static.SetIcon(icon); ... static is CStatic variable. i dont know why, but this code causes an error, the windows error message: "illigal operation" appears. and it happens only after i use this function.... have any ideas? thanks RG

          P Offline
          P Offline
          Paolo Messina
          wrote on last edited by
          #4

          Do you mean ASSERT(icon != NULL) ?

          1 Reply Last reply
          0
          • L Lost User

            look at this code: ... HICON icon = ExtractAssociatedIcon(AfxGetInstanceHandle() , "D:\\file.fp", 0); ASERT(icon==NULL) static.Create(NULL, WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50), this); static.SetIcon(icon); ... static is CStatic variable. i dont know why, but this code causes an error, the windows error message: "illigal operation" appears. and it happens only after i use this function.... have any ideas? thanks RG

            A Offline
            A Offline
            Andrew Peace
            wrote on last edited by
            #5

            As above about ASSERT;

            ASSERT(icon != NULL);

            And also, the icon variable has to be present for the lifetime of the static control - thus you must put it as a member variable of the class, or as a global variable. > Andrew.

            R 1 Reply Last reply
            0
            • A Andrew Peace

              As above about ASSERT;

              ASSERT(icon != NULL);

              And also, the icon variable has to be present for the lifetime of the static control - thus you must put it as a member variable of the class, or as a global variable. > Andrew.

              R Offline
              R Offline
              Reid
              wrote on last edited by
              #6

              You know, you COULD put it as a global variable... but then again, we also COULD write poor poor poor code... If I were you, i would stick to putting it as a member variable of the Document class or the View class...depends on how it is used... -Reid the C++/C# programmer (Caution: I am a teenager, and that means that I think I know everything...but probably don't...)

              A 1 Reply Last reply
              0
              • R Reid

                You know, you COULD put it as a global variable... but then again, we also COULD write poor poor poor code... If I were you, i would stick to putting it as a member variable of the Document class or the View class...depends on how it is used... -Reid the C++/C# programmer (Caution: I am a teenager, and that means that I think I know everything...but probably don't...)

                A Offline
                A Offline
                Andrew Peace
                wrote on last edited by
                #7

                Yes you're right about the global variable (obviously) but I said that because....hmmmm....don't know why I said that. You're right - it should be a member of the class that's using it. Truth be told, the reason I said global variable was because I thought maybe he wasn't doing OOP programming, in which case that's pretty much the only alternative. > Andrew.

                L 1 Reply Last reply
                0
                • A Andrew Peace

                  Yes you're right about the global variable (obviously) but I said that because....hmmmm....don't know why I said that. You're right - it should be a member of the class that's using it. Truth be told, the reason I said global variable was because I thought maybe he wasn't doing OOP programming, in which case that's pretty much the only alternative. > Andrew.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  you were right about the ASSERT parameter, but still, i dont understand why i get this error message, and it happens only because i used the AfxGetInstanceHandle() function. Please heeelp! thanks.

                  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