Link to home
Start Free TrialLog in
Avatar of Joeriw
Joeriw

asked on

How do i make 1 application for both win98 and winxp; with win98 using CButton for my buttons and winxp using CXPStyleButtonS

Hello,

i got the following problem :

i created a CFormView based app, with most of my buttons declared as CXPStyleButtonST buttons.
Problem is, these buttons look very dumb in windows 98. I prefer not to make 2 different versions, but instead let the program determine the OS (i got a function for that) and then either use CButton or CXPStyleButtonST. Sounds simple, but it surely isn't. I thought to use this:

#ifdef _WINXP
     CXPStyleButtonST Button1;
     CXPStyleButtonST Button2;
#else
        CButton Button1;
     CButton Button2;
#endif

but the problem is where can i call my function (and let its outcome do either #define _WINXP or #define _WIN98) before it checks this... ??
Anyone got the answer?
I for now only got 50 points for the answer but i will consider a bonus when i got more points.
Avatar of Linzer
Linzer

Your #ifdef things will be used at compile time only, and I can't see how you could call a function at that time. BUT what you sure can do is ask the compiler (whichever you use) to define constants depending on the OS (actually, it probably does it by default). Check your compiler's manual for this!
Avatar of Joeriw

ASKER

i use visual c++ 6.0
umm where is the compilers manual here? all i use is msdn.
By the way, im just busy with building this solution, and it compiles.. will let you know in a bit
Avatar of Joeriw

ASKER

damn, i know understand every word you said :)

#include "simexhelper.h"

#define _OS_WIN2003 6
#define _OS_WINXP 5
#define _OS_WIN2000 4
#define _OS_WINNT 3
#define _OS_WIN98 2
#define _OS_WIN95 1
#define _OS_WIN31 0
#define _OS_WINUNK -1

#ifndef _OSVERSION
static int _OSVERSION = CSimexhelper::GetWindowsVersion();
#endif

#if _OSVERSION >= _OS_WINXP
#define _WINXPMODE //this is the win xp version
#else
#define _WIN98MODE    
#endif

this indeed can't work
as it will probably compile it to:

#include "simexhelper.h"
static int _OSVERSION = CSimexhelper::GetWindowsVersion();

 with _WIN98MODE defined. :(

Does someone know the compiler options then? Can't see them anywhere.


Avatar of Joeriw

ASKER

found a way to get the desired result.

i used my helper function in the initialization of my document class,
so its BOOL xpmode would reflect the OS thats running.

then for every view i created CXPStyleButtonST 's and used:

void CIntroView::OnInitialUpdate()
{  
     CMasterDoc* pDoc = (CMasterDoc*) GetDocument();
//sets icons (works in both w98 and winxp)
     m_Quit.SetIcon(IDI_QUIT_S);
     m_About.SetIcon(IDI_ABOUT_S);
     m_Help.SetIcon(IDI_HELP_S);
     if (pDoc->xpmode)
     {
          m_About.SetThemeHelper(&pDoc->m_ThemeHelper);
          m_Quit.SetThemeHelper(&pDoc->m_ThemeHelper);
          m_Help.SetThemeHelper(&pDoc->m_ThemeHelper);
     }
     else
     { //create regular look in win98
          m_About.SetFlat(FALSE,TRUE);
          m_Quit.SetFlat(FALSE,TRUE);
          m_Help.SetFlat(FALSE,TRUE);
     }
}
works for me. if anyone knows how to check os on compile time please tell, otherwise the points will go to linzer
ASKER CERTIFIED SOLUTION
Avatar of Salte
Salte

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Joeriw

ASKER

Waw! explains all i would ever need for this case.
Thanks a lot for this!

If you can add a decent comment to this question
 https://www.experts-exchange.com/questions/20552717/How-do-i-print-a-bitmap-to-my-printer-from-my-Formview.html

i can donate you a nice & well deserved 200 pts for your help (sorry i'm out of pts so can't give more)