summaryrefslogtreecommitdiff
path: root/windowspopover/main.c
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-10-09 10:51:35 -0400
committerPietro Gagliardi <[email protected]>2014-10-09 10:51:35 -0400
commit26511f74159135051da8946df10fcbd8ac44daef (patch)
tree30731e239d506cfa8d38fb2b574d7fbd0ef47c70 /windowspopover/main.c
parent1b7dc4a28ca101a24fcdaae9ff506210ed15fa4f (diff)
Reshaped the Windows popover.
Diffstat (limited to 'windowspopover/main.c')
-rw-r--r--windowspopover/main.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/windowspopover/main.c b/windowspopover/main.c
index c733507..ef9de1c 100644
--- a/windowspopover/main.c
+++ b/windowspopover/main.c
@@ -21,6 +21,54 @@
HWND popover;
+// #qo LIBS: user32 kernel32 gdi32
+
+#define ARROWHEIGHT 6
+#define ARROWWIDTH 8
+
+LRESULT CALLBACK popoverproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ PAINTSTRUCT ps;
+ HDC dc;
+ HRGN region;
+ POINT pt;
+
+ switch (uMsg) {
+ case WM_PAINT:
+ dc = BeginPaint(hwnd, &ps);
+ if (dc == NULL) abort();
+ BeginPath(dc);
+ pt.x = 0;
+ pt.y = ARROWHEIGHT;
+ if (MoveToEx(dc, pt.x, pt.y, NULL) == 0) abort();
+ pt.y = 100;
+ if (LineTo(dc, pt.x, pt.y) == 0) abort();
+ pt.x = 100;
+ LineTo(dc, pt.x, pt.y);
+ pt.y = ARROWHEIGHT;
+ LineTo(dc, pt.x, pt.y);
+ pt.x = 50 + ARROWWIDTH;
+ LineTo(dc, pt.x, pt.y);
+ pt.x -= ARROWWIDTH;
+ pt.y -= ARROWHEIGHT;
+ LineTo(dc, pt.x, pt.y);
+ pt.x -= ARROWWIDTH;
+ pt.y += ARROWHEIGHT;
+ LineTo(dc, pt.x, pt.y);
+ pt.x = 0;
+ LineTo(dc, pt.x, pt.y);
+ EndPath(dc);
+ region = PathToRegion(dc);
+ FrameRgn(dc, region, GetStockObject(BLACK_PEN), 1, 1);
+ SetWindowRgn(hwnd, region, TRUE);
+ EndPaint(hwnd, &ps);
+ return 0;
+ case WM_NCCALCSIZE:
+ break;
+ }
+ return DefWindowProcW(hwnd, uMsg, wParam, lParam);
+}
+
LRESULT CALLBACK wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
@@ -47,14 +95,14 @@ int main(int argc, char *argv[])
ZeroMemory(&wc, sizeof (WNDCLASSW));
wc.lpszClassName = L"popover";
- wc.lpfnWndProc = DefWindowProcW;
+ wc.lpfnWndProc = popoverproc;
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
wc.style = CS_DROPSHADOW | CS_NOCLOSE;
if (RegisterClassW(&wc) == 0)
abort();
popover = CreateWindowExW(WS_EX_TOPMOST,
L"popover", L"",
- WS_POPUP | WS_BORDER,
+ WS_POPUP,
0, 0, 150, 100,
NULL, NULL, NULL, NULL);
if (popover == NULL)