diff options
Diffstat (limited to 'win32/PlatWin.cxx')
| -rw-r--r-- | win32/PlatWin.cxx | 266 | 
1 files changed, 125 insertions, 141 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index b9164c757..6a6c38029 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -11,6 +11,12 @@  #include <stdarg.h>  #include <stdio.h> +#define _WIN32_WINNT  0x0400 +#include <windows.h> +#undef DrawText +#include <commctrl.h> +#include <richedit.h> +  #include "Platform.h"  #include "PlatformRes.h"  #include "UniConversion.h" @@ -24,34 +30,6 @@ static RECT RectFromPRectangle(PRectangle prc) {  	return rc;  } -Colour::Colour(long lcol) { -	co = lcol; -} - -Colour::Colour(unsigned int red, unsigned int green, unsigned int blue) { -	co = RGB(red, green, blue); -} - -bool Colour::operator==(const Colour &other) const { -	return co == other.co; -} - -long Colour::AsLong() const { -	return co; -} - -unsigned int Colour::GetRed() { -	return co & 0xff; -} - -unsigned int Colour::GetGreen() { -	return (co >> 8) & 0xff; -} - -unsigned int Colour::GetBlue() { -	return (co >> 16) & 0xff; -} -  Palette::Palette() {  	used = 0;  	allowRealization = false; @@ -83,7 +61,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {  		if (used < numEntries) {  			entries[used].desired = cp.desired; -			entries[used].allocated = cp.desired; +			entries[used].allocated.Set(cp.desired.AsLong());  			used++;  		}  	} else { @@ -93,7 +71,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {  				return;  			}  		} -		cp.allocated = cp.desired; +		cp.allocated.Set(cp.desired.AsLong());  	}  } @@ -108,12 +86,12 @@ void Palette::Allocate(Window &) {  		logpal->palVersion = 0x300;  		logpal->palNumEntries = static_cast<WORD>(used);  		for (int iPal=0;iPal<used;iPal++) { -			Colour desired = entries[iPal].desired; +			ColourDesired desired = entries[iPal].desired;  			logpal->palPalEntry[iPal].peRed   = static_cast<BYTE>(desired.GetRed());  			logpal->palPalEntry[iPal].peGreen = static_cast<BYTE>(desired.GetGreen());  			logpal->palPalEntry[iPal].peBlue  = static_cast<BYTE>(desired.GetBlue()); -			entries[iPal].allocated = -				PALETTERGB(desired.GetRed(), desired.GetGreen(), desired.GetBlue()); +			entries[iPal].allocated.Set( +				PALETTERGB(desired.GetRed(), desired.GetGreen(), desired.GetBlue()));  			// PC_NOCOLLAPSE means exact colours allocated even when in background this means other windows  			// are less likely to get their colours and also flashes more when switching windows  			logpal->palPalEntry[iPal].peFlags = PC_NOCOLLAPSE; @@ -273,36 +251,37 @@ Surface::~Surface() {  void Surface::Release() {  	if (penOld) { -		::SelectObject(hdc, penOld); +		::SelectObject(reinterpret_cast<HDC>(hdc), penOld);  		::DeleteObject(pen);  		penOld = 0;  	}  	pen = 0;  	if (brushOld) { -		::SelectObject(hdc, brushOld); +		::SelectObject(reinterpret_cast<HDC>(hdc), brushOld);  		::DeleteObject(brush);  		brushOld = 0;  	}  	brush = 0;  	if (fontOld) {  		// Fonts are not deleted as they are owned by a Font object -		::SelectObject(hdc, fontOld); +		::SelectObject(reinterpret_cast<HDC>(hdc), fontOld);  		fontOld = 0;  	}  	font =0;  	if (bitmapOld) { -		::SelectObject(hdc, bitmapOld); +		::SelectObject(reinterpret_cast<HDC>(hdc), bitmapOld);  		::DeleteObject(bitmap);  		bitmapOld = 0;  	}  	bitmap = 0;  	if (paletteOld) {  		// Fonts are not deleted as they are owned by a Palette object -		::SelectPalette(hdc, paletteOld, TRUE); +		::SelectPalette(reinterpret_cast<HDC>(hdc),  +			reinterpret_cast<HPALETTE>(paletteOld), TRUE);  		paletteOld = 0;  	}  	if (hdcOwned) { -		::DeleteDC(hdc); +		::DeleteDC(reinterpret_cast<HDC>(hdc));  		hdc = 0;  		hdcOwned = false;  	} @@ -316,61 +295,61 @@ void Surface::Init() {  	Release();  	hdc = ::CreateCompatibleDC(NULL);  	hdcOwned = true; -	::SetTextAlign(hdc, TA_BASELINE); +	::SetTextAlign(reinterpret_cast<HDC>(hdc), TA_BASELINE);  }  void Surface::Init(SurfaceID sid) {  	Release();  	hdc = sid; -	::SetTextAlign(hdc, TA_BASELINE); +	::SetTextAlign(reinterpret_cast<HDC>(hdc), TA_BASELINE);  }  void Surface::InitPixMap(int width, int height, Surface *surface_) {  	Release(); -	hdc = ::CreateCompatibleDC(surface_->hdc); +	hdc = ::CreateCompatibleDC(reinterpret_cast<HDC>(surface_->hdc));  	hdcOwned = true; -	bitmap = ::CreateCompatibleBitmap(surface_->hdc, width, height); -	bitmapOld = static_cast<HBITMAP>(::SelectObject(hdc, bitmap)); -	::SetTextAlign(hdc, TA_BASELINE); +	bitmap = ::CreateCompatibleBitmap(reinterpret_cast<HDC>(surface_->hdc), width, height); +	bitmapOld = static_cast<HBITMAP>(::SelectObject(reinterpret_cast<HDC>(hdc), bitmap)); +	::SetTextAlign(reinterpret_cast<HDC>(hdc), TA_BASELINE);  } -void Surface::PenColour(Colour fore) { +void Surface::PenColour(ColourAllocated fore) {  	if (pen) { -		::SelectObject(hdc, penOld); +		::SelectObject(reinterpret_cast<HDC>(hdc), penOld);  		::DeleteObject(pen);  		pen = 0;  		penOld = 0;  	}  	pen = ::CreatePen(0,1,fore.AsLong()); -	penOld = static_cast<HPEN>(::SelectObject(hdc, pen)); +	penOld = static_cast<HPEN>(::SelectObject(reinterpret_cast<HDC>(hdc), pen));  } -void Surface::BrushColor(Colour back) { +void Surface::BrushColor(ColourAllocated back) {  	if (brush) { -		::SelectObject(hdc, brushOld); +		::SelectObject(reinterpret_cast<HDC>(hdc), brushOld);  		::DeleteObject(brush);  		brush = 0;  		brushOld = 0;  	}  	// Only ever want pure, non-dithered brushes -	Colour colourNearest = ::GetNearestColor(hdc, back.AsLong()); +	ColourAllocated colourNearest = ::GetNearestColor(reinterpret_cast<HDC>(hdc), back.AsLong());  	brush = ::CreateSolidBrush(colourNearest.AsLong()); -	brushOld = static_cast<HBRUSH>(::SelectObject(hdc, brush)); +	brushOld = static_cast<HBRUSH>(::SelectObject(reinterpret_cast<HDC>(hdc), brush));  }  void Surface::SetFont(Font &font_) {  	if (font_.GetID() != font) {  		if (fontOld) { -			::SelectObject(hdc, font_.GetID()); +			::SelectObject(reinterpret_cast<HDC>(hdc), font_.GetID());  		} else { -			fontOld = static_cast<HFONT>(::SelectObject(hdc, font_.GetID())); +			fontOld = static_cast<HFONT>(::SelectObject(reinterpret_cast<HDC>(hdc), font_.GetID()));  		}  		font = font_.GetID();  	}  }  int Surface::LogPixelsY() { -	return ::GetDeviceCaps(hdc, LOGPIXELSY); +	return ::GetDeviceCaps(reinterpret_cast<HDC>(hdc), LOGPIXELSY);  }  int Surface::DeviceHeightFont(int points) { @@ -378,93 +357,96 @@ int Surface::DeviceHeightFont(int points) {  }  void Surface::MoveTo(int x_, int y_) { -	::MoveToEx(hdc, x_, y_, 0); +	::MoveToEx(reinterpret_cast<HDC>(hdc), x_, y_, 0);  }  void Surface::LineTo(int x_, int y_) { -	::LineTo(hdc, x_, y_); +	::LineTo(reinterpret_cast<HDC>(hdc), x_, y_);  } -void Surface::Polygon(Point *pts, int npts, Colour fore, Colour back) { +void Surface::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) {  	PenColour(fore);  	BrushColor(back); -	::Polygon(hdc, reinterpret_cast<POINT *>(pts), npts); +	::Polygon(reinterpret_cast<HDC>(hdc), reinterpret_cast<POINT *>(pts), npts);  } -void Surface::RectangleDraw(PRectangle rc, Colour fore, Colour back) { +void Surface::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) {  	PenColour(fore);  	BrushColor(back); -	::Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom); +	::Rectangle(reinterpret_cast<HDC>(hdc), rc.left, rc.top, rc.right, rc.bottom);  } -void Surface::FillRectangle(PRectangle rc, Colour back) { +void Surface::FillRectangle(PRectangle rc, ColourAllocated back) {  	// Using ExtTextOut rather than a FillRect ensures that no dithering occurs.  	// There is no need to allocate a brush either.  	RECT rcw = RectFromPRectangle(rc); -	::SetBkColor(hdc, back.AsLong()); -	::ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE, &rcw, "", 0, NULL); +	::SetBkColor(reinterpret_cast<HDC>(hdc), back.AsLong()); +	::ExtTextOut(reinterpret_cast<HDC>(hdc), rc.left, rc.top, ETO_OPAQUE, &rcw, "", 0, NULL);  }  void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {  	HBRUSH br;  	if (surfacePattern.bitmap) -		br = ::CreatePatternBrush(surfacePattern.bitmap); +		br = ::CreatePatternBrush(reinterpret_cast<HBITMAP>(surfacePattern.bitmap));  	else	// Something is wrong so display in red  		br = ::CreateSolidBrush(RGB(0xff, 0, 0));  	RECT rcw = RectFromPRectangle(rc); -	::FillRect(hdc, &rcw, br); +	::FillRect(reinterpret_cast<HDC>(hdc), &rcw, br);  	::DeleteObject(br);  } -void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) { +void Surface::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {  	PenColour(fore);  	BrushColor(back); -	::RoundRect(hdc, +	::RoundRect(reinterpret_cast<HDC>(hdc),  		rc.left + 1, rc.top,  		rc.right - 1, rc.bottom,  		8, 8 );  } -void Surface::Ellipse(PRectangle rc, Colour fore, Colour back) { +void Surface::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {  	PenColour(fore);  	BrushColor(back); -	::Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom); +	::Ellipse(reinterpret_cast<HDC>(hdc), rc.left, rc.top, rc.right, rc.bottom);  }  void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) { -	::BitBlt(hdc, rc.left, rc.top, rc.Width(), rc.Height(), -		surfaceSource.hdc, from.x, from.y, SRCCOPY); +	::BitBlt(reinterpret_cast<HDC>(hdc),  +		rc.left, rc.top, rc.Width(), rc.Height(), +		reinterpret_cast<HDC>(surfaceSource.hdc), from.x, from.y, SRCCOPY);  }  #define MAX_US_LEN 5000 -void Surface::DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back) { +void Surface::DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len,  +	ColourAllocated fore, ColourAllocated back) {  	SetFont(font_); -	::SetTextColor(hdc, fore.AsLong()); -	::SetBkColor(hdc, back.AsLong()); +	::SetTextColor(reinterpret_cast<HDC>(hdc), fore.AsLong()); +	::SetBkColor(reinterpret_cast<HDC>(hdc), back.AsLong());  	RECT rcw = RectFromPRectangle(rc);  	if (unicodeMode) {  		wchar_t tbuf[MAX_US_LEN];  		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t));  		tbuf[tlen] = L'\0'; -		::ExtTextOutW(hdc, rc.left, ybase, ETO_OPAQUE, &rcw, tbuf, tlen, NULL); +		::ExtTextOutW(reinterpret_cast<HDC>(hdc), rc.left, ybase, ETO_OPAQUE, &rcw, tbuf, tlen, NULL);  	} else { -		::ExtTextOut(hdc, rc.left, ybase, ETO_OPAQUE, &rcw, s, len, NULL); +		::ExtTextOut(reinterpret_cast<HDC>(hdc), rc.left, ybase, ETO_OPAQUE, &rcw, s, len, NULL);  	}  } -void Surface::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back) { +void Surface::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len,  +	ColourAllocated fore, ColourAllocated back) {  	SetFont(font_); -	::SetTextColor(hdc, fore.AsLong()); -	::SetBkColor(hdc, back.AsLong()); +	::SetTextColor(reinterpret_cast<HDC>(hdc), fore.AsLong()); +	::SetBkColor(reinterpret_cast<HDC>(hdc), back.AsLong());  	RECT rcw = RectFromPRectangle(rc);  	if (unicodeMode) {  		wchar_t tbuf[MAX_US_LEN];  		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t));  		tbuf[tlen] = L'\0'; -		::ExtTextOutW(hdc, rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, tbuf, tlen, NULL); +		::ExtTextOutW(reinterpret_cast<HDC>(hdc), rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, tbuf, tlen, NULL);  	} else { -		::ExtTextOut(hdc, rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, s, len, NULL); +		::ExtTextOut(reinterpret_cast<HDC>(hdc), rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, s, len, NULL);  	}  } @@ -475,9 +457,9 @@ int Surface::WidthText(Font &font_, const char *s, int len) {  		wchar_t tbuf[MAX_US_LEN];  		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t));  		tbuf[tlen] = L'\0'; -		::GetTextExtentPoint32W(hdc, tbuf, tlen, &sz); +		::GetTextExtentPoint32W(reinterpret_cast<HDC>(hdc), tbuf, tlen, &sz);  	} else { -		::GetTextExtentPoint32(hdc, s, len, &sz); +		::GetTextExtentPoint32(reinterpret_cast<HDC>(hdc), s, len, &sz);  	}  	return sz.cx;  } @@ -492,12 +474,12 @@ void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions)  		tbuf[tlen] = L'\0';  		int poses[MAX_US_LEN];  		fit = tlen; -		if (!::GetTextExtentExPointW(hdc, tbuf, tlen, 30000, &fit, poses, &sz)) { +		if (!::GetTextExtentExPointW(reinterpret_cast<HDC>(hdc), tbuf, tlen, 30000, &fit, poses, &sz)) {  			// Likely to have failed because on Windows 9x where function not available  			// So measure the character widths by measuring each initial substring  			// Turns a linear operation into a qudratic but seems fast enough on test files  			for (int widthSS=0; widthSS < tlen; widthSS++) { -				::GetTextExtentPoint32W(hdc, tbuf, widthSS+1, &sz); +				::GetTextExtentPoint32W(reinterpret_cast<HDC>(hdc), tbuf, widthSS+1, &sz);  				poses[widthSS] = sz.cx;  			}  		} @@ -520,7 +502,7 @@ void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions)  		}  		positions[i] = sz.cx;  	} else { -		if (!::GetTextExtentExPoint(hdc, s, len, 30000, &fit, positions, &sz)) { +		if (!::GetTextExtentExPoint(reinterpret_cast<HDC>(hdc), s, len, 30000, &fit, positions, &sz)) {  			// Eeek - a NULL DC or other foolishness could cause this.  			// The least we can do is set the positions to zero!  			memset(positions, 0, len * sizeof(*positions)); @@ -536,67 +518,70 @@ void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions)  int Surface::WidthChar(Font &font_, char ch) {  	SetFont(font_);  	SIZE sz; -	::GetTextExtentPoint32(hdc, &ch, 1, &sz); +	::GetTextExtentPoint32(reinterpret_cast<HDC>(hdc), &ch, 1, &sz);  	return sz.cx;  }  int Surface::Ascent(Font &font_) {  	SetFont(font_);  	TEXTMETRIC tm; -	::GetTextMetrics(hdc, &tm); +	::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);  	return tm.tmAscent;  }  int Surface::Descent(Font &font_) {  	SetFont(font_);  	TEXTMETRIC tm; -	::GetTextMetrics(hdc, &tm); +	::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);  	return tm.tmDescent;  }  int Surface::InternalLeading(Font &font_) {  	SetFont(font_);  	TEXTMETRIC tm; -	::GetTextMetrics(hdc, &tm); +	::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);  	return tm.tmInternalLeading;  }  int Surface::ExternalLeading(Font &font_) {  	SetFont(font_);  	TEXTMETRIC tm; -	::GetTextMetrics(hdc, &tm); +	::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);  	return tm.tmExternalLeading;  }  int Surface::Height(Font &font_) {  	SetFont(font_);  	TEXTMETRIC tm; -	::GetTextMetrics(hdc, &tm); +	::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);  	return tm.tmHeight;  }  int Surface::AverageCharWidth(Font &font_) {  	SetFont(font_);  	TEXTMETRIC tm; -	::GetTextMetrics(hdc, &tm); +	::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);  	return tm.tmAveCharWidth;  }  int Surface::SetPalette(Palette *pal, bool inBackGround) {  	if (paletteOld) { -		::SelectPalette(hdc,paletteOld,TRUE); +		::SelectPalette(reinterpret_cast<HDC>(hdc), +			reinterpret_cast<HPALETTE>(paletteOld),TRUE);  	}  	paletteOld = 0;  	int changes = 0;  	if (pal->allowRealization) { -		paletteOld = ::SelectPalette(hdc, pal->hpal, inBackGround); -		changes = ::RealizePalette(hdc); +		paletteOld = ::SelectPalette( +			reinterpret_cast<HDC>(hdc),  +			reinterpret_cast<HPALETTE>(pal->hpal), inBackGround); +		changes = ::RealizePalette(reinterpret_cast<HDC>(hdc));  	}  	return changes;  }  void Surface::SetClip(PRectangle rc) { -	::IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom); +	::IntersectClipRect(reinterpret_cast<HDC>(hdc), rc.left, rc.top, rc.right, rc.bottom);  }  void Surface::FlushCachedState() { @@ -610,7 +595,7 @@ Window::~Window() {  void Window::Destroy() {  	if (id) -		::DestroyWindow(id); +		::DestroyWindow(reinterpret_cast<HWND>(id));  	id = 0;  } @@ -620,12 +605,13 @@ bool Window::HasFocus() {  PRectangle Window::GetPosition() {  	RECT rc; -	::GetWindowRect(id, &rc); +	::GetWindowRect(reinterpret_cast<HWND>(id), &rc);  	return PRectangle(rc.left, rc.top, rc.right, rc.bottom);  }  void Window::SetPosition(PRectangle rc) { -	::SetWindowPos(id, 0, rc.left, rc.top, rc.Width(), rc.Height(), 0); +	::SetWindowPos(reinterpret_cast<HWND>(id),  +		0, rc.left, rc.top, rc.Width(), rc.Height(), 0);  }  void Window::SetPositionRelative(PRectangle rc, Window) { @@ -634,28 +620,32 @@ void Window::SetPositionRelative(PRectangle rc, Window) {  PRectangle Window::GetClientPosition() {  	RECT rc; -	::GetClientRect(id, &rc); +	::GetClientRect(reinterpret_cast<HWND>(id), &rc);  	return  PRectangle(rc.left, rc.top, rc.right, rc.bottom);  }  void Window::Show(bool show) {  	if (show) -		::ShowWindow(id, SW_SHOWNORMAL); +		::ShowWindow(reinterpret_cast<HWND>(id), SW_SHOWNORMAL);  	else -		::ShowWindow(id, SW_HIDE); +		::ShowWindow(reinterpret_cast<HWND>(id), SW_HIDE);  }  void Window::InvalidateAll() { -	::InvalidateRect(id, NULL, FALSE); +	::InvalidateRect(reinterpret_cast<HWND>(id), NULL, FALSE);  }  void Window::InvalidateRectangle(PRectangle rc) {  	RECT rcw = RectFromPRectangle(rc); -	::InvalidateRect(id, &rcw, FALSE); +	::InvalidateRect(reinterpret_cast<HWND>(id), &rcw, FALSE); +} + +static LRESULT Window_SendMessage(Window *w, UINT msg, WPARAM wParam=0, LPARAM lParam=0) { +	return ::SendMessage(reinterpret_cast<HWND>(w->GetID()), msg, wParam, lParam);  }  void Window::SetFont(Font &font) { -	SendMessage(WM_SETFONT, +	Window_SendMessage(this, WM_SETFONT,  		reinterpret_cast<WPARAM>(font.GetID()), 0);  } @@ -695,23 +685,7 @@ void Window::SetCursor(Cursor curs) {  }  void Window::SetTitle(const char *s) { -	::SetWindowText(id, s); -} - -LRESULT Window::SendMessage(UINT msg, WPARAM wParam, LPARAM lParam) { -	if (id) -		return ::SendMessage(id, msg, wParam, lParam); -	else -		return 0; -} - -int Window::GetDlgCtrlID() { -	return ::GetDlgCtrlID(id); -} - -HINSTANCE Window::GetInstance() { -	return reinterpret_cast<HINSTANCE>( -		::GetWindowLong(id,GWL_HINSTANCE)); +	::SetWindowText(reinterpret_cast<HWND>(id), s);  }  ListBox::ListBox() : desiredVisibleRows(5), maxItemCharacters(0), aveCharWidth(8) { @@ -721,11 +695,15 @@ ListBox::~ListBox() {  }  void ListBox::Create(Window &parent, int ctrlID) { +	HINSTANCE hinstanceParent = reinterpret_cast<HINSTANCE>( +		::GetWindowLong(reinterpret_cast<HWND>(parent.GetID()),GWL_HINSTANCE));  	id = ::CreateWindowEx(  		WS_EX_WINDOWEDGE, "listbox", "",  		WS_CHILD | WS_THICKFRAME | WS_VSCROLL | LBS_NOTIFY, -		100,100, 150,80, parent.GetID(), reinterpret_cast<HMENU>(ctrlID), -		parent.GetInstance(), 0); +		100,100, 150,80, reinterpret_cast<HWND>(parent.GetID()),  +		reinterpret_cast<HMENU>(ctrlID), +		hinstanceParent,  +		0);  }  void ListBox::SetFont(Font &font) { @@ -742,7 +720,7 @@ void ListBox::SetVisibleRows(int rows) {  PRectangle ListBox::GetDesiredRect() {  	PRectangle rcDesired = GetPosition(); -	int itemHeight = SendMessage(LB_GETITEMHEIGHT, 0); +	int itemHeight = Window_SendMessage(this, LB_GETITEMHEIGHT, 0);  	int rows = Length();  	if ((rows == 0) || (rows > desiredVisibleRows))  		rows = desiredVisibleRows; @@ -758,40 +736,40 @@ PRectangle ListBox::GetDesiredRect() {  }  void ListBox::Clear() { -	SendMessage(LB_RESETCONTENT); +	Window_SendMessage(this, LB_RESETCONTENT);  	maxItemCharacters = 0;  }  void ListBox::Append(char *s) { -	SendMessage(LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(s)); +	Window_SendMessage(this, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(s));  	size_t len = strlen(s);  	if (maxItemCharacters < len)  		maxItemCharacters = len;  }  int ListBox::Length() { -	return SendMessage(LB_GETCOUNT); +	return Window_SendMessage(this, LB_GETCOUNT);  }  void ListBox::Select(int n) { -	SendMessage(LB_SETCURSEL, n); +	Window_SendMessage(this, LB_SETCURSEL, n);  }  int ListBox::GetSelection() { -	return SendMessage(LB_GETCURSEL); +	return Window_SendMessage(this, LB_GETCURSEL);  }  int ListBox::Find(const char *prefix) { -	return SendMessage(LB_FINDSTRING, static_cast<WPARAM>(-1), -	reinterpret_cast<LPARAM>(prefix)); +	return Window_SendMessage(this, LB_FINDSTRING, static_cast<WPARAM>(-1), +		reinterpret_cast<LPARAM>(prefix));  }  void ListBox::GetValue(int n, char *value, int len) { -	int lenText = SendMessage(LB_GETTEXTLEN, n); +	int lenText = Window_SendMessage(this, LB_GETTEXTLEN, n);  	if ((len > 0) && (lenText > 0)){  		char *text = new char[len+1];  		if (text) { -			SendMessage(LB_GETTEXT, n, reinterpret_cast<LPARAM>(text)); +			Window_SendMessage(this, LB_GETTEXT, n, reinterpret_cast<LPARAM>(text));  			strncpy(value, text, len);  			value[len-1] = '\0';  			delete []text; @@ -817,20 +795,22 @@ void Menu::CreatePopUp() {  void Menu::Destroy() {  	if (id) -		::DestroyMenu(id); +		::DestroyMenu(reinterpret_cast<HMENU>(id));  	id = 0;  }  void Menu::Show(Point pt, Window &w) { -	::TrackPopupMenu(id, 0, pt.x - 4, pt.y, 0, w.GetID(), NULL); +	::TrackPopupMenu(reinterpret_cast<HMENU>(id),  +		0, pt.x - 4, pt.y, 0,  +		reinterpret_cast<HWND>(w.GetID()), NULL);  	Destroy();  } -Colour Platform::Chrome() { +ColourDesired Platform::Chrome() {  	return ::GetSysColor(COLOR_3DFACE);  } -Colour Platform::ChromeHighlight() { +ColourDesired Platform::ChromeHighlight() {  	return ::GetSysColor(COLOR_3DHIGHLIGHT);  } @@ -855,7 +835,11 @@ bool Platform::IsKeyDown(int key) {  }  long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) { -	return ::SendMessage(w, msg, wParam, lParam); +	return ::SendMessage(reinterpret_cast<HWND>(w), msg, wParam, lParam); +} + +bool Platform::IsDBCSLeadByte(int codePage, char ch) { +	return ::IsDBCSLeadByteEx(codePage, ch);  }  // These are utility functions not really tied to a platform  | 
