Merge pull request #746 from toehead2001/lang-selector
Use a standard window for the Language Selector
This commit is contained in:
commit
866d18a97b
|
@ -20,130 +20,15 @@ void CLanguageSelector::Select ( void )
|
|||
DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_Lang_Select),NULL,(DLGPROC)LangSelectProc, (LPARAM)this);
|
||||
}
|
||||
|
||||
static WNDPROC pfnWndLangSelectOkProc = NULL;
|
||||
static HBITMAP hOkButton = NULL;
|
||||
|
||||
DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
|
||||
{
|
||||
static bool m_fPressed = false;
|
||||
static HBITMAP hOkButtonDown = NULL;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
if (BeginPaint(hWnd,&ps))
|
||||
{
|
||||
if (m_fPressed)
|
||||
{
|
||||
if (hOkButtonDown == NULL)
|
||||
{
|
||||
hOkButtonDown = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK_DOWN));
|
||||
}
|
||||
if (hOkButtonDown)
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(hWnd, &rcClient);
|
||||
|
||||
BITMAP bmTL1;
|
||||
GetObject(hOkButtonDown, sizeof(BITMAP), &bmTL1);
|
||||
HDC memdc = CreateCompatibleDC(ps.hdc);
|
||||
HGDIOBJ save = SelectObject(memdc, hOkButtonDown);
|
||||
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hOkButton)
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(hWnd, &rcClient);
|
||||
|
||||
BITMAP bmTL1;
|
||||
GetObject(hOkButton, sizeof(BITMAP), &bmTL1);
|
||||
HDC memdc = CreateCompatibleDC(ps.hdc);
|
||||
HGDIOBJ save = SelectObject(memdc, hOkButton);
|
||||
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
}
|
||||
}
|
||||
EndPaint(hWnd,&ps);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
if (::GetCapture() == hWnd)
|
||||
{
|
||||
POINT ptCursor = { ((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)) };
|
||||
ClientToScreen(hWnd, &ptCursor);
|
||||
RECT rect;
|
||||
GetWindowRect(hWnd, &rect);
|
||||
bool uPressed = ::PtInRect(&rect, ptCursor)==TRUE;
|
||||
if ( m_fPressed != uPressed )
|
||||
{
|
||||
m_fPressed = uPressed;
|
||||
::InvalidateRect(hWnd, NULL, TRUE);
|
||||
UpdateWindow(hWnd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
LRESULT lRet = 0;
|
||||
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
SetCapture(hWnd);
|
||||
if ( ::GetCapture()==hWnd )
|
||||
{
|
||||
m_fPressed = true;
|
||||
|
||||
if (m_fPressed)
|
||||
{
|
||||
::InvalidateRect(hWnd, NULL, TRUE);
|
||||
UpdateWindow(hWnd);
|
||||
}
|
||||
}
|
||||
return lRet;
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
LRESULT lRet = 0;
|
||||
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
if ( ::GetCapture() == hWnd )
|
||||
{
|
||||
::ReleaseCapture();
|
||||
if ( m_fPressed )
|
||||
{
|
||||
::SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), BN_CLICKED), (LPARAM)hWnd);
|
||||
}
|
||||
}
|
||||
m_fPressed = false;
|
||||
|
||||
return lRet;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CallWindowProc(pfnWndLangSelectOkProc, hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static HBITMAP hbmpBackgroundTop = NULL;
|
||||
static HBITMAP hbmpBackgroundBottom = NULL;
|
||||
static HBITMAP hbmpBackgroundMiddle = NULL;
|
||||
static HFONT hTextFont = NULL;
|
||||
static CLanguageSelector * lngClass;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
SetWindowPos(hDlg,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOSIZE);
|
||||
{
|
||||
lngClass = (CLanguageSelector *)lParam;
|
||||
|
||||
|
@ -167,47 +52,11 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
|
|||
SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,0,0);
|
||||
}
|
||||
|
||||
enum { ROUND_EDGE = 15 };
|
||||
|
||||
DWORD dwStyle = GetWindowLong(hDlg, GWL_STYLE);
|
||||
dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
|
||||
SetWindowLong(hDlg, GWL_STYLE, dwStyle);
|
||||
|
||||
// Use the size of the image
|
||||
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_TOP));
|
||||
hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_BOTTOM));
|
||||
hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_MIDDLE));
|
||||
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_LOGO));
|
||||
BITMAP bmTL;
|
||||
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
|
||||
|
||||
if (hbmpBackgroundTop)
|
||||
{
|
||||
// int iHeight = bmTL.bmHeight;
|
||||
int iWidth = bmTL.bmWidth;
|
||||
|
||||
RECT rect;
|
||||
GetWindowRect(hDlg, &rect);
|
||||
rect.left -= rect.left;
|
||||
rect.bottom -= rect.top;
|
||||
rect.top -= rect.top;
|
||||
|
||||
// Tweaked
|
||||
HRGN hWindowRegion= CreateRoundRectRgn
|
||||
(
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.left+iWidth+GetSystemMetrics(SM_CXEDGE)-1,
|
||||
rect.bottom+GetSystemMetrics(SM_CYEDGE)-1,
|
||||
ROUND_EDGE,
|
||||
ROUND_EDGE
|
||||
);
|
||||
|
||||
if (hWindowRegion)
|
||||
{
|
||||
SetWindowRgn(hDlg, hWindowRegion, TRUE);
|
||||
DeleteObject(hWindowRegion);
|
||||
}
|
||||
}
|
||||
hTextFont = ::CreateFont
|
||||
(
|
||||
18,
|
||||
|
@ -227,35 +76,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
|
|||
);
|
||||
SendDlgItemMessage(hDlg,IDC_SELECT_LANG,WM_SETFONT,(WPARAM)hTextFont,TRUE);
|
||||
}
|
||||
|
||||
hOkButton = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK));
|
||||
pfnWndLangSelectOkProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC);
|
||||
::SetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC,(LONG_PTR)LangSelectOkProc);
|
||||
break;
|
||||
case WM_NCHITTEST:
|
||||
{
|
||||
int xPos = LOWORD(lParam);
|
||||
int yPos = HIWORD(lParam);
|
||||
RECT client, a;
|
||||
GetClientRect(hDlg,&a);
|
||||
GetClientRect(hDlg,&client);
|
||||
ClientToScreen(hDlg,(LPPOINT)&client);
|
||||
client.right += client.left;
|
||||
client.bottom += client.top;
|
||||
|
||||
int nCaption = GetSystemMetrics(SM_CYCAPTION)*4;
|
||||
|
||||
LRESULT lResult = HTCLIENT;
|
||||
|
||||
//check caption
|
||||
if (xPos <= client.right && xPos >= client.left &&
|
||||
(yPos >= client.top+ 0)&& (yPos <= client.top + 0+nCaption))
|
||||
{
|
||||
lResult = HTCAPTION;
|
||||
}
|
||||
SetWindowLong(hDlg, DWLP_MSGRESULT, lResult);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case WM_CTLCOLORSTATIC:
|
||||
{
|
||||
|
@ -265,6 +85,22 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
|
|||
return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH));
|
||||
}
|
||||
break;
|
||||
case WM_ERASEBKGND:
|
||||
{
|
||||
HPEN outline;
|
||||
HBRUSH fill;
|
||||
RECT rect;
|
||||
|
||||
outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF);
|
||||
fill = CreateSolidBrush(0x00FFFFFF);
|
||||
SelectObject((HDC)wParam, outline);
|
||||
SelectObject((HDC)wParam, fill);
|
||||
|
||||
GetClientRect(hDlg, &rect);
|
||||
|
||||
Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom);
|
||||
}
|
||||
break;
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
|
@ -276,8 +112,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
|
|||
|
||||
BITMAP bmTL_top, bmTL_bottom, bmTL_Middle;
|
||||
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
|
||||
GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom);
|
||||
GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle);
|
||||
|
||||
HDC memdc = CreateCompatibleDC(ps.hdc);
|
||||
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
|
||||
|
@ -285,25 +119,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
|
|||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
|
||||
memdc = CreateCompatibleDC(ps.hdc);
|
||||
save = SelectObject(memdc, hbmpBackgroundMiddle);
|
||||
for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight)
|
||||
{
|
||||
//BitBlt(ps.hdc, 0, bmTL_top.bmHeight, bmTL_Middle.bmWidth, rcClient.bottom - (bmTL_bottom.bmHeight + bmTL_top.bmHeight), memdc, 0, 0, SRCCOPY);
|
||||
BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
}
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
|
||||
BITMAP ;
|
||||
memdc = CreateCompatibleDC(ps.hdc);
|
||||
save = SelectObject(memdc, hbmpBackgroundBottom);
|
||||
BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
|
||||
BITMAP ;
|
||||
|
||||
EndPaint(hDlg,&ps);
|
||||
}
|
||||
}
|
||||
|
@ -316,14 +131,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
|
|||
{
|
||||
DeleteObject(hbmpBackgroundTop);
|
||||
}
|
||||
if (hbmpBackgroundBottom)
|
||||
{
|
||||
DeleteObject(hbmpBackgroundBottom);
|
||||
}
|
||||
if (hbmpBackgroundMiddle)
|
||||
{
|
||||
DeleteObject(hbmpBackgroundMiddle);
|
||||
}
|
||||
|
||||
if (hTextFont)
|
||||
{
|
||||
|
|
|
@ -492,9 +492,9 @@ BEGIN
|
|||
PUSHBUTTON "Close",IDCANCEL,154,110,50,14
|
||||
END
|
||||
|
||||
IDD_Lang_Select DIALOGEX 0, 0, 237, 111
|
||||
STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Welcome to"
|
||||
IDD_Lang_Select DIALOGEX 0, 0, 233, 120
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION
|
||||
CAPTION "Project64"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,90,99,50,12
|
||||
|
|
Loading…
Reference in New Issue