dummy message
This commit is contained in:
parent
e4d1206e35
commit
6ded50a21d
@ -27,6 +27,10 @@ LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_SETFOCUS:
|
||||||
|
SetFocus(trackViewWin); // needed to forward keyboard input
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
@ -45,7 +49,7 @@ ATOM registerMainWindowClass(HINSTANCE hInstance)
|
|||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
wc.hbrBackground = (HBRUSH)0;
|
||||||
wc.lpszMenuName = NULL;
|
wc.lpszMenuName = NULL;
|
||||||
wc.lpszClassName = mainWindowClassName;
|
wc.lpszClassName = mainWindowClassName;
|
||||||
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
|||||||
142
trackview.cpp
142
trackview.cpp
@ -5,7 +5,7 @@
|
|||||||
const char *trackViewWindowClassName = "TrackView";
|
const char *trackViewWindowClassName = "TrackView";
|
||||||
|
|
||||||
static const int topMarginHeight = 20;
|
static const int topMarginHeight = 20;
|
||||||
static const int leftMarginWidth = 70;
|
static const int leftMarginWidth = 60;
|
||||||
|
|
||||||
static const int fontHeight = 16;
|
static const int fontHeight = 16;
|
||||||
static const int fontWidth = 12;
|
static const int fontWidth = 12;
|
||||||
@ -59,7 +59,9 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
topLeftCorner.bottom = topMarginHeight;
|
topLeftCorner.bottom = topMarginHeight;
|
||||||
topLeftCorner.left = 0;
|
topLeftCorner.left = 0;
|
||||||
topLeftCorner.right = leftMarginWidth;
|
topLeftCorner.right = leftMarginWidth;
|
||||||
FillRect( hdc, &topLeftCorner, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
FillRect(hdc, &topLeftCorner, (HBRUSH)GetStockObject(GRAY_BRUSH));
|
||||||
|
// DrawEdge(hdc, &topLeftCorner, BDR_SUNKENINNER | BDR_RAISEDOUTER, BF_RIGHT | BF_BOTTOM);
|
||||||
|
ExcludeClipRect(hdc, topLeftCorner.left, topLeftCorner.top, topLeftCorner.right, topLeftCorner.bottom);
|
||||||
|
|
||||||
SetBkMode(hdc, TRANSPARENT);
|
SetBkMode(hdc, TRANSPARENT);
|
||||||
|
|
||||||
@ -72,7 +74,8 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
leftMargin.bottom = leftMargin.top + fontHeight;
|
leftMargin.bottom = leftMargin.top + fontHeight;
|
||||||
|
|
||||||
FillRect(hdc, &leftMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
FillRect(hdc, &leftMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
|
DrawEdge(hdc, &leftMargin, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_RIGHT | BF_BOTTOM | BF_TOP);
|
||||||
|
// Rectangle( hdc, leftMargin.left, leftMargin.top, leftMargin.right, leftMargin.bottom + 1);
|
||||||
if ((y % 16) == 0) SetTextColor(hdc, RGB(0, 0, 0));
|
if ((y % 16) == 0) SetTextColor(hdc, RGB(0, 0, 0));
|
||||||
else if ((y % 8) == 0) SetTextColor(hdc, RGB(32, 32, 32));
|
else if ((y % 8) == 0) SetTextColor(hdc, RGB(32, 32, 32));
|
||||||
else if ((y % 4) == 0) SetTextColor(hdc, RGB(64, 64, 64));
|
else if ((y % 4) == 0) SetTextColor(hdc, RGB(64, 64, 64));
|
||||||
@ -90,6 +93,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
SetTextColor(hdc, RGB(0, 0, 0));
|
SetTextColor(hdc, RGB(0, 0, 0));
|
||||||
|
|
||||||
int trackLeft = leftMarginWidth - scrollPosX;
|
int trackLeft = leftMarginWidth - scrollPosX;
|
||||||
|
int trackTop = 0;
|
||||||
for (int x = 0; x < tracks; ++x)
|
for (int x = 0; x < tracks; ++x)
|
||||||
{
|
{
|
||||||
int trackWidth = fontWidth * 5;
|
int trackWidth = fontWidth * 5;
|
||||||
@ -102,7 +106,8 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
topMargin.left = trackLeft;
|
topMargin.left = trackLeft;
|
||||||
topMargin.right = trackLeft + trackWidth;
|
topMargin.right = trackLeft + trackWidth;
|
||||||
|
|
||||||
FillRect( hdc, &topMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
DrawEdge(hdc, &topMargin, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT | BF_RIGHT | BF_BOTTOM);
|
||||||
|
FillRect(hdc, &topMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
|
|
||||||
/* format the text */
|
/* format the text */
|
||||||
_snprintf_s(temp, 256, "track %d", x);
|
_snprintf_s(temp, 256, "track %d", x);
|
||||||
@ -113,7 +118,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
ExcludeClipRect(hdc, topMargin.left, topMargin.top, topMargin.right, topMargin.bottom);
|
ExcludeClipRect(hdc, topMargin.left, topMargin.top, topMargin.right, topMargin.bottom);
|
||||||
|
|
||||||
// SetBkColor(hdc, RGB(255, 0, 0));
|
// SetBkColor(hdc, RGB(255, 0, 0));
|
||||||
int trackTop = topMarginHeight + (firstLine - scrollPosY) * fontHeight;
|
trackTop = topMarginHeight + (firstLine - scrollPosY) * fontHeight;
|
||||||
for (int y = firstLine; y < lastLine; ++y)
|
for (int y = firstLine; y < lastLine; ++y)
|
||||||
{
|
{
|
||||||
RECT patternDataRect;
|
RECT patternDataRect;
|
||||||
@ -121,7 +126,11 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
patternDataRect.right = trackLeft + trackWidth;
|
patternDataRect.right = trackLeft + trackWidth;
|
||||||
patternDataRect.top = trackTop;
|
patternDataRect.top = trackTop;
|
||||||
patternDataRect.bottom = patternDataRect.top + fontHeight;
|
patternDataRect.bottom = patternDataRect.top + fontHeight;
|
||||||
FillRect( hdc, &patternDataRect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
|
||||||
|
if (y % 8 == 0) FillRect( hdc, &patternDataRect, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
|
else FillRect( hdc, &patternDataRect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||||
|
|
||||||
|
// if (y % 8 == 0) DrawEdge(hdc, &patternDataRect, BDR_RAISEDINNER | BDR_SUNKENOUTER, BF_TOP | BF_BOTTOM | BF_FLAT);
|
||||||
|
|
||||||
bool key = (y % 8 == 0);
|
bool key = (y % 8 == 0);
|
||||||
float val = (float(y) / 16);
|
float val = (float(y) / 16);
|
||||||
@ -154,6 +163,15 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
topMargin.right = rcTracks.right;
|
topMargin.right = rcTracks.right;
|
||||||
FillRect( hdc, &topMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
FillRect( hdc, &topMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
|
|
||||||
|
/* pad left margin to the left edge */
|
||||||
|
RECT leftMargin;
|
||||||
|
leftMargin.top = trackTop;
|
||||||
|
leftMargin.bottom = rcTracks.bottom;
|
||||||
|
leftMargin.left = 0;
|
||||||
|
leftMargin.right = leftMarginWidth;
|
||||||
|
FillRect( hdc, &leftMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
|
|
||||||
|
|
||||||
/* right margin */
|
/* right margin */
|
||||||
RECT rightMargin;
|
RECT rightMargin;
|
||||||
rightMargin.top = topMarginHeight;
|
rightMargin.top = topMarginHeight;
|
||||||
@ -291,17 +309,16 @@ void TrackView::onHScroll(HWND hwnd, UINT sbCode, int newPos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::onGetMinMaxInfo(MINMAXINFO *mm)
|
void TrackView::onKeyDown(HWND hwnd, UINT keyCode, UINT flags)
|
||||||
{
|
{
|
||||||
RECT rect;
|
switch (keyCode)
|
||||||
rect.left = 0;
|
{
|
||||||
rect.top = 0;
|
case VK_UP: setScrollPos(hwnd, scrollPosX, scrollPosY - 1); break;
|
||||||
rect.right = leftMarginWidth;
|
case VK_DOWN: setScrollPos(hwnd, scrollPosX, scrollPosY + 1); break;
|
||||||
rect.bottom = topMarginHeight;
|
|
||||||
AdjustWindowRectEx(&rect, WS_VSCROLL | WS_HSCROLL | WS_OVERLAPPEDWINDOW, FALSE, WS_EX_CLIENTEDGE);
|
|
||||||
|
|
||||||
mm->ptMinTrackSize.x = rect.right;
|
case VK_PRIOR: setScrollPos(hwnd, scrollPosX, scrollPosY - windowLines); break;
|
||||||
mm->ptMinTrackSize.y = rect.bottom - rect.top;
|
case VK_NEXT: setScrollPos(hwnd, scrollPosX, scrollPosY + windowLines); break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::onSize(HWND hwnd, int width, int height)
|
void TrackView::onSize(HWND hwnd, int width, int height)
|
||||||
@ -317,6 +334,48 @@ void TrackView::onSize(HWND hwnd, int width, int height)
|
|||||||
setupScrollBars(hwnd);
|
setupScrollBars(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT TrackView::windowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch(msg)
|
||||||
|
{
|
||||||
|
case WM_CREATE:
|
||||||
|
onCreate(hwnd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_CLOSE:
|
||||||
|
DestroyWindow(hwnd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_SIZE:
|
||||||
|
onSize(hwnd, LOWORD(lParam), HIWORD(lParam));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_VSCROLL:
|
||||||
|
onVScroll(hwnd, LOWORD(wParam), getScrollPos(hwnd, SB_VERT));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_HSCROLL:
|
||||||
|
onHScroll(hwnd, LOWORD(wParam), getScrollPos(hwnd, SB_HORZ));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_PAINT:
|
||||||
|
onPaint(hwnd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
onKeyDown(hwnd, wParam, lParam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK trackViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK trackViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
// Get the TrackView instance (if any)
|
// Get the TrackView instance (if any)
|
||||||
@ -325,7 +384,7 @@ LRESULT CALLBACK trackViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
|||||||
|
|
||||||
switch(msg)
|
switch(msg)
|
||||||
{
|
{
|
||||||
case WM_CREATE:
|
case WM_NCCREATE:
|
||||||
ASSERT(NULL == trackView);
|
ASSERT(NULL == trackView);
|
||||||
|
|
||||||
// allocate a TrackView instance
|
// allocate a TrackView instance
|
||||||
@ -335,49 +394,30 @@ LRESULT CALLBACK trackViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
|||||||
#pragma warning(suppress:4244) /* remove a pointless warning */
|
#pragma warning(suppress:4244) /* remove a pointless warning */
|
||||||
SetWindowLongPtr(hwnd, 0, (LONG_PTR)trackView);
|
SetWindowLongPtr(hwnd, 0, (LONG_PTR)trackView);
|
||||||
|
|
||||||
trackView->onCreate(hwnd);
|
// call the proper window procedure
|
||||||
|
return trackView->windowProc(hwnd, msg, wParam, lParam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_NCDESTROY:
|
||||||
// free the TrackView instance
|
{
|
||||||
ASSERT(NULL != trackView);
|
ASSERT(NULL != trackView);
|
||||||
|
|
||||||
|
// call the window proc and store away the return code
|
||||||
|
LRESULT res = trackView->windowProc(hwnd, msg, wParam, lParam);
|
||||||
|
|
||||||
|
// free the TrackView instance
|
||||||
delete trackView;
|
delete trackView;
|
||||||
|
trackView = NULL;
|
||||||
SetWindowLongPtr(hwnd, 0, (LONG_PTR)NULL);
|
SetWindowLongPtr(hwnd, 0, (LONG_PTR)NULL);
|
||||||
|
|
||||||
DestroyWindow(hwnd);
|
// return the stored return code
|
||||||
break;
|
return res;
|
||||||
|
}
|
||||||
case WM_DESTROY:
|
|
||||||
PostQuitMessage(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_SIZE:
|
|
||||||
ASSERT(NULL != trackView);
|
|
||||||
trackView->onSize(hwnd, LOWORD(lParam), HIWORD(lParam));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_GETMINMAXINFO:
|
|
||||||
ASSERT(NULL != trackView);
|
|
||||||
trackView->onGetMinMaxInfo((MINMAXINFO*)lParam);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_VSCROLL:
|
|
||||||
ASSERT(NULL != trackView);
|
|
||||||
trackView->onVScroll(hwnd, LOWORD(wParam), getScrollPos(hwnd, SB_VERT));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_HSCROLL:
|
|
||||||
ASSERT(NULL != trackView);
|
|
||||||
trackView->onHScroll(hwnd, LOWORD(wParam), getScrollPos(hwnd, SB_HORZ));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_PAINT:
|
|
||||||
ASSERT(NULL != trackView);
|
|
||||||
trackView->onPaint(hwnd);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
ASSERT(NULL != trackView);
|
||||||
|
return trackView->windowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -412,8 +452,6 @@ HWND createTrackViewWindow(HINSTANCE hInstance, HWND hwndParent)
|
|||||||
CW_USEDEFAULT, CW_USEDEFAULT, // width, height
|
CW_USEDEFAULT, CW_USEDEFAULT, // width, height
|
||||||
hwndParent, NULL, GetModuleHandle(NULL), NULL
|
hwndParent, NULL, GetModuleHandle(NULL), NULL
|
||||||
);
|
);
|
||||||
// SetWindowLong(hwnd, 0, (LONG)0xdeadbeef);
|
|
||||||
// SetWindowLongPtr(hwnd, DWLP_USER, 0xdeadbeef);
|
|
||||||
return hwnd;
|
return hwnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,10 @@ public:
|
|||||||
void onVScroll(HWND hwnd, UINT sbCode, int newPos);
|
void onVScroll(HWND hwnd, UINT sbCode, int newPos);
|
||||||
void onHScroll(HWND hwnd, UINT sbCode, int newPos);
|
void onHScroll(HWND hwnd, UINT sbCode, int newPos);
|
||||||
void onSize(HWND hwnd, int width, int height);
|
void onSize(HWND hwnd, int width, int height);
|
||||||
void onGetMinMaxInfo(MINMAXINFO *mm);
|
void onKeyDown(HWND hwnd, UINT keyCode, UINT flags);
|
||||||
|
|
||||||
|
// the window procedure
|
||||||
|
LRESULT windowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
void paintTracks(HDC hdc, RECT rcTracks);
|
void paintTracks(HDC hdc, RECT rcTracks);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user