Thread: Menu like file, edit, help, etc...

  1. #31
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    wx is probably the best way to do this. But, there is a registry key HKCR\htmlfile\shell\open\command that for me (using IE 7.0) like this:
    "C:\Program Files\Internet Explorer\IEXPLORE.EXE" -nohome
    This last part shows the default browser. So if in your prog you loaded this key and then ran that program in your program with the correct arguments, I guess it's possible.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  2. #32
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Quote Originally Posted by Livijn
    Isn't there any code like GotoURL("http://....", _Blank....);
    FAQ > How do I... (Level 2) > Run a program from within a program - scroll to the bottom of that faq page; ShellExecute is the simplest option.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #33
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    I was talking about how to know which browser was the user's default.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  4. #34
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    I guess you mean this code...

    Code:
    #include <windows.h>  //You need shell32.lib for this one 
    
    int main(void)
    {
      char szPath[] = "C:\Program Files\Internet Explorer\IEXPLORE.EXE"                                                                                          ;
    
      HINSTANCE hRet = ShellExecute(
            HWND_DESKTOP, //Parent window
            "open",       //Operation to perform
            szPath,       //Path to program
            NULL,         //Parameters
            NULL,         //Default directory
            SW_SHOW);     //How to open
    
      /*
      The function returns a HINSTANCE (not really useful in this case)
      So therefore, to test its result, we cast it to a LONG.
      Any value over 32 represents success!
      */
    
      if((LONG)hRet <= 32)
      {
        MessageBox(HWND_DESKTOP,"Unable to start program","",MB_OK);
        return 1;
      }
    
      return 0;
    }
    Can i change the int main (void) to int call (void) or something

  5. #35
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    Is this what you need?

    Code:
    #include <windows.h>
    
    int main(void)
    {      
       ShellExecute(NULL, "open","http://livijnproductions.se",  NULL, NULL,SW_SHOWNORMAL); 
       return 0;
    }

  6. #36
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    i think it is, but if i want to open a file...

    Code:
    #include <windows.h>
    
    int main(void)
    {      
       ShellExecute(NULL, "open","C://Program/Jinky/README.html",  NULL, NULL,SW_SHOWNORMAL); 
       return 0;
    }
    is this right?

  7. #37
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    That'll work as long as the path to the HTML file is legit.

  8. #38
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    I'm not english, what does legit mean? Guilty?

  9. #39
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    It's short for 'legitimate' - in this context it means the url/path must be to a valid web address or html file, otherwise your default browser (or whatever is the default application for html files on your system) will start but will report an error.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  10. #40
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    it doesn't start for me... the C:// path file but the http// starts... wh`yh?

  11. #41
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    maybe it is because c:/ should have only 1 slash?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  12. #42
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    Does it matter if i write C:\ or C:/ ?

  13. #43
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by Livijn
    Does it matter if i write C:\ or C:/ ?
    Oh yes it does. / is only for web sites. Also, you should use \\ everywhere unless you want to use something like \n or \r or \0.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  14. #44
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Windows seems to accept both slashes in some cases (for example Start>Run on XP Home), but \ is correct and / might work but not always. And \ needs to be escaped.

  15. #45
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    aka
    Code:
    std::string a = "C:\\";
    std::string b = "C:/";
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  5. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM