Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have done something like this, so I can offer a few bits of advice.</p> <ul> <li><p>While it would be okay to call your Window classes MSWindow, OSXWindow, etc., this is really not handy, since every part of the code that ever needs to interact with the Window will need to know which one to use. You should call these classes just Window. Since you will only be compiling one of these in a given platform there is no collision.</p></li> <li><p>The macros to check for a given OS:</p> <ul> <li><code>_WIN32</code> for Windows</li> <li><code>__APPLE__</code> for OSX and iOS (I set my own constant to tell these two apart in the pch file )</li> <li><code>__linux__</code> for Linux</li> </ul></li> <li><p>I recommend that you do not add <code>#define</code> with the above all over the place. You'll have more portable code if you put the cross-platform specific code in as few places as possible.</p></li> <li><p>You will have different main functions on each platform. <code>WinMain()</code> on Windows, <code>main()</code> on others. I recommend that you put these on different files, and you only reference the file that corresponds to correct platform in your makefile or project file.</p></li> <li><p>The HINSTANCE problem that you asked is easily solved. In your WinMain() function you will give the HINSTACE to your Window class. The Window class on Windows will have a static method, let's say <code>setHinstance()</code>, that will store the HINSTACE away in a class variable. Then when a Window instance is created, the HINSTACE will be available without having to change the common methods of this class.</p></li> <li><p>As a final comment, you should keep in mind that there are several GUI frameworks that are cross-platform that may work for you. If you want a full featured one, then look at <a href="http://qt.nokia.com/products/" rel="nofollow">Qt</a>. If you want one that is very simple to use (with some nice features, but not as many as Qt) then have a look at <a href="http://www.fltk.org/" rel="nofollow">FLTK</a>. Both Qt and FLTK are open source.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload