fixed code to compile both as ansi and unicode version, build as unicode by default

svn path=/trunk/; revision=17564
This commit is contained in:
Thomas Bluemel 2005-08-26 21:02:47 +00:00
parent 342d03f235
commit d1e98bfddd
5 changed files with 504 additions and 470 deletions

View file

@ -1,7 +1,9 @@
<module name="calc" type="win32gui" installbase="system32" installname="calc.exe" warnings="true">
<module name="calc" type="win32gui" installbase="system32" installname="calc.exe">
<include base="calc">.</include>
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x0501</define>
<define name="UNICODE" />
<define name="_UNICODE" />
<library>kernel32</library>
<library>user32</library>
<library>gdi32</library>

View file

@ -19,6 +19,7 @@
*/
#include <windows.h>
#include <tchar.h>
#include "dialog.h"
#include "resource.h"
#include "winecalc.h"
@ -50,32 +51,32 @@ BOOL CALLBACK AboutDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
HFONT hFont;
HFONT hFontOrg;
char c1[CALC_BUF_SIZE];
char c2[CALC_BUF_SIZE];
char c3[CALC_BUF_SIZE];
char c4[CALC_BUF_SIZE];
char c5[CALC_BUF_SIZE];
TCHAR c1[CALC_BUF_SIZE];
TCHAR c2[CALC_BUF_SIZE];
TCHAR c3[CALC_BUF_SIZE];
TCHAR c4[CALC_BUF_SIZE];
TCHAR c5[CALC_BUF_SIZE];
hdc = BeginPaint( hDlg, &ps );
hMemDC = CreateCompatibleDC( hdc );
LoadString( hInstance, IDS_COPYRIGHT1, c1, sizeof(c1));
LoadString( hInstance, IDS_COPYRIGHT2, c2, sizeof(c2));
LoadString( hInstance, IDS_COPYRIGHT3, c3, sizeof(c3));
LoadString( hInstance, IDS_COPYRIGHT4, c4, sizeof(c4));
LoadString( hInstance, IDS_COPYRIGHT5, c5, sizeof(c5));
LoadString( hInstance, IDS_COPYRIGHT1, c1, sizeof(c1) / sizeof(c1[0]));
LoadString( hInstance, IDS_COPYRIGHT2, c2, sizeof(c2) / sizeof(c2[0]));
LoadString( hInstance, IDS_COPYRIGHT3, c3, sizeof(c3) / sizeof(c3[0]));
LoadString( hInstance, IDS_COPYRIGHT4, c4, sizeof(c4) / sizeof(c4[0]));
LoadString( hInstance, IDS_COPYRIGHT5, c5, sizeof(c5) / sizeof(c5[0]));
hFont = GetStockObject(DEFAULT_GUI_FONT);
hFontOrg = SelectObject(hdc, hFont);
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, 10, 10, c1, strlen(c1));
TextOut(hdc, 10, 35, c2, strlen(c2));
TextOut(hdc, 10, 50, c3, strlen(c3));
TextOut(hdc, 10, 75, c4, strlen(c4));
TextOut(hdc, 10, 90, c5, strlen(c5));
TextOut(hdc, 10, 10, c1, _tcslen(c1));
TextOut(hdc, 10, 35, c2, _tcslen(c2));
TextOut(hdc, 10, 50, c3, _tcslen(c3));
TextOut(hdc, 10, 75, c4, _tcslen(c4));
TextOut(hdc, 10, 90, c5, _tcslen(c5));
SelectObject(hdc, hFontOrg);

View file

@ -21,6 +21,7 @@
#include <stdio.h> // sprintf
#include <windows.h>
#include <tchar.h>
#include "stats.h"
#include "resource.h"
@ -41,8 +42,8 @@ BOOL CALLBACK StatsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
case WM_INITDIALOG:
hWndListBox = CreateWindow(
"LISTBOX", // pointer to registered class name
"Listbox", // pointer to window name
TEXT("LISTBOX"), // pointer to registered class name
TEXT("Listbox"), // pointer to window name
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | LBS_NOINTEGRALHEIGHT, // window style
6, // horizontal position of window
6, // vertical position of window
@ -100,7 +101,7 @@ BOOL CALLBACK StatsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
case WM_PAINT:
{
char s[CALC_BUF_SIZE];
TCHAR s[CALC_BUF_SIZE];
int lb_count;
HFONT hFont;
HFONT hFontOrg;
@ -110,10 +111,10 @@ BOOL CALLBACK StatsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
hFontOrg = SelectObject(hdc, hFont);
lb_count = SendMessage(hWndListBox, LB_GETCOUNT, 0, 0);
sprintf(s, "n=%d", lb_count);
_stprintf(s, TEXT("n=%d"), lb_count);
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, 98, 121, s, strlen(s));
TextOut(hdc, 98, 121, s, _tcslen(s));
SelectObject(hdc, hFontOrg);
EndPaint( hDlg, &ps );
@ -121,7 +122,7 @@ BOOL CALLBACK StatsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
}
case WM_CLOSE:
hWndDlgStats = 0; // invalidate stats dialog
SendMessage(GetParent(hDlg), WM_CHAR, '\x13', 1); // disable stats related calculator buttons
SendMessage(GetParent(hDlg), WM_CHAR, TEXT('\x13'), 1); // disable stats related calculator buttons
DestroyWindow( hDlg );
return 0;

File diff suppressed because it is too large Load diff

View file

@ -23,8 +23,8 @@
// numerics are defined here for easier porting
typedef double calcfloat;
#define FMT_DESC_FLOAT "%.32g"
#define FMT_DESC_EXP "%.32e"
#define FMT_DESC_FLOAT TEXT("%.32g")
#define FMT_DESC_EXP TEXT("%.32e")
#define CALC_ATOF(x) atof(x)
@ -283,7 +283,7 @@ typedef double calcfloat;
typedef struct tagCalcBtn {
int id; // private id
HWND hBtn; // button child window handle
char label[80]; // text on buttonface
TCHAR label[80]; // text on buttonface
int color; // text color
RECT r; // location
int enable; // 1 = control enbabled, 0 = disabled
@ -303,8 +303,8 @@ typedef struct tagCalc {
POS pos;
int numButtons; // standard = 28, scientific = more
char buffer [CALC_BUF_SIZE]; // current keyboard buffer
char display[CALC_BUF_SIZE]; // display buffer before output
TCHAR buffer [CALC_BUF_SIZE]; // current keyboard buffer
TCHAR display[CALC_BUF_SIZE]; // display buffer before output
calcfloat value; // most recent computer value
calcfloat memory; // most recent stored memory value from display buffer
@ -313,7 +313,7 @@ typedef struct tagCalc {
int sciMode; // standard = 1, scientific = 0
int displayMode; // 0 = float, 1 = scientific exponential notation like 1.0e+10
char oper; // most recent operator pushed
TCHAR oper; // most recent operator pushed
calcfloat operand; // most recent operand pushed
int newenter; // track multiple =
int next; // binary operation flag
@ -344,19 +344,19 @@ void DestroyCalc (CALC *calc);
void calc_buffer_format(CALC *calc);
void calc_buffer_display(CALC *calc);
char *calc_sep(char *s);
TCHAR *calc_sep(TCHAR *s);
void DrawCalcText (HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, CALC *calc, int object, char *s);
void DrawCalcText (HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, CALC *calc, int object, TCHAR *s);
void CalcRect (HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, CALC *calc, int object);
void DrawCalcRectSci(HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, CALC *calc, RECT *r);
void DrawCalc (HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, CALC *calc);
void calc_setmenuitem_radio(HMENU hMenu, UINT id);
void show_debug(CALC *calc, char *title, long wParam, long lParam);
void show_debug(CALC *calc, TCHAR *title, long wParam, long lParam);
calcfloat calc_atof(char *s, int base);
void calc_ftoa(CALC *calc, calcfloat r, char *buf);
calcfloat calc_atof(TCHAR *s, int base);
void calc_ftoa(CALC *calc, calcfloat r, TCHAR *buf);
long factorial(long n);
calcfloat calc_convert_to_radians(CALC *calc);