/*[]=====================================================================[]*/ /*[] 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" DISPALPHAACTIONPROPS AlphaProp; static L_BOOL AlphaWndProc_OnCommand (HWND hWnd, L_INT nID, HWND hWndCtl, L_UINT uCodeNotify); static L_BOOL AlphaWndProc_OnInitDialog (HWND hWnd, HWND hWndFocus, LPARAM lParam); L_BOOL CALLBACK AlphaWndProc (HWND hWnd, L_UINT uMessage, WPARAM wParam, LPARAM lParam) { switch(uMessage) { HANDLE_MSG (hWnd, WM_COMMAND, AlphaWndProc_OnCommand); HANDLE_MSG (hWnd, WM_INITDIALOG, AlphaWndProc_OnInitDialog); } return FALSE; } static L_BOOL AlphaWndProc_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); AlphaProp.DispContainerActionProps.uStructSize = sizeof(DISPALPHAACTIONPROPS); nIndex = SearchForFirstSelectedCell(hCon); nCellIndex = 0; nSubCellIndex = 0; nIndex = max(0, nIndex); L_DispContainerGetActionProperties(hCon, CONTAINER_ACTION_ALPHA, nIndex, 0, (LONG)&AlphaProp, CONTAINER_ACTION_CONTAINERLEVEL); L_DispContainerGetActionProperties(hCon, CONTAINER_ACTION_ALPHA, nIndex, 0, (LONG)&AlphaProp, 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_ALPHAACTION_FACTOR_EDT, AlphaProp.nFactor, 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_ACTION_SUBCELLINDEX_EDT), 0, nCount - 1, 1, 0, 0); SetNumericEditBox(GetDlgItem(hWnd, IDC_ALPHAACTION_FACTOR_EDT), -1000, 1000, 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_ALPHAACTION_FACTOR_EDT), bEnable); InitlizeVirtualKeyList(hWnd); AddSupString(GetDlgItem(hWnd, IDC_ACTION_MOD_COM)); AddVirtualKeyString(GetDlgItem(hWnd, IDC_ACTION_LEFTKEY_COM)); AddVirtualKeyString(GetDlgItem(hWnd, IDC_ACTION_RIGHTKEY_COM)); GetKeyboardAction(GetDlgItem(hWnd, IDC_ACTION_LEFTKEY_COM), CONTAINER_ACTION_ALPHA, CONTAINER_MOUSEMOVE_LEFT); GetKeyboardAction(GetDlgItem(hWnd, IDC_ACTION_RIGHTKEY_COM), CONTAINER_ACTION_ALPHA, CONTAINER_MOUSEMOVE_RIGHT); CheckKeyValidity(GetDlgItem(hWnd, IDC_ACTION_MOD_COM), 1); Button_SetCheck(GetDlgItem(hWnd, IDC_ACTION_CIRCLE_CHK), AlphaProp.DispContainerActionProps.bCircularMouseMove); SetDlgItemInt(hWnd, IDC_ACTION_SEN_EDT, AlphaProp.DispContainerActionProps.nChange, FALSE); SendMessage(GetDlgItem(hWnd, IDC_ACTION_CUR_BTN), BM_SETIMAGE , IMAGE_CURSOR, (LPARAM)(HCURSOR)AlphaProp.DispContainerActionProps.hCursor); hOldCursor = AlphaProp.DispContainerActionProps.hCursor; return TRUE; } static L_BOOL AlphaWndProc_OnCommand (HWND hWnd, L_INT nID, HWND hWndCtl, L_UINT uCodeNotify) { HDISPCONTAINER hCon = (HDISPCONTAINER)GetWindowLong(hWnd, GWL_USERDATA); L_INT nRet; HBITMAPLIST hBitmapList; L_INT nCount; switch(nID) { case IDC_ACTION_LEFTKEY_COM: case IDC_ACTION_RIGHTKEY_COM: CheckKeyValidity(GetDlgItem(hWnd, IDC_ACTION_MOD_COM), 1); 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_ALPHA, nCellIndex, nSubCellIndex, (LONG)&AlphaProp, CONTAINER_ACTION_CELLLEVEL); SetDlgItemInt(hWnd, IDC_ALPHAACTION_FACTOR_EDT, AlphaProp.nFactor, TRUE); L_DispContainerGetCellBitmapList(hCon, nCellIndex, &hBitmapList, 0); L_GetBitmapListCount(hBitmapList, &nCount); EditNumericEditBox(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_EDT), 0, nCount - 1, 1, 0, 0, EDT_MODFY_MAX | EDT_MODFY_MIN); break; case IDC_ACTION_SUBCELLINDEX_EDT: if (nSubCellIndex == (L_INT)GetDlgItemInt(hWnd, nID, NULL, TRUE)) break; nSubCellIndex = GetDlgItemInt(hWnd, nID, NULL, TRUE); L_DispContainerGetActionProperties(hCon, CONTAINER_ACTION_ALPHA, nCellIndex, nSubCellIndex, (LONG)&AlphaProp, CONTAINER_ACTION_CELLLEVEL); SetDlgItemInt(hWnd, IDC_ALPHAACTION_FACTOR_EDT, AlphaProp.nFactor, 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_ALPHAACTION_FACTOR_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, &AlphaProp.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))); AlphaProp.DispContainerActionProps.bCircularMouseMove = Button_GetCheck(GetDlgItem(hWnd, IDC_ACTION_CIRCLE_CHK)); AlphaProp.DispContainerActionProps.nChange = GetDlgItemInt(hWnd, IDC_ACTION_SEN_EDT, NULL, FALSE); L_DispContainerSetActionProperties(hCon, CONTAINER_ACTION_ALPHA, 0, 0, (LONG)&AlphaProp, CONTAINER_ACTION_CONTAINERLEVEL); nRet = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_ACTION_CELLINDEX_COM)); if (nRet) { L_INT nIndex; L_INT nSubIndex; AlphaProp.nFactor = GetDlgItemInt(hWnd, IDC_ALPHAACTION_FACTOR_EDT, NULL, TRUE); if (nRet == 1) nIndex = -1; else nIndex = GetDlgItemInt(hWnd, IDC_ACTION_CELLINDEX_EDT, NULL, TRUE); nRet = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_ACTION_SUBCELLINDEX_COM)); if (nRet == 0) nSubIndex = -1; else nSubIndex = GetDlgItemInt(hWnd, IDC_ACTION_SUBCELLINDEX_EDT, NULL, FALSE); L_DispContainerSetActionProperties(hCon, CONTAINER_ACTION_ALPHA, nIndex, nSubIndex, (LONG)&AlphaProp, CONTAINER_ACTION_CELLLEVEL); } nVk = GetVirtualKey(hWnd, GetDlgItem(hWnd, IDC_ACTION_LEFTKEY_COM)); L_DispContainerSetKeyboardAction(hCon, CONTAINER_ACTION_ALPHA, CONTAINER_MOUSEMOVE_LEFT, nVk, uState); nVk = GetVirtualKey(hWnd, GetDlgItem(hWnd, IDC_ACTION_RIGHTKEY_COM)); L_DispContainerSetKeyboardAction(hCon, CONTAINER_ACTION_ALPHA, CONTAINER_MOUSEMOVE_RIGHT, nVk, uState); if (nID == IDAPPLY) break; EndDialog(hWnd, 1); } break; case IDCANCEL: EndDialog(hWnd, 0); break; } return TRUE; }