From: <kr_...@us...> - 2003-08-10 18:36:07
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv18716/src/cbits/Win32 Modified Files: ControlBar.c ControlBar.h Frame.c Internals.h ToolBar.c Util.c Log Message: Added complete implementation for floating toolbars for Windows Index: ControlBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ControlBar.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ControlBar.c 8 Jul 2003 20:31:29 -0000 1.1 --- ControlBar.c 10 Aug 2003 18:36:04 -0000 1.2 *************** *** 5,27 **** ! int GetControlBarSize(HWND hControlBar) { ! HWND hCtrl; ! LONG lStyle; ! int nSize; ! RECT rect; ! ! lStyle = GetWindowLong(hControlBar, GWL_STYLE); ! nSize = 0; ! hCtrl = GetTopWindow(hControlBar); ! while (hCtrl) ! { ! GetClientRect(hCtrl,&rect); ! nSize = max(nSize, (lStyle & CCS_VERT) ? rect.right : rect.bottom); ! hCtrl = GetNextWindow(hCtrl,GW_HWNDNEXT); ! } return nSize; --- 5,86 ---- ! typedef struct { ! int nSize; ! int nOffset; ! HWND hWnd; ! } BarData; ! typedef struct ! { ! int nSize; ! int nOffset; ! int nBarCount; ! BarData *pBars; ! } BandData; ! typedef struct ! { ! int nBandCount; ! BandData *pBands; ! } ControlBarData; ! static void RecalcControlBarLayout(ControlBarData *pData, BOOL bVert) ! { ! int i, j; ! BarData *pBar; ! BandData *pBand; ! int nBarOffset, nBandOffset; ! SIZE sz; ! ! nBandOffset = 0; ! for (i = 0; i < pData->nBandCount; i++) ! { ! pBand = &pData->pBands[i]; ! ! pBand->nSize = 0; ! pBand->nOffset = nBandOffset; ! ! nBarOffset = 0; ! for (j = 0; j < pBand->nBarCount; j++) ! { ! pBar = &pBand->pBars[j]; ! GetToolBarSize(pBar->hWnd, &sz); ! ! pBar->nOffset = max(pBar->nOffset, nBarOffset); ! if (bVert) ! { ! pBand->nSize = max(pBand->nSize, sz.cx); ! pBar->nSize = sz.cy; ! ! SetWindowPos(pBar->hWnd,NULL,pBand->nOffset,pBar->nOffset,sz.cx,sz.cy,SWP_NOZORDER); ! } ! else ! { ! pBand->nSize = max(pBand->nSize, sz.cy); ! pBar->nSize = sz.cx; ! ! SetWindowPos(pBar->hWnd,NULL,pBar->nOffset,pBand->nOffset,sz.cx,sz.cy,SWP_NOZORDER); ! } ! ! nBarOffset = pBar->nOffset + pBar->nSize; ! } ! ! nBandOffset = pBand->nOffset + pBand->nSize; ! } ! } ! ! static int GetControlBarSize(HWND hControlBar) ! { ! int i, nSize; ! ControlBarData *pData; ! ! nSize = 0; ! pData = (ControlBarData *) GetWindowLong(hControlBar, GWL_USERDATA); ! ! RecalcControlBarLayout(pData, GetWindowLong(hControlBar, GWL_STYLE) & CCS_VERT); ! ! for (i = 0; i < pData->nBandCount; i++) ! nSize += pData->pBands[i].nSize; return nSize; *************** *** 53,89 **** LRESULT CALLBACK HControlBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! HWND hToolBar; ! TBBUTTONINFO tbbi; ! ! tbbi.cbSize = sizeof(tbbi); ! tbbi.dwMask = TBIF_LPARAM; ! tbbi.lParam = NULL; switch (uMsg) { case WM_COMMAND: { ! hToolBar = (HWND) lParam; SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); handleToolCommand((WindowHandle) tbbi.lParam); } break; ! case WM_NOTIFY: { ! LPNMTTDISPINFO lpnmtdi = (LPNMTTDISPINFO) lParam; ! if (lpnmtdi->hdr.code == TTN_NEEDTEXT) ! { ! hToolBar = lpnmtdi->lParam; ! printf("2> hToolBar=%p\n", hToolBar); ! printf("2> lpnmtdi->hdr.idFrom=%p\n", lpnmtdi->hdr.idFrom); ! ! SendMessage(hToolBar, TB_GETBUTTONINFO, lpnmtdi->hdr.idFrom, (LPARAM) &tbbi); ! printf("2> tbbi.lParam=%p\n", tbbi.lParam); ! printf("2> lpnmtdi->lParam=%p\n", lpnmtdi->lParam); ! ! //lpnmtdi->lpszText = ((ToolButton) tbbi.lParam)->lpszToolTip; ! } } break; } --- 112,183 ---- LRESULT CALLBACK HControlBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! ControlBarData *pData = (ControlBarData *) GetWindowLong(hWnd, GWL_USERDATA); switch (uMsg) { + case WM_CREATE: + { + HMENU hMenu; + + if (((CREATESTRUCT *) lParam)->style & WS_CHILD) + { + pData = malloc(sizeof(ControlBarData)); + if (!pData) return -1; + + pData->nBandCount = 0; + pData->pBands = NULL; + + SetWindowLong(hWnd, GWL_USERDATA, (LONG) pData); + } + + hMenu = GetSystemMenu(hWnd, FALSE); + if (hMenu) + { + DeleteMenu(hMenu, SC_RESTORE, MF_BYCOMMAND); + DeleteMenu(hMenu, SC_MINIMIZE, MF_BYCOMMAND); + DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND); + DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND); + AppendMenu(hMenu, MF_STRING, SC_CLOSE, "Hide"); + } + } + break; + case WM_DESTROY: + if (pData) + { + int i; + + SetWindowLong(hWnd, GWL_USERDATA, 0); + for (i = 0; i < pData->nBandCount; i++) + free(pData->pBands[i].pBars); + free(pData->pBands); + free(pData); + } + break; + case WM_CLOSE: + ShowWindow(hWnd, SW_HIDE); + return 0; case WM_COMMAND: { ! TBBUTTONINFO tbbi; ! HWND hToolBar = (HWND) lParam; + tbbi.cbSize = sizeof(tbbi); + tbbi.dwMask = TBIF_LPARAM; + tbbi.lParam = 0; SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); handleToolCommand((WindowHandle) tbbi.lParam); } break; ! case WM_SIZE: ! if (!pData) { ! int nWidth = LOWORD(lParam); ! int nHeight = HIWORD(lParam); ! ! SetWindowPos(GetWindow(hWnd, GW_CHILD),NULL,0,0,nWidth,nHeight,SWP_NOZORDER); } + case WM_NCLBUTTONDOWN: + if (wParam == HTCAPTION) + SendMessage(GetWindow(hWnd, GW_CHILD), uMsg, wParam, lParam); break; } *************** *** 91,92 **** --- 185,314 ---- return DefWindowProc(hWnd, uMsg, wParam, lParam); } + + void DockToolBarToRect(HWND hControlBar, HWND hWnd, RECT rect) + { + int nBandNum; + int nPosition; + int nOffset; + int nCentralOffset; + ControlBarData *pData = (ControlBarData *) GetWindowLong(hControlBar, GWL_USERDATA); + BOOL bVert = GetWindowLong(hControlBar, GWL_STYLE) & CCS_VERT; + BandData *pBand; + + RecalcControlBarLayout(pData, bVert); + + if (bVert) + { + nOffset = rect.top; + nCentralOffset = (rect.right-rect.left)/2; + } + else + { + nOffset = rect.left; + nCentralOffset = (rect.bottom-rect.top)/2; + } + + for (nBandNum = 0; nBandNum < pData->nBandCount; nBandNum++) + { + if (pData->pBands[nBandNum].nOffset <= nCentralOffset && + nCentralOffset <= pData->pBands[nBandNum].nOffset+pData->pBands[nBandNum].nSize) + break; + } + + if (nBandNum >= pData->nBandCount) + nPosition = 0; + else + { + pBand = &pData->pBands[nBandNum]; + + if (nOffset < pBand->pBars[0].nOffset) + nPosition = 0; + else + { + for (nPosition = 1; nPosition < pBand->nBarCount; nPosition++) + { + if (nOffset < pBand->pBars[nPosition].nOffset) + break; + } + } + } + + DockToolBar(hControlBar, hWnd, nBandNum, nPosition, nOffset); + } + + void DockToolBar(HWND hControlBar, HWND hWnd, int nBandNum, int nPosition, int nOffset) + { + BarData *pBar; + BandData *pBand; + ControlBarData *pData = (ControlBarData *) GetWindowLong(hControlBar, GWL_USERDATA); + + SetParent(hWnd, hControlBar); + + if (pData) + { + if (nBandNum >= pData->nBandCount) + { + pData->pBands = realloc(pData->pBands, (pData->nBandCount+1)*sizeof(BandData)); + memset(pData->pBands+pData->nBandCount, 0, sizeof(BandData)); + nBandNum = pData->nBandCount; + pData->nBandCount++; + } + pBand = &pData->pBands[nBandNum]; + + if (nPosition >= pBand->nBarCount) + nPosition = pBand->nBarCount; + pBand->pBars = realloc(pBand->pBars, (pBand->nBarCount+1)*sizeof(BarData)); + memmove(pBand->pBars+nPosition+1, pBand->pBars+nPosition, (pBand->nBarCount-nPosition)*sizeof(BarData)); + pBand->nBarCount++; + + pBar = &pBand->pBars[nPosition]; + memset(pBar, 0, sizeof(BarData)); + pBar->nOffset = nOffset; + pBar->hWnd = hWnd; + + RecalcControlBarLayout(pData, GetWindowLong(hWnd, GWL_STYLE) & CCS_VERT); + } + } + + void UndockToolBar(HWND hControlBar, HWND hWnd) + { + int i, j; + BarData *pBar; + BandData *pBand; + ControlBarData *pData = (ControlBarData *) GetWindowLong(hControlBar, GWL_USERDATA); + + SetParent(hWnd, NULL); + + if (pData) + { + for (i = 0; i < pData->nBandCount; i++) + { + pBand = &pData->pBands[i]; + + for (j = 0; j < pBand->nBarCount; j++) + { + pBar = &pBand->pBars[j]; + + if (pBar->hWnd == hWnd) + { + memmove(pBand->pBars+j, pBand->pBars+j+1, (pBand->nBarCount-j-1)*sizeof(BarData)); + pBand->pBars = realloc(pBand->pBars, (pBand->nBarCount-1)*sizeof(BarData)); + pBand->nBarCount--; + + if (pBand->nBarCount == 0) + { + memmove(pData->pBands+i, pData->pBands+i+1, (pData->nBandCount-i-1)*sizeof(BandData)); + pData->pBands = realloc(pData->pBands, (pData->nBandCount-1)*sizeof(BandData)); + pData->nBandCount--; + } + + return; + } + } + } + } + else + { + DestroyWindow(hControlBar); + } + } \ No newline at end of file Index: ControlBar.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ControlBar.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ControlBar.h 8 Jul 2003 20:31:29 -0000 1.1 --- ControlBar.h 10 Aug 2003 18:36:04 -0000 1.2 *************** *** 2,7 **** #define CONTROLBAR_H - int GetControlBarSize(HWND hControlBar); void RelayoutFrameBars(); #endif --- 2,12 ---- #define CONTROLBAR_H void RelayoutFrameBars(); + + void DockToolBar(HWND hControlBar, HWND hWnd, int nBandNum, int nPosition, int nOffset); + void DockToolBarToRect(HWND hControlBar, HWND hWnd, RECT rect); + void UndockToolBar(HWND hControlBar, HWND hWnd); + + void GetToolBarSize(HWND hToolBar, SIZE *pSize); #endif Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Frame.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Frame.c 3 Jul 2003 17:46:00 -0000 1.11 --- Frame.c 10 Aug 2003 18:36:04 -0000 1.12 *************** *** 94,107 **** GetWindowText(hWnd,pData->lpszAppName,nLen+1); } ! SetWindowLong(hWnd,GWL_USERDATA,(LONG) pData); } break; case WM_SIZE: ! { ! int nWidth = LOWORD(lParam); ! int nHeight = HIWORD(lParam); ! SetWindowPos(pData->hClientWnd,NULL,0,0,nWidth,nHeight,SWP_NOZORDER); ! } break; case WM_COMMAND: --- 94,136 ---- GetWindowText(hWnd,pData->lpszAppName,nLen+1); } ! ! pData->hLeftBar = CreateWindow("HCONTROLBAR", ! NULL, ! WS_CHILD | WS_VISIBLE | CCS_VERT, ! 0,0,0,0, ! hWnd, ! NULL, ! (HANDLE) ghModule, ! NULL); ! pData->hTopBar = CreateWindow("HCONTROLBAR", ! NULL, ! WS_CHILD | WS_VISIBLE, ! 0,0,0,0, ! hWnd, ! NULL, ! (HANDLE) ghModule, ! NULL); ! pData->hRightBar = CreateWindow("HCONTROLBAR", ! NULL, ! WS_CHILD | WS_VISIBLE | CCS_VERT, ! 0,0,0,0, ! hWnd, ! NULL, ! (HANDLE) ghModule, ! NULL); ! pData->hBottomBar= CreateWindow("HCONTROLBAR", ! NULL, ! WS_CHILD | WS_VISIBLE, ! 0,0,0,0, ! hWnd, ! NULL, ! (HANDLE) ghModule, ! NULL); ! SetWindowLong(hWnd,GWL_USERDATA,(LONG) pData); } break; case WM_SIZE: ! RelayoutFrameBars(); break; case WM_COMMAND: Index: Internals.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Internals.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Internals.h 8 Jul 2003 21:18:06 -0000 1.3 --- Internals.h 10 Aug 2003 18:36:04 -0000 1.4 *************** *** 13,16 **** --- 13,35 ---- #endif + #ifndef NCCALCSIZE_PARAMS + typedef struct tagNCCALCSIZE_PARAMS { + RECT rgrc[3]; + PWINDOWPOS lppos; + } NCCALCSIZE_PARAMS, *LPNCCALCSIZE_PARAMS; + #endif + + #ifndef TB_GETMAXSIZE + #define TB_GETMAXSIZE (WM_USER + 83) + #endif + + #ifndef TB_SETSTYLE + #define TB_SETSTYLE (WM_USER + 56) + #endif + + #ifndef TB_GETSTYLE + #define TB_GETSTYLE (WM_USER + 57) + #endif + extern HMODULE ghModule; extern HWND ghWndFrame; Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ToolBar.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ToolBar.c 8 Jul 2003 21:36:39 -0000 1.3 --- ToolBar.c 10 Aug 2003 18:36:04 -0000 1.4 *************** *** 2,5 **** --- 2,21 ---- #include "ControlBar.h" #include "Internals.h" + #include <windowsx.h> + + #define CX_GRIPPER 3 + #define CY_GRIPPER 3 + #define CX_BORDER_GRIPPER 2 + #define CY_BORDER_GRIPPER 2 + #define CX_BORDER 1 + #define CY_BORDER 1 + + #define HORZ 0x1000L + #define VERT 0x2000L + #define FLOAT 0x4000L + + WNDPROC DefToolBarProc = NULL; + + static int nNextToolButtonID = 0; struct ToolHandle *************** *** 9,39 **** BitmapHandle bitmap; }; - static int nNextToolButtonID = 0; ! WindowHandle osCreateToolBar(char *name, int place, int band_num, int band_position, int offset) { HWND hControlBar, hWnd; FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); switch (place) { ! case 0: hControlBar = pFrameData->hLeftBar; break; ! case 1: hControlBar = pFrameData->hTopBar; break; ! case 2: hControlBar = pFrameData->hRightBar; break; ! case 3: hControlBar = pFrameData->hBottomBar; break; } ! hWnd = CreateWindow (TOOLBARCLASSNAME, ! NULL, ! WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS | CCS_TOP | TBSTYLE_TOOLTIPS | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT, 0,0,0,0, hControlBar, (HMENU) NULL, (HANDLE) ghModule, ! 0 ); ! SendMessage (hWnd, TB_AUTOSIZE, (WPARAM)0, (LPARAM)0); ! SendMessage (hWnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), (LPARAM) 0); ! return hWnd; } --- 25,777 ---- BitmapHandle bitmap; }; ! //////////////////////////////////////////// ! // Drawing & GDI utilities ! //////////////////////////////////////////// ! ! static void FillSolidRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clr) ! { ! RECT rect; ! rect.left = x; ! rect.top = y; ! rect.right = x + cx; ! rect.bottom = y + cy; ! ! SetBkColor(hDC, clr); ! ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL); ! } ! ! static void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight) ! { ! FillSolidRect(hDC, x, y, cx - 1, 1, clrTopLeft); ! FillSolidRect(hDC, x, y, 1, cy - 1, clrTopLeft); ! FillSolidRect(hDC, x + cx, y, -1, cy, clrBottomRight); ! FillSolidRect(hDC, x, y + cy, cx, -1, clrBottomRight); ! } ! ! static HBRUSH CreateHalftoneBrush() ! { ! static WORD grayPattern[] = {0x5555, 0xAAAA, 0x5555, 0xAAAA, 0x5555, 0xAAAA, 0x5555, 0xAAAA}; ! ! HBITMAP hGrayBitmap; ! HBRUSH hHalftoneBrush = NULL; ! ! hGrayBitmap = CreateBitmap(8, 8, 1, 1, &grayPattern); ! if (hGrayBitmap != NULL) ! { ! hHalftoneBrush = CreatePatternBrush(hGrayBitmap); ! DeleteObject(hGrayBitmap); ! } ! ! return hHalftoneBrush; ! } ! ! static void DrawDragRect(HDC hDC, RECT *pRect, SIZE size, RECT *pRectLast, SIZE sizeLast, HBRUSH hBrush, HBRUSH hBrushLast) ! { ! RECT rect; ! HRGN hRgnNew, hRgnOutside, hRgnInside, hRgnLast, hRgnUpdate; ! HBRUSH hBrushOld; ! ! // first, determine the update region and select it ! rect = *pRect; ! InflateRect(&rect, -size.cx, -size.cy); ! IntersectRect(&rect, &rect, pRect); ! hRgnOutside = CreateRectRgnIndirect(pRect); ! hRgnInside = CreateRectRgnIndirect(&rect); ! hRgnNew = CreateRectRgn(0, 0, 0, 0); ! CombineRgn(hRgnNew, hRgnOutside, hRgnInside, RGN_XOR); ! ! // find difference between new region and old region ! rect = *pRectLast; ! InflateRect(&rect, -sizeLast.cx, -sizeLast.cy); ! IntersectRect(&rect, &rect, pRectLast); ! SetRectRgn(hRgnOutside, pRectLast->left, pRectLast->top, pRectLast->right, pRectLast->bottom); ! SetRectRgn(hRgnInside, rect.left, rect.top, rect.right, rect.bottom); ! hRgnLast = CreateRectRgn(0, 0, 0, 0); ! CombineRgn(hRgnLast, hRgnOutside, hRgnInside, RGN_XOR); ! ! // only diff them if brushes are the same ! hRgnUpdate = NULL; ! if (hBrush == hBrushLast) ! { ! hRgnUpdate = CreateRectRgn(0, 0, 0, 0); ! CombineRgn(hRgnUpdate, hRgnLast, hRgnNew, RGN_XOR); ! } ! ! if (hBrush != hBrushLast && pRectLast != NULL) ! { ! // brushes are different -- erase old region first ! SelectClipRgn(hDC, hRgnLast); ! GetClipBox(hDC, &rect); ! hBrushOld = SelectObject(hDC, hBrushLast); ! PatBlt(hDC, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, PATINVERT); ! SelectObject(hDC, hBrushOld); ! } ! ! // draw into the update/new region ! SelectClipRgn(hDC, hRgnUpdate != NULL ? hRgnUpdate : hRgnNew); ! GetClipBox(hDC, &rect); ! hBrushOld = SelectObject(hDC, hBrush); ! PatBlt(hDC, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, PATINVERT); ! SelectObject(hDC, hBrushOld); ! SelectClipRgn(hDC, NULL); ! ! if (hRgnNew) DeleteObject(hRgnNew); ! if (hRgnOutside) DeleteObject(hRgnOutside); ! if (hRgnInside) DeleteObject(hRgnInside); ! if (hRgnLast) DeleteObject(hRgnLast); ! if (hRgnUpdate) DeleteObject(hRgnUpdate); ! } ! ! //////////////////////////////////////////// ! // utility functions ! //////////////////////////////////////////// ! ! static BOOL ToolHitTest(HWND hToolBar, POINT point) ! { ! RECT rect; ! int i, nButtons; ! TBBUTTON button; ! ! // now hit test against CToolBar buttons ! nButtons = (int) SendMessage(hToolBar, TB_BUTTONCOUNT, 0, 0); ! for (i = 0; i < nButtons; i++) ! { ! if (SendMessage(hToolBar, TB_GETITEMRECT, i, (LPARAM)&rect)) ! { ! if ((point.x >= rect.left && point.x <= rect.right && ! point.y >= rect.top && point.y <= rect.bottom)) ! { ! if (SendMessage(hToolBar, TB_GETBUTTON, i, (LPARAM)&button) && (button.fsStyle & TBSTYLE_SEP) == 0) ! return TRUE; ! } ! } ! } ! ! return FALSE; ! } ! ! void GetToolBarSize(HWND hToolBar, SIZE *pSize) ! { ! RECT rect; ! SIZE sz; ! int i, nButtons; ! LONG lStyle; ! ! lStyle = GetWindowLong(hToolBar, GWL_STYLE); ! ! sz.cx = 0; ! sz.cy = 0; ! ! nButtons = (int) SendMessage(hToolBar, TB_BUTTONCOUNT, 0, 0); ! for (i = 0; i < nButtons; i++) ! { ! if (SendMessage(hToolBar, TB_GETITEMRECT, i, (LPARAM)&rect)) ! { ! if (lStyle & HORZ) ! { ! sz.cx += rect.right-rect.left; ! sz.cy = max(sz.cy,rect.bottom-rect.top); ! } ! else ! if (lStyle & VERT) ! { ! sz.cx = max(sz.cx,rect.right-rect.left); ! sz.cy += rect.bottom-rect.top; ! } ! } ! } ! ! sz.cx += 4*CX_BORDER; ! sz.cy += 4*CY_BORDER; ! if (lStyle & HORZ) ! sz.cx += CX_BORDER_GRIPPER+CX_GRIPPER+CX_BORDER_GRIPPER; ! else ! if (lStyle & VERT) ! sz.cy += CY_BORDER_GRIPPER+CY_GRIPPER+CY_BORDER_GRIPPER; ! ! *pSize = sz; ! } ! ! ! //////////////////////////////////////////// ! // The DockContext ! //////////////////////////////////////////// ! ! typedef struct ! { ! HWND hToolBar; ! POINT ptLast; ! RECT rectLast; ! SIZE sizeLast; ! ! HWND hDesktopWnd; ! HDC hDesktopDC; ! ! BOOL bDitherLast; ! HBRUSH hWhiteBrush, hDitherBrush; ! ! RECT rectDragHorz, rectFrameDragHorz; ! RECT rectDragVert, rectFrameDragVert; ! ! DWORD dwOverDockStyle; ! DWORD dwDockStyle; ! ! BOOL bFlip; ! BOOL bForceFrame; ! } DockContext; ! ! static BOOL InitDockContext(HWND hToolBar, POINT pos, DockContext *pCtxt) ! { ! RECT rect; ! ! memset(pCtxt, 0, sizeof(DockContext)); ! pCtxt->ptLast = pos; ! pCtxt->hToolBar = hToolBar; ! pCtxt->bForceFrame = FALSE; ! pCtxt->bFlip = FALSE; ! pCtxt->bDitherLast = FALSE; ! pCtxt->dwDockStyle = GetWindowLong(hToolBar, GWL_STYLE) & (HORZ | VERT); ! SetRectEmpty(&pCtxt->rectLast); ! ! // don't handle if capture already set ! if (GetCapture() != NULL) ! return FALSE; ! ! // get desktop window ! pCtxt->hDesktopWnd = GetDesktopWindow(); ! if (!pCtxt->hDesktopWnd) ! return FALSE; ! ! // get the device context for the desktop window ! if (LockWindowUpdate(pCtxt->hDesktopWnd)) ! pCtxt->hDesktopDC = GetDCEx(pCtxt->hDesktopWnd, NULL, DCX_WINDOW|DCX_CACHE|DCX_LOCKWINDOWUPDATE); ! else ! pCtxt->hDesktopDC = GetDCEx(pCtxt->hDesktopWnd, NULL, DCX_WINDOW|DCX_CACHE); ! ! if (!pCtxt->hDesktopDC) ! return FALSE; ! ! // get white brush ! pCtxt->hWhiteBrush = (HBRUSH) GetStockObject(WHITE_BRUSH); ! if (!pCtxt->hWhiteBrush) ! { ! ReleaseDC(pCtxt->hDesktopWnd, pCtxt->hDesktopDC); ! return FALSE; ! } ! ! // create dither brush ! pCtxt->hDitherBrush = CreateHalftoneBrush(); ! if (!pCtxt->hDitherBrush) ! { ! DeleteObject(pCtxt->hWhiteBrush); ! ReleaseDC(pCtxt->hDesktopWnd, pCtxt->hDesktopDC); ! return FALSE; ! } ! ! GetWindowRect(hToolBar, &rect); ! ScreenToClient(hToolBar, ((POINT *) &rect)); ! ScreenToClient(hToolBar, ((POINT *) &rect)+1); ! ! // calculate inverted dragging rect ! if (pCtxt->dwDockStyle & HORZ) ! { ! pCtxt->rectDragHorz = rect; ! pCtxt->rectDragVert.left = pos.x - (rect.bottom - rect.top)/2; ! pCtxt->rectDragVert.top = rect.top; ! pCtxt->rectDragVert.right = pCtxt->rectDragVert.left+(rect.bottom - rect.top ); ! pCtxt->rectDragVert.bottom = pCtxt->rectDragVert.top +(rect.right - rect.left); ! } ! else // vertical orientation ! { ! pCtxt->rectDragVert = rect; ! pCtxt->rectDragHorz.left = rect.left; ! pCtxt->rectDragHorz.top = pos.y - (rect.right - rect.left)/2; ! pCtxt->rectDragHorz.right = pCtxt->rectDragHorz.left+(rect.bottom - rect.top ); ! pCtxt->rectDragHorz.bottom = pCtxt->rectDragHorz.top +(rect.right - rect.left); ! } ! ! // calculate frame dragging rectangle ! pCtxt->rectFrameDragHorz = pCtxt->rectDragHorz; ! pCtxt->rectFrameDragVert = pCtxt->rectDragVert; ! ! AdjustWindowRectEx(&pCtxt->rectFrameDragHorz, WS_THICKFRAME | WS_CAPTION, FALSE, WS_EX_PALETTEWINDOW); ! AdjustWindowRectEx(&pCtxt->rectFrameDragVert, WS_THICKFRAME | WS_CAPTION, FALSE, WS_EX_PALETTEWINDOW); ! InflateRect(&pCtxt->rectFrameDragHorz, -CX_BORDER*2, -CY_BORDER*2); ! InflateRect(&pCtxt->rectFrameDragVert, -CX_BORDER*2, -CY_BORDER*2); ! ! // set capture to the window which received this message ! SetCapture(pCtxt->hToolBar); ! ! return TRUE; ! } ! ! static void ReleaseDockContext(DockContext *pCtxt) ! { ! DeleteObject(pCtxt->hDitherBrush); ! DeleteObject(pCtxt->hWhiteBrush); ! ! LockWindowUpdate(NULL); ! ReleaseDC(pCtxt->hDesktopWnd, pCtxt->hDesktopDC); ! ! ReleaseCapture(); ! } ! ! //////////////////////////////////////////////////////// ! ! static void DrawDockRect(DockContext *pCtxt, BOOL bRemoveRect) ! { ! SIZE size; ! RECT rect; ! HBRUSH hBrush = pCtxt->hWhiteBrush; ! ! // default to thin frame ! size.cx = CX_BORDER; ! size.cy = CY_BORDER; ! ! // determine new rect and size ! if (pCtxt->dwOverDockStyle & HORZ) ! rect = pCtxt->rectDragHorz; ! else ! if (pCtxt->dwOverDockStyle & VERT) ! rect = pCtxt->rectDragVert; ! else ! { ! // use thick frame instead ! size.cx = GetSystemMetrics(SM_CXFRAME) - CX_BORDER; ! size.cy = GetSystemMetrics(SM_CYFRAME) - CY_BORDER; ! ! if (((pCtxt->dwDockStyle & HORZ) && !pCtxt->bFlip) || ((pCtxt->dwDockStyle & VERT) && pCtxt->bFlip)) ! rect = pCtxt->rectFrameDragHorz; ! else ! rect = pCtxt->rectFrameDragVert; ! hBrush = pCtxt->hDitherBrush; ! } ! ! if (bRemoveRect) ! size.cx = size.cy = 0; ! ! if (pCtxt->dwOverDockStyle & (VERT | HORZ)) ! { ! // looks better one pixel in (makes the bar look pushed down) ! InflateRect(&rect, -CX_BORDER, -CY_BORDER); ! } ! ! // draw it and remember last size ! DrawDragRect(pCtxt->hDesktopDC, &rect, size, &pCtxt->rectLast, pCtxt->sizeLast, ! hBrush, pCtxt->bDitherLast ? pCtxt->hDitherBrush : pCtxt->hWhiteBrush); ! pCtxt->rectLast = rect; ! pCtxt->sizeLast = size; ! pCtxt->bDitherLast = (hBrush == pCtxt->hDitherBrush); ! } ! ! static BOOL CanDockBar(HWND hControlBar, RECT *pRect) ! { ! RECT rect; ! ! GetWindowRect(hControlBar, &rect); ! if (rect.left == rect.right ) rect.right++; ! if (rect.top == rect.bottom) rect.bottom++; ! ! return IntersectRect(&rect, &rect, pRect); ! } ! ! static DWORD CanDock(DockContext *pCtxt, HWND *phControlBar) ! { ! RECT rect; ! FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame, GWL_USERDATA); ! int nSize; ! ! if (((pCtxt->dwDockStyle & HORZ) && !pCtxt->bFlip) || ((pCtxt->dwDockStyle & VERT) && pCtxt->bFlip)) ! rect = pCtxt->rectDragHorz; ! else ! rect = pCtxt->rectDragVert; ! nSize = min(rect.right-rect.left, rect.bottom-rect.top); ! rect.right = rect.left + nSize; ! rect.bottom = rect.top + nSize; ! ! if (CanDockBar(pData->hLeftBar, &rect)) ! { ! if (phControlBar) *phControlBar = pData->hLeftBar; ! return VERT; ! } ! ! if (CanDockBar(pData->hTopBar, &rect)) ! { ! if (phControlBar) *phControlBar = pData->hTopBar; ! return HORZ; ! } ! ! if (CanDockBar(pData->hRightBar, &rect)) ! { ! if (phControlBar) *phControlBar = pData->hRightBar; ! return VERT; ! } ! ! if (CanDockBar(pData->hBottomBar, &rect)) ! { ! if (phControlBar) *phControlBar = pData->hBottomBar; ! return HORZ; ! } ! ! return 0; ! } ! ! static void Move(DockContext *pCtxt, POINT pt) ! { ! POINT ptOffset; ! ! ptOffset.x = pt.x - pCtxt->ptLast.x; ! ptOffset.y = pt.y - pCtxt->ptLast.y; ! ! // offset all drag rects to new position ! OffsetRect(&pCtxt->rectDragHorz, ptOffset.x, ptOffset.y); ! OffsetRect(&pCtxt->rectFrameDragHorz, ptOffset.x, ptOffset.y); ! OffsetRect(&pCtxt->rectDragVert, ptOffset.x, ptOffset.y); ! OffsetRect(&pCtxt->rectFrameDragVert, ptOffset.x, ptOffset.y); ! pCtxt->ptLast = pt; ! ! // if control key is down don't dock ! pCtxt->dwOverDockStyle = pCtxt->bForceFrame ? 0 : CanDock(pCtxt, NULL); ! ! // update feedback ! DrawDockRect(pCtxt, FALSE); ! } ! ! static void OnKey(DockContext *pCtxt, int nChar, BOOL bDown) ! { ! switch (nChar) ! { ! case VK_CONTROL: ! if (pCtxt->bForceFrame == bDown) ! return; ! pCtxt->bForceFrame = bDown; ! break; ! case VK_SHIFT: ! if (pCtxt->bFlip == bDown) ! return; ! pCtxt->bFlip = bDown; ! break; ! default: ! return; ! } ! ! pCtxt->dwOverDockStyle = (pCtxt->bForceFrame) ? 0 : CanDock(pCtxt, NULL); ! DrawDockRect(pCtxt, FALSE); ! } ! ! static void EndDrag(DockContext *pCtxt) ! { ! RECT rect; ! HWND hToolBar; ! HWND hControlBar = NULL; ! LONG lStyle; ! char *szCaption; ! int nLen; ! ! hToolBar = pCtxt->hToolBar; ! lStyle = GetWindowLong(hToolBar, GWL_STYLE); ! ! CanDock(pCtxt, &hControlBar); ! ! // undock the toolbar ! UndockToolBar(GetParent(hToolBar), hToolBar); ! if (hControlBar) ! { ! if (pCtxt->dwOverDockStyle & HORZ) ! rect = pCtxt->rectDragHorz; ! else ! rect = pCtxt->rectDragVert; ! ! SetWindowLong(hToolBar, GWL_STYLE, lStyle & ~(VERT | HORZ | FLOAT) | pCtxt->dwOverDockStyle); ! ScreenToClient(hControlBar, ((POINT *) &rect)); ! ScreenToClient(hControlBar, ((POINT *) &rect)+1); ! ! // dock it at the specified position ! DockToolBarToRect(hControlBar, hToolBar, rect); ! } ! else ! { ! if (((pCtxt->dwDockStyle & HORZ) && !pCtxt->bFlip) || ((pCtxt->dwDockStyle & VERT) && pCtxt->bFlip)) ! rect = pCtxt->rectFrameDragHorz; ! else ! rect = pCtxt->rectFrameDragVert; ! ! SetWindowLong(hToolBar, GWL_STYLE, lStyle | FLOAT); ! ! szCaption = NULL; ! nLen = GetWindowTextLength(hToolBar); ! if (nLen > 0) ! { ! szCaption = malloc(nLen+1); ! if (!szCaption) ! szCaption = NULL; ! else ! GetWindowText(hToolBar,szCaption,nLen+1); ! } ! ! hControlBar = CreateWindowEx(WS_EX_TOOLWINDOW, ! "HCONTROLBAR", ! szCaption, ! WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_THICKFRAME, ! 0,0,0,0, ! ghWndFrame, ! NULL, ! (HANDLE) ghModule, ! NULL); ! SetParent(hToolBar, hControlBar); ! SetWindowPos(hControlBar, NULL, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER); ! ! free(szCaption); ! } ! RelayoutFrameBars(); ! } ! ! static void StartDrag(HWND hToolBar, POINT pos) ! { ! MSG msg; ! DockContext ctxt; ! ! // handle pending WM_PAINT messages ! while (PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT, PM_NOREMOVE)) ! { ! if (!GetMessage(&msg, NULL, WM_PAINT, WM_PAINT)) ! return; ! DispatchMessage(&msg); ! } ! ! if (!InitDockContext(hToolBar, pos, &ctxt)) ! return; ! ! // get messages until capture lost or cancelled/accepted ! while (GetCapture() == hToolBar) ! { ! if (!GetMessage(&msg, NULL, 0, 0)) ! { ! PostQuitMessage((int)msg.wParam); ! break; ! } ! ! switch (msg.message) ! { ! case WM_LBUTTONUP: ! EndDrag(&ctxt); ! goto end_loop; ! case WM_MOUSEMOVE: ! Move(&ctxt, msg.pt); ! break; ! case WM_KEYUP: ! OnKey(&ctxt, (int)msg.wParam, FALSE); ! break; ! case WM_KEYDOWN: ! OnKey(&ctxt, (int)msg.wParam, TRUE); ! if (msg.wParam == VK_ESCAPE) ! goto end_loop; ! break; ! case WM_RBUTTONDOWN: ! goto end_loop; ! ! // just dispatch rest of the messages ! default: ! DispatchMessage(&msg); ! break; ! } ! } ! ! end_loop: ! DrawDockRect(&ctxt, TRUE); ! ReleaseDockContext(&ctxt); ! } ! ! LRESULT CALLBACK HToolBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ! { ! LRESULT lResult = 0; ! LONG lStyle = GetWindowLong(hWnd, GWL_STYLE); ! ! switch (uMsg) ! { ! case WM_NCCALCSIZE: ! if ((lStyle & FLOAT) == 0) ! { ! NCCALCSIZE_PARAMS *lpncsp = (NCCALCSIZE_PARAMS *) lParam; ! ! lpncsp->rgrc[0].left += CX_BORDER*2; ! lpncsp->rgrc[0].top += CY_BORDER*2; ! lpncsp->rgrc[0].right -= CX_BORDER*2; ! lpncsp->rgrc[0].bottom -= CY_BORDER*2; ! ! if (lStyle & HORZ) ! lpncsp->rgrc[0].left += CX_BORDER_GRIPPER+CX_GRIPPER+CX_BORDER_GRIPPER; ! else ! if (lStyle & VERT) ! lpncsp->rgrc[0].top += CY_BORDER_GRIPPER+CY_GRIPPER+CY_BORDER_GRIPPER; ! ! return 0; ! }; ! break; ! case WM_NCHITTEST: ! { ! POINT pos; ! ! pos.x = GET_X_LPARAM(lParam); ! pos.y = GET_Y_LPARAM(lParam); ! ScreenToClient(hWnd, &pos); ! if (ToolHitTest(hWnd, pos)) ! return HTCLIENT; ! else ! return HTCAPTION; ! } ! break; ! case WM_NCPAINT: ! if ((lStyle & FLOAT) == 0) ! { ! HDC hDC; ! POINT pt; ! RECT rectClient, rectWindow, rect1, rect2; ! COLORREF clrBtnHilite, clrBtnShadow; ! ! clrBtnHilite = GetSysColor(COLOR_BTNHIGHLIGHT); ! clrBtnShadow = GetSysColor(COLOR_BTNSHADOW); ! ! // get window DC that is clipped to the non-client area ! hDC = GetWindowDC(hWnd); ! ! GetClientRect(hWnd, &rectClient); ! GetWindowRect(hWnd, &rectWindow); ! ! pt.x = rectWindow.left; ! pt.y = rectWindow.top; ! ScreenToClient(hWnd, &pt); ! ! rectClient.left -= pt.x; ! rectClient.top -= pt.y; ! rectClient.right -= pt.x; ! rectClient.bottom -= pt.y; ! ! ExcludeClipRect(hDC, rectClient.left, rectClient.top, rectClient.right, rectClient.bottom); ! ! rectWindow.right = rectWindow.right-rectWindow.left; ! rectWindow.bottom = rectWindow.bottom-rectWindow.top; ! rectWindow.left = 0; ! rectWindow.top = 0; ! ! rect1 = rectWindow; ! rect2 = rectWindow; ! ! rect1.right -= CX_BORDER; ! rect1.bottom -= CY_BORDER; ! rect2.top += CY_BORDER*2; ! rect2.bottom -= CY_BORDER*2; ! ! // draw left and top dark line ! FillSolidRect(hDC, 0, rect2.top, CX_BORDER, rect2.bottom-rect2.top, clrBtnShadow); ! FillSolidRect(hDC, 0, 0, rectWindow.right, CY_BORDER, clrBtnShadow); ! ! // draw right and bottom dark line ! FillSolidRect(hDC, rect1.right, rect2.top, -CX_BORDER, rect2.bottom-rect2.top, clrBtnShadow); ! FillSolidRect(hDC, 0, rect1.bottom, rectWindow.right, -CY_BORDER, clrBtnShadow); ! ! // draw left and top hilite lines ! FillSolidRect(hDC, 1, rect2.top, CX_BORDER, rect2.bottom-rect2.top, clrBtnHilite); ! FillSolidRect(hDC, 0, 1, rectWindow.right, CY_BORDER, clrBtnHilite); ! ! // draw right and bottom ! FillSolidRect(hDC, rectWindow.right, rect2.top, -CX_BORDER, rect2.bottom-rect2.top, clrBtnHilite); ! FillSolidRect(hDC, 0, rectWindow.bottom, rectWindow.right, -CY_BORDER, clrBtnHilite); ! ! rectWindow.left += CX_BORDER*2; ! rectWindow.top += CY_BORDER*2; ! rectWindow.right -= CX_BORDER*2; ! rectWindow.bottom -= CY_BORDER*2; ! ! IntersectClipRect(hDC, rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom); ! ! // erase parts not drawn ! SendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0); ! ! // draw the gripper in the border ! if (lStyle & HORZ) ! Draw3dRect(hDC,rectWindow.left+CX_BORDER_GRIPPER, ! rectWindow.top, ! CX_GRIPPER, rectWindow.bottom-rectWindow.top, ! clrBtnHilite, clrBtnShadow); ! else ! if (lStyle & VERT) ! Draw3dRect(hDC,rectWindow.left, ! rectWindow.top+CY_BORDER_GRIPPER, ! rectWindow.right-rectWindow.left, CY_GRIPPER, ! clrBtnHilite, clrBtnShadow); ! ! // release context ! ReleaseDC(hWnd, hDC); ! } ! break; ! case WM_NCLBUTTONDOWN: ! if (wParam == HTCAPTION) ! { ! POINT pos; ! ! pos.x = GET_X_LPARAM(lParam); ! pos.y = GET_Y_LPARAM(lParam); ! ScreenToClient(hWnd, &pos); ! StartDrag(hWnd, pos); ! } ! break; ! } ! ! lResult = CallWindowProc(DefToolBarProc, hWnd, uMsg, wParam, lParam); ! ! if (uMsg == WM_CREATE) ! { ! SendMessage (hWnd, TB_AUTOSIZE, (WPARAM)0, (LPARAM)0); ! SendMessage (hWnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), (LPARAM) 0); ! } ! ! return lResult; ! }; ! ! WindowHandle osCreateToolBar(char *name, DockPlace place, int band_num, int band_position, int offset) { HWND hControlBar, hWnd; FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); + LONG lStyle; switch (place) { ! case DockLeft: ! hControlBar = pFrameData->hLeftBar; ! lStyle = VERT; ! break; ! case DockTop: ! hControlBar = pFrameData->hTopBar; ! lStyle = HORZ; ! break; ! case DockRight: ! hControlBar = pFrameData->hRightBar; ! lStyle = VERT; ! break; ! case DockBottom: ! hControlBar = pFrameData->hBottomBar; ! lStyle = HORZ; ! break; ! default: ! return NULL; } ! hWnd = CreateWindow ("HTOOLBAR", ! name, ! WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS ! | CCS_NOPARENTALIGN | CCS_NOMOVEY ! | CCS_NODIVIDER | CCS_NORESIZE | TBSTYLE_WRAPABLE ! | TBSTYLE_TOOLTIPS | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT ! | lStyle, 0,0,0,0, hControlBar, (HMENU) NULL, (HANDLE) ghModule, ! NULL ); ! SetWindowText(hWnd, name); ! DockToolBar(hControlBar, hWnd, band_num, band_position, offset); return hWnd; } *************** *** 66,72 **** else SendMessage(toolBar, TB_ADDBUTTONS, 1, (LPARAM)&tbb); ! RelayoutFrameBars(); - return btn; } --- 804,809 ---- else SendMessage(toolBar, TB_ADDBUTTONS, 1, (LPARAM)&tbb); ! RelayoutFrameBars(); return btn; } *************** *** 81,84 **** --- 818,822 ---- TBBUTTON tbb; ToolHandle btn; + SIZE sz; btn = malloc(sizeof(struct ToolHandle)); *************** *** 101,104 **** --- 839,846 ---- SendMessage(toolBar, TB_ADDBUTTONS, 1, (LPARAM)&tbb); + SendMessage(toolBar, TB_GETMAXSIZE, 0, (LPARAM) &sz); + sz.cx += CX_BORDER*4; + sz.cy += CY_BORDER*4; + SetWindowPos(toolBar, NULL, 0, 0, sz.cx, sz.cy, SWP_NOMOVE | SWP_NOZORDER); RelayoutFrameBars(); Index: Util.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Util.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Util.c 12 Jul 2003 13:49:41 -0000 1.15 --- Util.c 10 Aug 2003 18:36:04 -0000 1.16 *************** *** 33,50 **** extern LRESULT CALLBACK HMDIWindowFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); extern LRESULT CALLBACK HDialogFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); ! static ATOM classDialog = 0; ! static ATOM classWindow = 0; ! ! /* ! BOOL isDialogHandle( HWND hWnd ) ! { ! WINDOWINFO info; ! memset(&info,0,sizeof(info)); ! info.cbSize = sizeof(info); ! GetWindowInfo( hWnd, &info ); ! return (info.atomWindowType == classDialog); ! } ! */ void osInit(char *appName, char *appVersion, int DocumentInterface) --- 33,40 ---- extern LRESULT CALLBACK HMDIWindowFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); extern LRESULT CALLBACK HDialogFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + extern LRESULT CALLBACK HControlBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + extern LRESULT CALLBACK HToolBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); ! extern WNDPROC DefToolBarProc; void osInit(char *appName, char *appVersion, int DocumentInterface) *************** *** 57,61 **** ghModule = GetModuleHandle(NULL); ! // Window class for SDIFrame wc.style = CS_DBLCLKS; wc.lpfnWndProc = HSDIFrameFunction; --- 47,51 ---- ghModule = GetModuleHandle(NULL); ! // SDIFrame class wc.style = CS_DBLCLKS; wc.lpfnWndProc = HSDIFrameFunction; *************** *** 70,73 **** --- 60,64 ---- RegisterClass(&wc); + // SDIWindow class wc.style = CS_DBLCLKS; wc.lpfnWndProc = HSDIWindowFunction; *************** *** 80,86 **** wc.lpszMenuName = NULL; wc.lpszClassName = "HSDIWINDOW"; ! classWindow = RegisterClass(&wc); ! // Window class for Dialogs wc.style = CS_DBLCLKS; wc.lpfnWndProc = HDialogFunction; --- 71,77 ---- wc.lpszMenuName = NULL; wc.lpszClassName = "HSDIWINDOW"; ! RegisterClass(&wc); ! // Dialog class wc.style = CS_DBLCLKS; wc.lpfnWndProc = HDialogFunction; *************** *** 93,99 **** wc.lpszMenuName = NULL; wc.lpszClassName = "HDIALOG"; ! classDialog = RegisterClass(&wc); ! // Window class for MDIFrame wc.style = CS_DBLCLKS; wc.lpfnWndProc = HMDIFrameFunction; --- 84,90 ---- wc.lpszMenuName = NULL; wc.lpszClassName = "HDIALOG"; ! RegisterClass(&wc); ! // MDIFrame class wc.style = CS_DBLCLKS; wc.lpfnWndProc = HMDIFrameFunction; *************** *** 108,112 **** RegisterClass(&wc); ! // Window class for MDIWindow wc.style = CS_DBLCLKS; wc.lpfnWndProc = HMDIWindowFunction; --- 99,103 ---- RegisterClass(&wc); ! // MDIWindow class wc.style = CS_DBLCLKS; wc.lpfnWndProc = HMDIWindowFunction; *************** *** 119,122 **** --- 110,134 ---- wc.lpszMenuName = NULL; wc.lpszClassName = "HMDIWINDOW"; + RegisterClass(&wc); + + // ControlBar class + wc.style = CS_DBLCLKS; + wc.lpfnWndProc = HControlBarFunction; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = ghModule; + wc.hIcon = NULL; + wc.hCursor = NULL; + wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE+1); + wc.lpszMenuName = NULL; + wc.lpszClassName = "HCONTROLBAR"; + RegisterClass(&wc); + + // ToolBar class (subclass of the standard ToolBar class) + GetClassInfo(ghModule, TOOLBARCLASSNAME, &wc); + DefToolBarProc = wc.lpfnWndProc; + wc.style = CS_DBLCLKS; + wc.lpfnWndProc = HToolBarFunction; + wc.lpszClassName = "HTOOLBAR"; RegisterClass(&wc); |