aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32
diff options
context:
space:
mode:
Diffstat (limited to 'win32')
-rw-r--r--win32/ExternalLexer.cxx5
-rw-r--r--win32/PlatWin.cxx266
-rw-r--r--win32/ScintillaWin.cxx146
3 files changed, 209 insertions, 208 deletions
diff --git a/win32/ExternalLexer.cxx b/win32/ExternalLexer.cxx
index 77c235940..015f9b6af 100644
--- a/win32/ExternalLexer.cxx
+++ b/win32/ExternalLexer.cxx
@@ -9,8 +9,11 @@
#include <stdio.h>
#include <ctype.h>
-#include "SciLexer.h"
+#define _WIN32_WINNT 0x0400
+#include <windows.h>
+
#include "Platform.h"
+#include "SciLexer.h"
#include "PropSet.h"
#include "Accessor.h"
#include "DocumentAccessor.h"
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
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 90cb275a5..d2b399be5 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -11,6 +11,11 @@
#include <ctype.h>
#include <assert.h>
+#define _WIN32_WINNT 0x0400
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+
#include "Platform.h"
#include "Scintilla.h"
@@ -159,6 +164,7 @@ class ScintillaWin :
virtual void Initialise();
virtual void Finalise();
+ HWND MainHWND();
static sptr_t DirectFunction(
ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam);
@@ -280,10 +286,14 @@ void ScintillaWin::Initialise() {
void ScintillaWin::Finalise() {
ScintillaBase::Finalise();
SetTicking(false);
- RevokeDragDrop(wMain.GetID());
+ RevokeDragDrop(MainHWND());
OleUninitialize();
}
+HWND ScintillaWin::MainHWND() {
+ return reinterpret_cast<HWND>(wMain.GetID());
+}
+
void ScintillaWin::StartDrag() {
DWORD dwEffect = 0;
dropWentOutside = true;
@@ -370,7 +380,7 @@ LRESULT ScintillaWin::WndPaint(unsigned long wParam) {
pps = reinterpret_cast<PAINTSTRUCT*>(wParam);
} else {
pps = &ps;
- BeginPaint(wMain.GetID(), pps);
+ ::BeginPaint(MainHWND(), pps);
}
Surface surfaceWindow;
surfaceWindow.Init(pps->hdc);
@@ -386,7 +396,7 @@ LRESULT ScintillaWin::WndPaint(unsigned long wParam) {
Paint(&surfaceWindow, rcPaint);
surfaceWindow.Release();
if(!IsOcxCtrl)
- EndPaint(wMain.GetID(), pps);
+ ::EndPaint(MainHWND(), pps);
if (paintState == paintAbandoned) {
// Painting area was insufficient to cover new styling or brace highlight positions
FullPaint();
@@ -418,7 +428,7 @@ sptr_t ScintillaWin::HandleComposition(uptr_t wParam, sptr_t lParam) {
return 0;
#else
if ((lParam & GCS_RESULTSTR) && (IsNT())) {
- HIMC hIMC = ::ImmGetContext(wMain.GetID());
+ HIMC hIMC = ::ImmGetContext(MainHWND());
if (hIMC) {
const int maxLenInputIME = 200;
wchar_t wcs[maxLenInputIME];
@@ -439,11 +449,11 @@ sptr_t ScintillaWin::HandleComposition(uptr_t wParam, sptr_t lParam) {
AddChar(dbcsval[i]);
}
}
- ::ImmReleaseContext(wMain.GetID(), hIMC);
+ ::ImmReleaseContext(MainHWND(), hIMC);
}
return 0;
} else {
- return ::DefWindowProc(wMain.GetID(), WM_IME_COMPOSITION, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), WM_IME_COMPOSITION, wParam, lParam);
}
#endif
}
@@ -483,10 +493,10 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
switch (iMessage) {
case WM_CREATE:
- ctrlID = wMain.GetDlgCtrlID();
+ ctrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(wMain.GetID()));
// Get Intellimouse scroll line parameters
GetIntelliMouseParameters();
- RegisterDragDrop(wMain.GetID(), reinterpret_cast<IDropTarget *>(&dt));
+ ::RegisterDragDrop(MainHWND(), reinterpret_cast<IDropTarget *>(&dt));
break;
case WM_COMMAND:
@@ -497,7 +507,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
AutoCompleteCompleted();
} else {
if (cmd != LBN_SETFOCUS)
- SetFocus(wMain.GetID());
+ ::SetFocus(MainHWND());
}
}
Command(LoWord(wParam));
@@ -529,7 +539,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// i.e. if datazoomed out only class structures are visible, when datazooming in the control
// structures appear, then eventually the individual statements...)
if (wParam & MK_SHIFT) {
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
}
// Either SCROLL or ZOOM. We handle the wheel steppings calculation
@@ -562,7 +572,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
break;
case WM_GETMINMAXINFO:
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_LBUTTONDOWN:
//Platform::DebugPrintf("Buttdown %d %x %x %x %x %x\n",iMessage, wParam, lParam,
@@ -571,7 +581,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// Platform::IsKeyDown(VK_MENU));
ButtonDown(Point::FromLong(lParam), GetTickCount(),
wParam & MK_SHIFT, wParam & MK_CONTROL, Platform::IsKeyDown(VK_MENU));
- SetFocus(wMain.GetID());
+ SetFocus(MainHWND());
break;
case WM_MOUSEMOVE:
@@ -590,7 +600,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// Display regular (drag) cursor over selection
POINT pt;
::GetCursorPos(&pt);
- ::ScreenToClient(wMain.GetID(), &pt);
+ ::ScreenToClient(MainHWND(), &pt);
if (PointInSelMargin(Point(pt.x, pt.y))) {
DisplayCursor(Window::cursorReverseArrow);
} else if (PointInSelection(Point(pt.x, pt.y))) {
@@ -601,7 +611,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
}
return TRUE;
} else
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_CHAR:
if (!iscntrl(wParam&0xff) || !lastKeyDownConsumed) {
@@ -623,16 +633,16 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
Platform::IsKeyDown(VK_MENU),
&lastKeyDownConsumed);
if (!ret && !lastKeyDownConsumed)
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
break;
}
case WM_IME_KEYDOWN:
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_KEYUP:
//Platform::DebugPrintf("S keyup %d %x %x\n",iMessage, wParam, lParam);
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_SETTINGCHANGE:
//Platform::DebugPrintf("Setting Changed\n");
@@ -660,7 +670,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
break;
case WM_PALETTECHANGED:
- if (wParam != reinterpret_cast<unsigned int>(wMain.GetID())) {
+ if (wParam != reinterpret_cast<unsigned int>(MainHWND())) {
//Platform::DebugPrintf("** Palette Changed\n");
RealizeWindowPalette(true);
}
@@ -673,11 +683,11 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_IME_STARTCOMPOSITION: // dbcs
ImeStartComposition();
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_IME_ENDCOMPOSITION: // dbcs
ImeEndComposition();
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_IME_COMPOSITION:
return HandleComposition(wParam, lParam);
@@ -695,21 +705,21 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// Caused by keyboard so display menu near caret
pt = LocationFromPosition(currentPos);
POINT spt = {pt.x, pt.y};
- ::ClientToScreen(wMain.GetID(), &spt);
+ ::ClientToScreen(MainHWND(), &spt);
pt = Point(spt.x, spt.y);
}
ContextMenu(pt);
return 0;
}
#endif
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_INPUTLANGCHANGE:
//::SetThreadLocale(LOWORD(lParam));
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_INPUTLANGCHANGEREQUEST:
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_ERASEBKGND:
return 1; // Avoid any background erasure as whole window painted.
@@ -732,7 +742,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_SYSCOMMAND:
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case EM_LINEFROMCHAR:
if (static_cast<int>(wParam) < 0)
@@ -772,7 +782,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
return reinterpret_cast<sptr_t>(this);
case SCI_GRABFOCUS:
- ::SetFocus(wMain.GetID());
+ ::SetFocus(MainHWND());
break;
default:
@@ -782,16 +792,16 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
}
sptr_t ScintillaWin::DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
}
void ScintillaWin::SetTicking(bool on) {
if (timer.ticking != on) {
timer.ticking = on;
if (timer.ticking) {
- timer.tickerID = ::SetTimer(wMain.GetID(), 1, timer.tickSize, NULL);
+ timer.tickerID = ::SetTimer(MainHWND(), 1, timer.tickSize, NULL);
} else {
- ::KillTimer(wMain.GetID(), timer.tickerID);
+ ::KillTimer(MainHWND(), timer.tickerID);
timer.tickerID = 0;
}
}
@@ -801,7 +811,7 @@ void ScintillaWin::SetTicking(bool on) {
void ScintillaWin::SetMouseCapture(bool on) {
if (mouseDownCaptures) {
if (on) {
- ::SetCapture(wMain.GetID());
+ ::SetCapture(MainHWND());
} else {
::ReleaseCapture();
}
@@ -812,22 +822,22 @@ void ScintillaWin::SetMouseCapture(bool on) {
bool ScintillaWin::HaveMouseCapture() {
// Cannot just see if GetCapture is this window as the scroll bar also sets capture for the window
return capturedMouse;
- //return capturedMouse && (::GetCapture() == wMain.GetID());
+ //return capturedMouse && (::GetCapture() == MainHWND());
}
void ScintillaWin::ScrollText(int linesToMove) {
//Platform::DebugPrintf("ScintillaWin::ScrollText %d\n", linesToMove);
- ::ScrollWindow(wMain.GetID(), 0,
+ ::ScrollWindow(MainHWND(), 0,
vs.lineHeight * linesToMove, 0, 0);
- ::UpdateWindow(wMain.GetID());
+ ::UpdateWindow(MainHWND());
}
void ScintillaWin::SetVerticalScrollPos() {
- ::SetScrollPos(wMain.GetID(), SB_VERT, topLine, TRUE);
+ ::SetScrollPos(MainHWND(), SB_VERT, topLine, TRUE);
}
void ScintillaWin::SetHorizontalScrollPos() {
- ::SetScrollPos(wMain.GetID(), SB_HORZ, xOffset, TRUE);
+ ::SetScrollPos(MainHWND(), SB_HORZ, xOffset, TRUE);
}
bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
@@ -836,7 +846,7 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
sizeof(sci),0,0,0,0,0,0
};
sci.fMask = SIF_PAGE | SIF_RANGE;
- ::GetScrollInfo(wMain.GetID(), SB_VERT, &sci);
+ ::GetScrollInfo(MainHWND(), SB_VERT, &sci);
if ((sci.nMin != 0) || (sci.nMax != pdoc->LinesTotal()) ||
(sci.nPage != static_cast<unsigned int>(pdoc->LinesTotal() - MaxScrollPos() + 1)) ||
(sci.nPos != 0)) {
@@ -848,7 +858,7 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
sci.nPage = nPage;
sci.nPos = 0;
sci.nTrackPos = 1;
- ::SetScrollInfo(wMain.GetID(), SB_VERT, &sci, TRUE);
+ ::SetScrollInfo(MainHWND(), SB_VERT, &sci, TRUE);
modified = true;
}
int horizStart = 0;
@@ -856,9 +866,9 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
int horizEndPreferred = 2000;
if (!horizontalScrollBarVisible)
horizEndPreferred = 0;
- if (!::GetScrollRange(wMain.GetID(), SB_HORZ, &horizStart, &horizEnd) ||
+ if (!::GetScrollRange(MainHWND(), SB_HORZ, &horizStart, &horizEnd) ||
horizStart != 0 || horizEnd != horizEndPreferred) {
- ::SetScrollRange(wMain.GetID(), SB_HORZ, 0, horizEndPreferred, TRUE);
+ ::SetScrollRange(MainHWND(), SB_HORZ, 0, horizEndPreferred, TRUE);
//Platform::DebugPrintf("Horiz Scroll info changed\n");
modified = true;
}
@@ -866,29 +876,30 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
}
void ScintillaWin::NotifyChange() {
- ::SendMessage(::GetParent(wMain.GetID()), WM_COMMAND,
- MAKELONG(wMain.GetDlgCtrlID(), SCEN_CHANGE),
- reinterpret_cast<LPARAM>(wMain.GetID()));
+ ::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
+ MAKELONG(ctrlID, SCEN_CHANGE),
+ reinterpret_cast<LPARAM>(MainHWND()));
}
void ScintillaWin::NotifyFocus(bool focus) {
- ::SendMessage(::GetParent(wMain.GetID()), WM_COMMAND,
- MAKELONG(wMain.GetDlgCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
- reinterpret_cast<LPARAM>(wMain.GetID()));
+ ::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
+ MAKELONG(ctrlID, focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
+ reinterpret_cast<LPARAM>(MainHWND()));
}
void ScintillaWin::NotifyParent(SCNotification scn) {
- scn.nmhdr.hwndFrom = wMain.GetID();
+ scn.nmhdr.hwndFrom = MainHWND();
scn.nmhdr.idFrom = ctrlID;
- ::SendMessage(::GetParent(wMain.GetID()), WM_NOTIFY,
- wMain.GetDlgCtrlID(), reinterpret_cast<LPARAM>(&scn));
+ ::SendMessage(::GetParent(MainHWND()), WM_NOTIFY,
+ ctrlID, reinterpret_cast<LPARAM>(&scn));
}
void ScintillaWin::NotifyDoubleClick(Point pt, bool shift) {
//Platform::DebugPrintf("ScintillaWin Double click 0\n");
ScintillaBase::NotifyDoubleClick(pt, shift);
// Send myself a WM_LBUTTONDBLCLK, so the container can handle it too.
- wMain.SendMessage(WM_LBUTTONDBLCLK,
+ ::SendMessage(MainHWND(),
+ WM_LBUTTONDBLCLK,
shift ? MK_SHIFT : 0,
MAKELPARAM(pt.x, pt.y));
}
@@ -896,7 +907,7 @@ void ScintillaWin::NotifyDoubleClick(Point pt, bool shift) {
void ScintillaWin::Copy() {
//Platform::DebugPrintf("Copy\n");
if (currentPos != anchor) {
- ::OpenClipboard(wMain.GetID());
+ ::OpenClipboard(MainHWND());
::EmptyClipboard();
CopySelTextToClipboard();
if (selType == selRectangle) {
@@ -920,7 +931,7 @@ void ScintillaWin::Paste() {
pdoc->BeginUndoAction();
int selStart = SelectionStart();
ClearSelection();
- ::OpenClipboard(wMain.GetID());
+ ::OpenClipboard(MainHWND());
bool isRectangular = ::IsClipboardFormatAvailable(cfColumnSelect);
HGLOBAL hmemUSelection = 0;
if (IsUnicodeMode()) {
@@ -977,19 +988,22 @@ void ScintillaWin::CreateCallTipWindow(PRectangle) {
#ifdef TOTAL_CONTROL
ct.wCallTip = ::CreateWindow(callClassName, "ACallTip",
WS_VISIBLE | WS_CHILD, 100, 100, 150, 20,
- wMain.GetID(), reinterpret_cast<HMENU>(idCallTip), wMain.GetInstance(), &ct);
+ MainHWND(), reinterpret_cast<HMENU>(idCallTip),
+ reinterpret_cast<HINSTANCE>(::GetWindowLong(MainHWND(),GWL_HINSTANCE)),
+ &ct);
ct.wDraw = ct.wCallTip;
#endif
}
void ScintillaWin::AddToPopUp(const char *label, int cmd, bool enabled) {
#ifdef TOTAL_CONTROL
+ HMENU hmenuPopup = reinterpret_cast<HMENU>(popup.GetID());
if (!label[0])
- ::AppendMenu(popup.GetID(), MF_SEPARATOR, 0, "");
+ ::AppendMenu(hmenuPopup, MF_SEPARATOR, 0, "");
else if (enabled)
- ::AppendMenu(popup.GetID(), MF_STRING, cmd, label);
+ ::AppendMenu(hmenuPopup, MF_STRING, cmd, label);
else
- ::AppendMenu(popup.GetID(), MF_STRING | MF_DISABLED | MF_GRAYED, cmd, label);
+ ::AppendMenu(hmenuPopup, MF_STRING | MF_DISABLED | MF_GRAYED, cmd, label);
#endif
}
@@ -1310,7 +1324,7 @@ void ScintillaWin::ImeStartComposition() {
#ifndef __DMC__
if (caret.active) {
// Move IME Window to current caret position
- HIMC hIMC = ::ImmGetContext(wMain.GetID());
+ HIMC hIMC = ::ImmGetContext(MainHWND());
Point pos = LocationFromPosition(currentPos);
COMPOSITIONFORM CompForm;
CompForm.dwStyle = CFS_POINT;
@@ -1342,7 +1356,7 @@ void ScintillaWin::ImeStartComposition() {
::ImmSetCompositionFont(hIMC, &lf);
}
- ::ImmReleaseContext(wMain.GetID(), hIMC);
+ ::ImmReleaseContext(MainHWND(), hIMC);
// Caret is displayed in IME window. So, caret in Scintilla is useless.
DropCaret();
}
@@ -1418,7 +1432,7 @@ void ScintillaWin::ScrollMessage(WPARAM wParam) {
sci.cbSize = sizeof(sci);
sci.fMask = SIF_ALL;
- ::GetScrollInfo(wMain.GetID(), SB_VERT, &sci);
+ ::GetScrollInfo(MainHWND(), SB_VERT, &sci);
//Platform::DebugPrintf("ScrollInfo %d mask=%x min=%d max=%d page=%d pos=%d track=%d\n", b,sci.fMask,
//sci.nMin, sci.nMax, sci.nPage, sci.nPos, sci.nTrackPos);
@@ -1478,13 +1492,13 @@ void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) {
void ScintillaWin::RealizeWindowPalette(bool inBackGround) {
RefreshStyleData();
Surface surfaceWindow;
- HDC hdc = ::GetDC(wMain.GetID());
+ HDC hdc = ::GetDC(MainHWND());
surfaceWindow.Init(hdc);
int changes = surfaceWindow.SetPalette(&palette, inBackGround);
if (changes > 0)
Redraw();
surfaceWindow.Release();
- ::ReleaseDC(wMain.GetID(), hdc);
+ ::ReleaseDC(MainHWND(), hdc);
}
/**
@@ -1495,13 +1509,13 @@ void ScintillaWin::FullPaint() {
paintState = painting;
rcPaint = GetTextRectangle();
paintingAllText = true;
- HDC hdc = ::GetDC(wMain.GetID());
+ HDC hdc = ::GetDC(MainHWND());
Surface surfaceWindow;
surfaceWindow.Init(hdc);
surfaceWindow.SetUnicodeMode(IsUnicodeMode());
Paint(&surfaceWindow, rcPaint);
surfaceWindow.Release();
- ::ReleaseDC(wMain.GetID(), hdc);
+ ::ReleaseDC(MainHWND(), hdc);
paintState = notPainting;
}
@@ -1577,7 +1591,7 @@ STDMETHODIMP ScintillaWin::DragOver(DWORD grfKeyState, POINTL pt, PDWORD pdwEffe
*pdwEffect = DROPEFFECT_COPY;
// Update the cursor.
POINT rpt = {pt.x, pt.y};
- ::ScreenToClient(wMain.GetID(), &rpt);
+ ::ScreenToClient(MainHWND(), &rpt);
SetDragPosition(PositionFromLocation(Point(rpt.x, rpt.y)));
return S_OK;
@@ -1643,7 +1657,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
HRESULT hrRectangular = pIDataSource->QueryGetData(&fmtr);
POINT rpt = {pt.x, pt.y};
- ::ScreenToClient(wMain.GetID(), &rpt);
+ ::ScreenToClient(MainHWND(), &rpt);
int movePos = PositionFromLocation(Point(rpt.x, rpt.y));
DropAt(movePos, data, *pdwEffect == DROPEFFECT_MOVE, hrRectangular == S_OK);
@@ -1846,8 +1860,8 @@ sptr_t PASCAL ScintillaWin::SWndProc(
}
// This function is externally visible so it can be called from container when building statically
-void Scintilla_RegisterClasses(HINSTANCE hInstance) {
- ScintillaWin::Register(hInstance);
+void Scintilla_RegisterClasses(void *hInstance) {
+ ScintillaWin::Register(reinterpret_cast<HINSTANCE>(hInstance));
}
#ifndef STATIC_BUILD