Showing a web page

Discussion in 'Indie Basics' started by Phil Steinmeyer, Aug 29, 2005.

  1. Phil Steinmeyer

    Original Member

    Joined:
    Mar 1, 2005
    Messages:
    757
    Likes Received:
    0
    Within game, I'm showing a web page as follows:

    ShellExecute(NULL, "open", "http://www.newcrayon.com", "", "", SW_SHOW );

    It seems to work, whether I'm full screen or not, but I vaguely remember running into some problems with this a couple of years ago, depending on what browser the user has, etc.

    Is the above the right way to do this or is there something better?

    How about on the Mac - what's the syntax there?
     
  2. ggambett

    Moderator Original Member Indie Author

    Joined:
    Jul 26, 2004
    Messages:
    1,982
    Likes Received:
    6
    My code...
    Code:
    void openURL (const char* sBaseURL)
    {
    	String sURL = sBaseURL;
    
    #if defined(WIN32)
    
    	ShellExecute(NULL, "open", sURL, NULL, NULL, SW_SHOWNORMAL);
    
    #elif defined(linux)
    
    	if (fork() == 0)
    	{
    		printf("Attempting to open URL %s\n", (const char*)sURL);
    
    		for (int i = 0; i < nBrowsers; i++)
    		{
    			String sCmd = lBrowsers[i] + String(" ") + String(sURL);
    			int nRet = system(sCmd);
    
    			if (nRet == -1)
    			{
    				// The system() call itself failed
    			}
    			else
    			{
    				nRet = WEXITSTATUS(nRet);
    				if (nRet == 0)
    		 		exit(1);	// Success!
    			}
    		}
    
    		GFC_WARNING("Couldn't execute any browser!");
    		exit(1);
    	}
    
    #elif defined(__APPLE__)
    
    	OSStatus nErr;
    	ICInstance pInst;
    	long nStartSel = 0;
    	long nEndSel = sURL.getLength();
    
    	nErr = ICStart(&pInst, 'MYST');
    	nErr = ICLaunchURL(pInst, (byte*)"", (const char*)sURL, nEndSel, &nStartSel, &nEndSel);
    	ICStop(pInst);
    
    #endif
    }
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer