⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 freeotfeguilib.c

📁 文件驱动加密,功能强大,可产生加密分区,支持AES,MD2,MD4,MD5MD2, MD4, MD5, RIPEMD-128, RIPEMD-160, SHA-1, SHA-224, SHA-256,
💻 C
📖 第 1 页 / 共 2 页
字号:
                               hWndMenu, 
                               SHCMBM_GETMENU, 
                               (WPARAM)0,
                               (LPARAM)0
                              ); 

    MenuItemRemoveMenu(hMenu, cmdID);

    DrawMenuBar(hWndMenu);
}


// =========================================================================
// Remove a menu item
// Returns: TRUE/FALSE on success/failure
void MenuItemRemoveMenu(
                   HMENU hMenu, 
                   UINT cmdID
)
{
    RemoveMenu(hMenu, cmdID, MF_BYCOMMAND); 
}


// =========================================================================
// Adjust spin control, checking bounds
void AdjustSpinControl(
                    HWND hDlg,
                    int nIDDlgItem,
                    int iMin,
                    int iMax,
                    int iDelta
                   )
{
    int iValue;

    iValue = GetDlgItemInt(hDlg, nIDDlgItem, NULL, TRUE);
    iValue = iValue + iDelta;
    if (iValue < iMin)
       {
       iValue = iMin;
       }
    else if (iValue > iMax)
       {
       iValue = iMax;
       }
    SetDlgItemInt(hDlg, nIDDlgItem, iValue, TRUE);

}


// =========================================================================
// Returns NULL on failure. Mallocs and returns pointer to char* password
// Note: It it is the *callers* responsibility to free of the returned string
char* GetPassword(
    HWND hDlg, 
    UINT ctrlID
)
{
    WCHAR* pwWS;
    int pwWSSize;
    int userPasswordSize;
    int pwLen;
    char* userPassword;

    pwLen = GetWindowTextLength(GetDlgItem(hDlg, ctrlID));
        
    // +1 for terminating NULL
    pwWSSize = (pwLen + 1) * sizeof(*pwWS);
    userPasswordSize = (pwLen + 1) * sizeof(*userPassword);
    pwWS = malloc(pwWSSize);
    userPassword = malloc(userPasswordSize);

    if (
        (pwWS == NULL) ||
        (userPassword == NULL) 
       )
        {
        MsgOutOfMemory(hDlg);
        SecZeroAndFreeMemory(userPassword, userPasswordSize);
        userPassword = NULL;
        }
    else
        {
        memset(pwWS, 0, pwWSSize);
        memset(userPassword, 0, userPasswordSize);
        GetDlgItemText( 
                       hDlg, 
                       ctrlID,
                       pwWS,
                       pwWSSize
                     ); 
        wcstombs(userPassword, pwWS, wcslen(pwWS));
        }

    SecZeroAndFreeMemory(pwWS, pwWSSize);

    return userPassword;
}


// =========================================================================
void
SetDlgItemString(
    HINSTANCE hInstance,
    HWND hWnd,
    int ctrlID,
    int stringID
)
{
    WCHAR* str;

    str = GetString(hInstance, stringID);
    if (str != NULL)
        {
        SetDlgItemText(hWnd, ctrlID, str);
        free(str);
        }

}

// =========================================================================
// Obtain string resource
// Note: It is the *callers* responsibility to free off the string returned
// Returns NULL on failure
WCHAR* GetString(HINSTANCE hInstance, int stringID)
{
    WCHAR* retval;
    WCHAR* tmpStr;
    WORD strLen;

    retval = NULL;

    tmpStr = (WCHAR*)LoadString(hInstance, stringID, NULL, 0);
    if (tmpStr != NULL)
        {
        strLen = ((WORD*)tmpStr)[-1];

        tmpStr = calloc((strLen + 1), sizeof(*tmpStr));
        if (tmpStr != NULL)
            {
            if (LoadString(hInstance, stringID, tmpStr, (strLen + 1)) == strLen)
                {
                retval = tmpStr;
                }
            else
                {
                free(tmpStr);
                }
            }
        }

    return retval;
}


// =========================================================================
void
SetControlVisible(
    HWND ParentWindow,
    int CtrlID,
    BOOL Visible
)
{
    HWND tmpHWND;

    tmpHWND = GetDlgItem(ParentWindow, CtrlID);
    if (tmpHWND != NULL)
        {
        if (Visible)
            {
            ShowWindow(tmpHWND, SW_SHOW);
            }
        else
            {
            ShowWindow(tmpHWND, SW_HIDE);
            }
        }
}


// =========================================================================
BOOL
IsControlVisible(
    HWND ParentWindow,
    int CtrlID
)
{
    BOOL retval = FALSE;
    HWND tmpHWND;

    tmpHWND = GetDlgItem(ParentWindow, CtrlID);
    if (tmpHWND != NULL)
        {
        retval = IsWindowVisible(tmpHWND);
        }

    return retval;
}


// =========================================================================
void
SetControlEnabled(
    HWND ParentWindow,
    int CtrlID,
    BOOL Enabled
)
{
    HWND tmpHWND;

    tmpHWND = GetDlgItem(ParentWindow, CtrlID);
    if (tmpHWND != NULL)
        {
        EnableWindow(tmpHWND, Enabled);
        }
}


// =========================================================================
BOOL
IsControlEnabled(
    HWND ParentWindow,
    int CtrlID
)
{
    BOOL retval = FALSE;
    HWND tmpHWND;

    tmpHWND = GetDlgItem(ParentWindow, CtrlID);
    if (tmpHWND != NULL)
        {
        retval = IsWindowEnabled(tmpHWND);
        }

    return retval;
}


// =========================================================================
void
SetControlReadonly(
    HWND ParentWindow,
    int CtrlID,
    BOOL Readonly
)
{
    HWND tmpHWND;

    tmpHWND = GetDlgItem(ParentWindow, CtrlID);
    if (tmpHWND != NULL)
        {
        SendMessage(tmpHWND, EM_SETREADONLY, Readonly, 0);
        }
}


// =========================================================================
void SizeControlMaxDepth(
    HWND hDlg,
    int ctrlID
)
{
    RECT rcParent;
    RECT rcClient;
    HWND hWndTmp;
    POINT pnt;

    if (GetClientRect(hDlg, &rcParent))
        {
        hWndTmp = GetDlgItem(hDlg, ctrlID); 
        if (hWndTmp != NULL)
            {
            if (GetWindowRect(hWndTmp, &rcClient))
                {
                pnt.x = rcClient.left;
                pnt.y = rcClient.top;
                ScreenToClient(hDlg, &pnt);
                rcClient.left = pnt.x;
                rcClient.top = pnt.y;

                pnt.x = rcClient.right;
                pnt.y = rcClient.bottom;
                ScreenToClient(hDlg, &pnt);
                rcClient.right = pnt.x;
                rcClient.bottom = pnt.y;

                SetWindowPos(
                             hWndTmp, 
                             NULL, 
                             rcClient.left, 
                             rcClient.top, 
                             (rcClient.right - rcClient.left),
                             (rcParent.bottom - rcClient.top), 
                             SWP_NOZORDER
                            );
                }
            }
        }
}


// =========================================================================
void SizeControlMaxWidth(
    HWND hDlg,
    int ctrlID
)
{
    SizeControlMaxWidthBorder(hDlg, ctrlID, 0);
}


// =========================================================================
void SizeControlMaxWidthBorder(
    HWND hDlg,
    int ctrlID,
    int Border
)
{
    RECT rcParent;
    RECT rcClient;
    HWND hWndTmp;
    POINT pnt;

    if (GetClientRect(hDlg, &rcParent))
        {
        hWndTmp = GetDlgItem(hDlg, ctrlID); 
        if (hWndTmp != NULL)
            {
            if (GetWindowRect(hWndTmp, &rcClient))
                {
                pnt.x = rcClient.left;
                pnt.y = rcClient.top;
                ScreenToClient(hDlg, &pnt);
                rcClient.left = pnt.x;
                rcClient.top = pnt.y;

                pnt.x = rcClient.right;
                pnt.y = rcClient.bottom;
                ScreenToClient(hDlg, &pnt);
                rcClient.right = pnt.x;
                rcClient.bottom = pnt.y;

                SetWindowPos(
                             hWndTmp, 
                             NULL, 
                             Border, 
                             rcClient.top, 
                             (rcParent.right - (Border * 2)),
                             (rcClient.bottom - rcClient.top), 
                             SWP_NOZORDER
                            );
                }
            }
        }

}


// =========================================================================
void SizeChildWindowParent(
    HWND hChildWnd
)
{
    HWND hParentWnd;
    
    if (hChildWnd != NULL)
        {
        hParentWnd = GetParent(hChildWnd); 
        SizeWindowToWindowClient(hParentWnd, hChildWnd);
        }

}


// =========================================================================
void SizeControlToParent(
    HWND hDlg,
    int ctrlID
)
{
    HWND hWndTmp;
    
    hWndTmp = GetDlgItem(hDlg, ctrlID); 
    if (hWndTmp != NULL)
        {
        SizeChildWindowParent(hWndTmp);
        }
}


// =========================================================================
void SizeWindowToWindowClient(
    HWND BaseWindow,
    HWND ResizeWindow
)
{
    RECT rcParent;
    
    if (
        (ResizeWindow != NULL) &&
        (BaseWindow != NULL)
       )
        {
        if (GetClientRect(BaseWindow, &rcParent))
            {
            SetWindowPos(
                         ResizeWindow, 
                         NULL, 
                         rcParent.left, 
                         rcParent.top, 
                         (rcParent.right - rcParent.left),
                         (rcParent.bottom - rcParent.top), 
                         SWP_NOZORDER
                        );
            }
        }

}


// =========================================================================
void SizeWindowToOverlapWindow(
    HWND BaseWindow,
    HWND ResizeWindow
)
{
    RECT rcBase;
    POINT pnt;

    if (GetWindowRect(BaseWindow, &rcBase))
        {
        pnt.x = rcBase.left;
        pnt.y = rcBase.top;
        ScreenToClient(ResizeWindow, &pnt);
        rcBase.left = pnt.x;
        rcBase.top = pnt.y;

        pnt.x = rcBase.right;
        pnt.y = rcBase.bottom;
        ScreenToClient(ResizeWindow, &pnt);
        rcBase.right = pnt.x;
        rcBase.bottom = pnt.y;

        SetWindowPos(
                     ResizeWindow, 
                     NULL, 
                     rcBase.left, 
                     rcBase.top, 
                     (rcBase.right - rcBase.left),
                     (rcBase.bottom - rcBase.top), 
                     SWP_NOZORDER
                    );
        }

}


// =========================================================================
// =========================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -