/*[]=====================================================================[]*/ /*[] LeadTools Run Time Library - Version 14 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2004 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ /*------------------------------------------------------------------------- We have made the assumption that the user has the knowledge of programming in C and Windows. --------------------------------------------------------------------------*/ #include "ImgConVw.h" static L_BOOL OffsetWndProc_OnCommand (HWND hWnd, L_INT nID, HWND hWndCtl, L_UINT codeNotify); static L_BOOL OffsetWndProc_OnInitDialog (HWND hWnd, HWND hWndFocus, LPARAM lParam); DISPOFFSETACTIONPROPS OffsetProp; L_BOOL CALLBACK OffsetWndProc (HWND hWnd, L_UINT uMessage, WPARAM wParam, LPARAM lParam) { switch(uMessage) { HANDLE_MSG (hWnd, WM_COMMAND, OffsetWndProc_OnCommand); HANDLE_MSG (hWnd, WM_INITDIALOG, OffsetWndProc_OnInitDialog); } return FALSE; } static L_BOOL OffsetWndProc_OnCommand (HWND hWnd, L_INT nID, HWND hWndCtl, L_UINT codeNotify) { HDISPCONTAINER hCon = (HDISPCONTAINER)GetWindowLong(hWnd, GWL_USERDATA); L_INT nRet; switch(nID) { case IDC_ACTION_UPKEY_COM: case IDC_ACTION_LEFTKEY_COM: case IDC_ACTION_RIGHTKEY_COM: case IDC_ACTION_DOWNKEY_COM: CheckKeyValidity(GetDlgItem(hWnd, IDC_ACTION_MOD_COM), 2); break; case IDC_ACTION_CELLINDEX_EDT: if (nCellIndex == (L_INT)GetDlgItemInt(hWnd, nID, NULL, TRUE)) break; nCellIndex = GetDlgItemInt(hWnd, nID, NULL, TRUE); L_DispContainerGetActionProperties(hCon, CONTAINER_ACTION_OFFSET, nCellIndex, nSubCellIndex, (LONG)&OffsetProp, CONTAINER_ACTION_CELLLEVEL); SetDlgItemInt(hWnd, IDC_OFFSETACTION_X_EDT, OffsetProp.nXOffset, TRUE); SetDlgItemInt(hWnd, IDC_OFFSETACTION_Y_EDT, OffsetProp.nYOffset, TRUE); break; case IDC_ACTION_CELLINDEX_COM: nRet = ComboBox_GetCurSel(hWndCtl); EnableWindow(GetDlgItem(hWnd, IDC_ACTION_CELLINDEX_EDT), (nRet == 2)); EnableWindow(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_COM), (nRet != 0)); EnableWindow(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_EDT), (nRet != 0) && ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_COM)) ); EnableWindow(GetDlgItem(hWnd, IDC_OFFSETACTION_X_EDT), (nRet != 0)); EnableWindow(GetDlgItem(hWnd, IDC_OFFSETACTION_Y_EDT), (nRet != 0)); break; case IDC_ACTION_SUBCELLINDEX_COM: nRet = ComboBox_GetCurSel(hWndCtl); EnableWindow(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_EDT), (nRet == 1)); break; case IDC_ACTION_CUR_BTN: OpenCursorDialog(hWndCtl, &OffsetProp.DispContainerActionProps.hCursor); break; case IDAPPLY: case IDOK: { L_INT nVk; L_INT bShiftedRemoved = (ComboBox_GetCount(GetDlgItem(hWnd, IDC_ACTION_MOD_COM)) == 3); L_UINT uState = (8 >> (4 - ( ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_ACTION_MOD_COM)) + bShiftedRemoved))); OffsetProp.DispContainerActionProps.uStructSize = sizeof(DISPOFFSETACTIONPROPS); OffsetProp.DispContainerActionProps.bCircularMouseMove = Button_GetCheck(GetDlgItem(hWnd, IDC_ACTION_CIRCLE_CHK)); OffsetProp.DispContainerActionProps.nChange = GetDlgItemInt(hWnd, IDC_ACTION_SEN_EDT, NULL, TRUE); L_DispContainerSetActionProperties(hCon, CONTAINER_ACTION_OFFSET, 0, 0, (LONG)&OffsetProp, CONTAINER_ACTION_CONTAINERLEVEL); nRet = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_ACTION_CELLINDEX_COM)); if (nRet) { L_INT nIndex; OffsetProp.nXOffset = GetDlgItemInt(hWnd, IDC_OFFSETACTION_X_EDT, NULL, TRUE); OffsetProp.nYOffset = GetDlgItemInt(hWnd, IDC_OFFSETACTION_Y_EDT, NULL, TRUE); if (nRet == 1) nIndex = -1; else nIndex = GetDlgItemInt(hWnd, IDC_ACTION_CELLINDEX_EDT, NULL, TRUE); L_DispContainerSetActionProperties(hCon, CONTAINER_ACTION_OFFSET, nIndex, 0, (LONG)&OffsetProp, CONTAINER_ACTION_CELLLEVEL); } nVk = GetVirtualKey(hWnd, GetDlgItem(hWnd, IDC_ACTION_UPKEY_COM)); L_DispContainerSetKeyboardAction(hCon, CONTAINER_ACTION_OFFSET, CONTAINER_MOUSEMOVE_UP, nVk, uState); nVk = GetVirtualKey(hWnd, GetDlgItem(hWnd, IDC_ACTION_LEFTKEY_COM)); L_DispContainerSetKeyboardAction(hCon, CONTAINER_ACTION_OFFSET, CONTAINER_MOUSEMOVE_LEFT, nVk, uState); nVk = GetVirtualKey(hWnd, GetDlgItem(hWnd, IDC_ACTION_RIGHTKEY_COM)); L_DispContainerSetKeyboardAction(hCon, CONTAINER_ACTION_OFFSET, CONTAINER_MOUSEMOVE_RIGHT, nVk, uState); nVk = GetVirtualKey(hWnd, GetDlgItem(hWnd, IDC_ACTION_DOWNKEY_COM)); L_DispContainerSetKeyboardAction(hCon, CONTAINER_ACTION_OFFSET, CONTAINER_MOUSEMOVE_DOWN, nVk, uState); if (nID == IDAPPLY) break; EndDialog(hWnd, 1); } break; case IDCANCEL: EndDialog(hWnd, 0); break; } return TRUE; } static L_BOOL OffsetWndProc_OnInitDialog (HWND hWnd, HWND hWndFocus, LPARAM lParam) { HDISPCONTAINER hCon = (HDISPCONTAINER)lParam; L_BOOL bEnable = FALSE; L_INT nIndex; L_INT nCount; HBITMAPLIST hBitmapList; MoveDialogToMiddle(hWnd); SetWindowLong(hWnd, GWL_USERDATA, (long)lParam); nIndex = SearchForFirstSelectedCell(hCon); nCellIndex = 0; nSubCellIndex = 0; nIndex = max(0, nIndex); OffsetProp.DispContainerActionProps.uStructSize = sizeof(DISPOFFSETACTIONPROPS); L_DispContainerGetActionProperties(hCon, CONTAINER_ACTION_OFFSET, nIndex, 0, (LONG)&OffsetProp, CONTAINER_ACTION_CONTAINERLEVEL); L_DispContainerGetActionProperties(hCon, CONTAINER_ACTION_OFFSET, nIndex, 0, (LONG)&OffsetProp, CONTAINER_ACTION_CELLLEVEL); nCount = L_DispContainerGetCellCount(hCon, 0); SetDlgItemText(hWnd, IDC_ACTION_SUBCELLINDEX_EDT, TEXT("0")); SetDlgItemInt(hWnd, IDC_ACTION_CELLINDEX_EDT, nIndex, TRUE); SetDlgItemInt(hWnd, IDC_OFFSETACTION_X_EDT, OffsetProp.nXOffset, TRUE); SetDlgItemInt(hWnd, IDC_OFFSETACTION_Y_EDT, OffsetProp.nYOffset, TRUE); L_DispContainerGetCellBitmapList(hCon, nIndex, &hBitmapList, 0); SetNumericEditBox(GetDlgItem(hWnd, IDC_ACTION_CELLINDEX_EDT), 0, nCount - 1, 1, 0, 0); L_GetBitmapListCount(hBitmapList, &nCount); SetNumericEditBox(GetDlgItem(hWnd, IDC_OFFSETACTION_X_EDT), -1000000, 1000000, 1, 0, 0); SetNumericEditBox(GetDlgItem(hWnd, IDC_OFFSETACTION_Y_EDT), -1000000, 1000000, 1, 0, 0); ComboBox_AddString(GetDlgItem(hWnd, IDC_ACTION_CELLINDEX_COM), TEXT("None")); ComboBox_AddString(GetDlgItem(hWnd, IDC_ACTION_CELLINDEX_COM), TEXT("All")); ComboBox_AddString(GetDlgItem(hWnd, IDC_ACTION_CELLINDEX_COM), TEXT("Custom")); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_ACTION_CELLINDEX_COM), 0); ComboBox_AddString(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_COM), TEXT("All")); ComboBox_AddString(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_COM), TEXT("Custom")); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_COM), 0); nCount = L_DispContainerGetCellCount(hCon, 0); if (!nCount) { EnableWindow(GetDlgItem(hWnd, IDC_ACTION_CELLINDEX_COM), bEnable); EnableWindow(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_COM), bEnable); } EnableWindow(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_COM), bEnable); EnableWindow(GetDlgItem(hWnd, IDC_ACTION_CELLINDEX_EDT), bEnable); EnableWindow(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_EDT), bEnable); EnableWindow(GetDlgItem(hWnd, IDC_OFFSETACTION_X_EDT), bEnable); EnableWindow(GetDlgItem(hWnd, IDC_OFFSETACTION_Y_EDT), bEnable); InitlizeVirtualKeyList(hWnd); AddSupString(GetDlgItem(hWnd, IDC_ACTION_MOD_COM)); AddVirtualKeyString(GetDlgItem(hWnd, IDC_ACTION_UPKEY_COM)); AddVirtualKeyString(GetDlgItem(hWnd, IDC_ACTION_DOWNKEY_COM)); AddVirtualKeyString(GetDlgItem(hWnd, IDC_ACTION_LEFTKEY_COM)); AddVirtualKeyString(GetDlgItem(hWnd, IDC_ACTION_RIGHTKEY_COM)); GetKeyboardAction(GetDlgItem(hWnd, IDC_ACTION_UPKEY_COM), CONTAINER_ACTION_OFFSET, CONTAINER_MOUSEMOVE_UP); GetKeyboardAction(GetDlgItem(hWnd, IDC_ACTION_LEFTKEY_COM), CONTAINER_ACTION_OFFSET, CONTAINER_MOUSEMOVE_LEFT); GetKeyboardAction(GetDlgItem(hWnd, IDC_ACTION_RIGHTKEY_COM), CONTAINER_ACTION_OFFSET, CONTAINER_MOUSEMOVE_RIGHT); GetKeyboardAction(GetDlgItem(hWnd, IDC_ACTION_DOWNKEY_COM), CONTAINER_ACTION_OFFSET, CONTAINER_MOUSEMOVE_DOWN); CheckKeyValidity(GetDlgItem(hWnd, IDC_ACTION_MOD_COM), 2); Button_SetCheck(GetDlgItem(hWnd, IDC_ACTION_CIRCLE_CHK), OffsetProp.DispContainerActionProps.bCircularMouseMove); SetDlgItemInt(hWnd, IDC_ACTION_SEN_EDT, OffsetProp.DispContainerActionProps.nChange, FALSE); SendMessage(GetDlgItem(hWnd, IDC_ACTION_CUR_BTN), BM_SETIMAGE , IMAGE_CURSOR, (LPARAM)(HCURSOR)OffsetProp.DispContainerActionProps.hCursor); hOldCursor = OffsetProp.DispContainerActionProps.hCursor; return TRUE; }