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. Loading resources?

Loading resources?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncom
11 Posts 4 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 Lord Kixdemp

    Hello everyone! :-D Another question... How do I load a string from a string table from resources? Thanks! ;-) Sulfurik K. Nosferathus (Darth_Sulfur) www.SulfurMidis.com www.SulfurSoft.tk http://www.BeepXtreme.tk [ftp://][http://][hotline://]tsfc.ath.cx

    B Offline
    B Offline
    BadKarma
    wrote on last edited by
    #2

    hi you can use the CString constructor to do this CString strInfo(IDS_INFO); or the Format method of CString if the reseource string needs additional paramaters like this: // if resource string is 'Hello %s' CString strHelloWorld; strHelloWorld.Format(IDS_HELLO, "world"); Regards codito ergo sum

    1 Reply Last reply
    0
    • L Lord Kixdemp

      Hello everyone! :-D Another question... How do I load a string from a string table from resources? Thanks! ;-) Sulfurik K. Nosferathus (Darth_Sulfur) www.SulfurMidis.com www.SulfurSoft.tk http://www.BeepXtreme.tk [ftp://][http://][hotline://]tsfc.ath.cx

      Q Offline
      Q Offline
      qfegd
      wrote on last edited by
      #3

      You can also use AfxFormatString1 & AfxFormatString2 if your resource HELLO_ID is: "Hello %1" you can do: CString result; AfxFormatString1(result HELLO_ID, "World"); it gives u Hello World Eric Premature optimization is the root of all evil

      1 Reply Last reply
      0
      • L Lord Kixdemp

        Hello everyone! :-D Another question... How do I load a string from a string table from resources? Thanks! ;-) Sulfurik K. Nosferathus (Darth_Sulfur) www.SulfurMidis.com www.SulfurSoft.tk http://www.BeepXtreme.tk [ftp://][http://][hotline://]tsfc.ath.cx

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #4

        CString strFoo;
        VERIFY (strFoo.LoadString (IDS_Foo));

        /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

        L 1 Reply Last reply
        0
        • RaviBeeR RaviBee

          CString strFoo;
          VERIFY (strFoo.LoadString (IDS_Foo));

          /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

          L Offline
          L Offline
          Lord Kixdemp
          wrote on last edited by
          #5

          Hmm... seems like it won't work: --------------------------- #include #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CString errors; errors.LoadString(IDS_ERROR1); MessageBox(NULL, errors, "Hello", MB_OK); return 0; } --------------------------- Errors: --------------------------- C:\VCProjs\KixWTF\KixWTF.cpp(14) : error C2065: 'CString' : undeclared identifier C:\VCProjs\KixWTF\KixWTF.cpp(14) : error C2146: syntax error : missing ';' before identifier 'errors' C:\VCProjs\KixWTF\KixWTF.cpp(14) : error C2065: 'errors' : undeclared identifier C:\VCProjs\KixWTF\KixWTF.cpp(16) : error C2228: left of '.LoadStringA' must have class/struct/union type C:\VCProjs\KixWTF\KixWTF.cpp(16) : error C2065: 'IDS_ERROR1' : undeclared identifier --------------------------- Anyone know? :( Thanks! ;-) PS: <code> tag didn't work. :-( Sulfurik K. Nosferathus (Darth_Sulfur) www.SulfurMidis.com www.SulfurSoft.tk http://www.BeepXtreme.tk [ftp://][http://][hotline://]tsfc.ath.cx

          RaviBeeR 1 Reply Last reply
          0
          • L Lord Kixdemp

            Hmm... seems like it won't work: --------------------------- #include #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CString errors; errors.LoadString(IDS_ERROR1); MessageBox(NULL, errors, "Hello", MB_OK); return 0; } --------------------------- Errors: --------------------------- C:\VCProjs\KixWTF\KixWTF.cpp(14) : error C2065: 'CString' : undeclared identifier C:\VCProjs\KixWTF\KixWTF.cpp(14) : error C2146: syntax error : missing ';' before identifier 'errors' C:\VCProjs\KixWTF\KixWTF.cpp(14) : error C2065: 'errors' : undeclared identifier C:\VCProjs\KixWTF\KixWTF.cpp(16) : error C2228: left of '.LoadStringA' must have class/struct/union type C:\VCProjs\KixWTF\KixWTF.cpp(16) : error C2065: 'IDS_ERROR1' : undeclared identifier --------------------------- Anyone know? :( Thanks! ;-) PS: <code> tag didn't work. :-( Sulfurik K. Nosferathus (Darth_Sulfur) www.SulfurMidis.com www.SulfurSoft.tk http://www.BeepXtreme.tk [ftp://][http://][hotline://]tsfc.ath.cx

            RaviBeeR Offline
            RaviBeeR Offline
            RaviBee
            wrote on last edited by
            #6

            I assumed you were building an MFC app. Here's[^] a link to the Win32 version of the API. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

            L 1 Reply Last reply
            0
            • RaviBeeR RaviBee

              I assumed you were building an MFC app. Here's[^] a link to the Win32 version of the API. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

              L Offline
              L Offline
              Lord Kixdemp
              wrote on last edited by
              #7

              Hmm... yeah, I kinda wanted to use MFC... Do you know how to make a MFC app, but without a main window? Thanks! ;-) Sulfurik K. Nosferathus (Darth_Sulfur) www.SulfurMidis.com www.SulfurSoft.tk http://www.BeepXtreme.tk [ftp://][http://][hotline://]tsfc.ath.cx

              RaviBeeR 1 Reply Last reply
              0
              • L Lord Kixdemp

                Hmm... yeah, I kinda wanted to use MFC... Do you know how to make a MFC app, but without a main window? Thanks! ;-) Sulfurik K. Nosferathus (Darth_Sulfur) www.SulfurMidis.com www.SulfurSoft.tk http://www.BeepXtreme.tk [ftp://][http://][hotline://]tsfc.ath.cx

                RaviBeeR Offline
                RaviBeeR Offline
                RaviBee
                wrote on last edited by
                #8

                Darth_Sulfur wrote:

                Do you know how to make a MFC app, but without a main window?

                Create a console application and select MFC support. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                L 1 Reply Last reply
                0
                • RaviBeeR RaviBee

                  Darth_Sulfur wrote:

                  Do you know how to make a MFC app, but without a main window?

                  Create a console application and select MFC support. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                  L Offline
                  L Offline
                  Lord Kixdemp
                  wrote on last edited by
                  #9

                  Yay! Seems good, but I have a DOS box in the background... How do I take that out? Thanks! ;-) Sulfurik K. Nosferathus (Darth_Sulfur) www.SulfurMidis.com www.SulfurSoft.tk http://www.BeepXtreme.tk [ftp://][http://][hotline://]tsfc.ath.cx

                  RaviBeeR 1 Reply Last reply
                  0
                  • L Lord Kixdemp

                    Yay! Seems good, but I have a DOS box in the background... How do I take that out? Thanks! ;-) Sulfurik K. Nosferathus (Darth_Sulfur) www.SulfurMidis.com www.SulfurSoft.tk http://www.BeepXtreme.tk [ftp://][http://][hotline://]tsfc.ath.cx

                    RaviBeeR Offline
                    RaviBeeR Offline
                    RaviBee
                    wrote on last edited by
                    #10

                    Darth_Sulfur wrote:

                    but I have a DOS box in the background... How do I take that out?

                    Create an MFC dialog based application and don't create the dialog in your app's InitInstance() method.  Instead, just execute whatever (non-GUI) code you wish to call. Note, your app will exit when it returns from InitInstance(). Hope this helps! /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                    L 1 Reply Last reply
                    0
                    • RaviBeeR RaviBee

                      Darth_Sulfur wrote:

                      but I have a DOS box in the background... How do I take that out?

                      Create an MFC dialog based application and don't create the dialog in your app's InitInstance() method.  Instead, just execute whatever (non-GUI) code you wish to call. Note, your app will exit when it returns from InitInstance(). Hope this helps! /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                      L Offline
                      L Offline
                      Lord Kixdemp
                      wrote on last edited by
                      #11

                      That worked! Thanks very much! :-D Sulfurik K. Nosferathus (Darth_Sulfur) www.SulfurMidis.com www.SulfurSoft.tk http://www.BeepXtreme.tk [ftp://][http://][hotline://]tsfc.ath.cx

                      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