void ViewFilesDialog::ShiftControls(int deltaX, int deltaY) { HDWP hdwp; /* * Use deferred reposn so that they don't end up drawing on top of each * other and getting all weird. * * IMPORTANT: the DeferWindowPos stuff changes the tab order of the * items in the window. The controls must be added in the reverse * order in which they appear in the window. */ hdwp = BeginDeferWindowPos(15); hdwp = MoveControl(hdwp, this, AFX_IDW_SIZE_BOX, deltaX, deltaY); hdwp = MoveControl(hdwp, this, IDHELP, deltaX, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_FONT, deltaX, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_PRINT, deltaX, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_FIND, deltaX, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_FMT_RAW, 0, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_FMT_HEX, 0, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_FMT_BEST, 0, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_PREV, 0, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_NEXT, 0, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_CMMT, 0, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_RSRC, 0, deltaY); hdwp = MoveControl(hdwp, this, IDC_FVIEW_DATA, 0, deltaY); hdwp = MoveStretchControl(hdwp, this, IDC_FVIEW_FORMATSEL, 0, deltaY, deltaX, 0); hdwp = StretchControl(hdwp, this, IDC_FVIEW_EDITBOX, deltaX, deltaY); hdwp = MoveControl(hdwp, this, IDOK, deltaX, deltaY); if (!EndDeferWindowPos(hdwp)) { LOGI("EndDeferWindowPos failed"); } /* * Work around buggy CRichEdit controls. The inner edit area is only * resized when the box is shrunk, not when it's expanded, and the * results are inconsistent between Win98 and Win2K. * * Set the internal size equal to the size of the entire edit box. * This should be large enough to make everything work right, but small * enough to avoid funky scrolling behavior. (If you want to set this * more precisely, don't forget that scroll bars are not part of the * edit control client area, and their sizes must be factored in.) */ CRect rect; CRichEditCtrl* pEdit = (CRichEditCtrl*) GetDlgItem(IDC_FVIEW_EDITBOX); ASSERT(pEdit != NULL); //pEdit->GetClientRect(&rect); pEdit->GetWindowRect(&rect); //GetClientRect(&rect); rect.left = 2; rect.top = 2; pEdit->SetRect(&rect); }
WINDOWPROC MainWndProc( HWND hwnd, UINT msg, WPARAM wParam, LONG lParam) { switch (msg) { case WM_CREATE: { RECT rc; /* * Create the status window. */ CreateDialog(ghInst, MAKEINTRESOURCE(DID_STATUS), hwnd, StatusDlgProc); /* * Save away its height for sizing later (like when * the app is minimized then restored). */ GetWindowRect(hwndStatus, &rc); gcyStatus = rc.bottom - rc.top; ghwndSubClient = CreateWindow(szSubClientClass, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwnd, NULL, ghInst, NULL); ghMenuMain = GetMenu(hwnd); LoadMenuBitmaps(ghMenuMain); } break; case WM_ACTIVATE: /* * If the main window is getting activated, there is no * currently active dialog. */ if (GET_WM_ACTIVATE_STATE(wParam, lParam)) gidCurrentDlg = 0; goto DoDefault; case WM_INITMENU: if (GetMenu(ghwndMain) == (HMENU)wParam) InitMenu((HMENU)wParam); break; case WM_MENUSELECT: if (GET_WM_MENUSELECT_FLAGS(wParam, lParam) & (MF_POPUP | MF_SYSMENU)) gMenuSelected = 0; else gMenuSelected = GET_WM_MENUSELECT_CMD(wParam, lParam); break; case WM_COMMAND: DialogMenu(GET_WM_COMMAND_ID(wParam, lParam)); break; case WM_KEYDOWN: switch (wParam) { case VK_UP: case VK_DOWN: case VK_LEFT: case VK_RIGHT: if ((GetKeyState(VK_SHIFT) & 0x8000) || (GetKeyState(VK_CONTROL) & 0x8000)) break; /* * Ignore it if we are not in a normal state * (don't allow when dragging). */ if (gState != STATE_NORMAL) break; /* * Be sure any outstanding changes get applied * without errors. */ if (!StatusApplyChanges()) break; /* * Move the control in the specified direction. */ MoveControl(wParam); break; case VK_TAB: if (GetKeyState(VK_CONTROL) & 0x8000) break; /* * Ignore it if we are not in a normal state * (don't allow when dragging). */ if (gState != STATE_NORMAL) break; /* * Be sure any outstanding changes get applied * without errors. */ if (!StatusApplyChanges()) break; /* * Is the shift key pressed also? */ if (GetKeyState(VK_SHIFT) & 0x8000) SelectPrevious(); else SelectNext(); break; case VK_ESCAPE: if ((GetKeyState(VK_SHIFT) & 0x8000) || (GetKeyState(VK_CONTROL) & 0x8000)) break; /* * Be sure any outstanding changes get applied * without errors. */ if (!StatusApplyChanges()) break; if (gState == STATE_SELECTING) OutlineSelectCancel(); /* * Cancel any drag operation they might have been doing. */ if (gState != STATE_NORMAL) DragCancel(); break; case VK_RETURN: if ((GetKeyState(VK_SHIFT) & 0x8000) || (GetKeyState(VK_CONTROL) & 0x8000)) break; /* * Be sure any outstanding changes get applied * without errors. */ if (!StatusApplyChanges()) break; switch (gState) { MPOINT mpt; POINT pt; DWORD dwPos; case STATE_SELECTING: /* * In outline selection mode. Map the * location of the mouse at the time that * the user pressed Enter into a point * relative to the dialog client and complete * the selection operation. */ dwPos = GetMessagePos(); mpt = MAKEMPOINT(dwPos); MPOINT2POINT(mpt, pt); ScreenToClient(gcd.npc->hwnd, &pt); OutlineSelectEnd(pt.x, pt.y); break; case STATE_DRAGGING: case STATE_DRAGGINGNEW: /* * We are dragging something. Map the * location of the mouse at the time * that the user pressed Enter into a * point relative to the proper window * and complete the drag operation. */ dwPos = GetMessagePos(); mpt = MAKEMPOINT(dwPos); MPOINT2POINT(mpt, pt); /* * The point must be changed to be relative to * the window that the ending mouse up message * would have come through, which will be the * capture window for the drag. This will be * the dialog if we are adding a new control, * or it will be the selected control if we are * dragging an existing control. */ ScreenToClient((gState == STATE_DRAGGING) ? gnpcSel->hwnd : gcd.npc->hwnd, &pt); /* * If the dialog is selected, map the points from * the client area to the window. */ if (gfDlgSelected) MapDlgClientPoint(&pt, TRUE); DragEnd(pt.x, pt.y); break; } break; } break; case WM_NCCALCSIZE: /* * Save away what is going to be the new window position. */ if (!IsIconic(hwnd) && !IsZoomed(hwnd)) grcAppPos = *((LPRECT)lParam); /* * Now let the DefWindowProc calculate the client area normally. */ goto DoDefault; case WM_MOVE: if (gfEditingDlg) RepositionDialog(); break; case WM_SIZE: SizeRibbons(hwnd); /* * Did the app start minimized and is it being restored * for the first time? If so, show the toolbox if * the user has requested it. */ if (fStartAsIcon && !IsIconic(hwnd)) { if (gfShowToolbox) ToolboxShow(TRUE); fStartAsIcon = FALSE; } break; case WM_SYSCOLORCHANGE: LoadSysColorBitmaps(); break; case WM_CLOSE: if (ghwndTestDlg) DestroyTestDialog(); if (DoWeSave(FILE_INCLUDE) == IDCANCEL || DoWeSave(FILE_RESOURCE) == IDCANCEL) break; /* * First destroy the Properties Bar. */ DestroyWindow(hwndStatus); hwndStatus = NULL; DestroyWindow(hwnd); break; case WM_QUERYENDSESSION: if (ghwndTestDlg) DestroyTestDialog(); if (DoWeSave(FILE_INCLUDE) == IDCANCEL || DoWeSave(FILE_RESOURCE) == IDCANCEL) return FALSE; else return TRUE; case WM_DESTROY: /* * Save the position of the app's window. */ WriteWindowPos(&grcAppPos, IsZoomed(hwnd), szAppPos); WinHelp(hwnd, gszHelpFile, HELP_QUIT, 0L); FreeMenuBitmaps(); PostQuitMessage(0); break; default: /* * Is this the registered help message from one of the common * dialogs? If so, show the help for it. * * The check to be sure gmsgHelp is non-zero is just in * case the call to register the help message failed * (it will return zero) and there happens to be a zero * message that gets sent to this window somehow. */ if (msg == gmsgHelp && gmsgHelp) { ShowHelp(FALSE); return 0; } DoDefault: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
CWindowPtr createdirwindow (CInfoPBRec *dir, Rect *r, char **path, short volume) { CWindowPeek wp; short i; OSErr e; Str255 s; opendirinfo **infoh; ControlHandle c; if (executor_p ()) { CInfoPBRec cpb; OSErr e2; cpb = *dir; e2 = unixmount (&cpb); if (e2 == noErr) volume = cpb.hFileInfo.ioVRefNum; } tail (*path, s); wp = (CWindowPeek) NewPtr (sizeof (CWindowRecord)); wp = (CWindowPeek) NewCWindow (wp, r, s, false, documentProc, (WindowPtr) 0, true, 0); wp->refCon = (long) NewHandle (sizeof (opendirinfo)); infoh = (opendirinfo **) wp->refCon; #if 1 /* This handle should be unlocked later, but it isn't for Executor 1.99m */ HLock ((Handle) infoh); #endif /* 0 */ (*infoh)->sortorder = ALPHABETIC; (*infoh)->items = (ControlHandle (**)[]) NewHandle (BANDARRAYSIZE * sizeof (ControlHandle)); (*infoh)->path = path; (*infoh)->iodirid = dir->dirInfo.ioDrDirID; (*infoh)->vrefnum = volume; (*infoh)->numitems = 0; (*infoh)->view = ICONVIEW; /* NOTE: r is the wrong rectangle, but it gets fixed before it's used. */ (*infoh)->sbar = NewControl ((WindowPtr) wp, r, (StringPtr) "\p", false, 0, 0, 0, scrollBarProc, 0); MoveControl ((*infoh)->sbar, wp->port.portRect.right - SCROLLBARWIDTH, 0); dir->hFileInfo.ioNamePtr = s; dir->hFileInfo.ioVRefNum = volume; e = noErr; for (i = 1; e == noErr; i++) { checkgrowitemarray (i, (*infoh)->items); dir->hFileInfo.ioDirID = (*infoh)->iodirid; dir->hFileInfo.ioFDirIndex = i; e = PBGetCatInfo (dir, false); if (e == noErr && !(dir->hFileInfo.ioFlFndrInfo.fdFlags & fInvisible)) { c = addtolist ((WindowPeek) wp, s, dir->hFileInfo.ioFlParID, volume); if (dir->hFileInfo.ioFlFndrInfo.fdType == 'APPL' || dir->hFileInfo.ioFlFndrInfo.fdType == 'dfil') hashicons (c); } } setwindowicons (wp); straightenwindow ((WindowPtr) wp); return (CWindowPtr) wp; }