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

📄 about.cpp

📁 早期的WINDOWS编程,适合刚接触WINDOWS编程的初学者
💻 CPP
字号:
//
//Function and data definition for about module
//
//From the OLE Developer's Guide
//Lawrence Harris
//SAMS Publishing
//

#include "stdhdrs.h"
#include "common.h"
#include "resource.h"
#include "about.h"
#include "tcpclient.h"

//Display the about box and wait for user to close it
//
//This routine is modified from a Microsoft 32bit Generic application
//
LRESULT CALLBACK About(
                HWND hDlg,           // window handle of the dialog box
                UINT message,        // type of message
                WPARAM wParam,       // message-specific information
                LPARAM lParam)
{
        switch (message) {
        HANDLE_MSG(hDlg,WM_INITDIALOG,About_OnInitDialog);
        HANDLE_MSG(hDlg,WM_COMMAND,About_OnCommand);
        }
        return (FALSE); // Didn't process the message
}

//Message cracker OnInitDialog which is for WM_INITDIALOG
//
//This routine is used to handle the initialization of the dialog box
//
BOOL    About_OnInitDialog(HWND hDlg, HWND /* hWndFocus */, LPARAM /*lParam */)
{
        LPSTR   lpVersion;
        DWORD   dwVerInfoSize;
        DWORD   dwVerHnd;
        UINT    uVersionLen;
        WORD    wRootLen;
        BOOL    bRetCode;
        int     i;
        TCHAR   szFullPath[256];
        TCHAR   szResult[256];
        TCHAR   szGetName[256];

        // Center the dialog over the application window
        CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));

        if (TCPClientAppObject.TCPClientAppType.IsWindowsNT())
            LoadString(TCPClientAppObject.hInstApp,IDS_WINTYPE_NT,szResult,sizeof(szResult));
        else if (TCPClientAppObject.TCPClientAppType.IsWindows9x())
            LoadString(TCPClientAppObject.hInstApp,IDS_WINTYPE_9X,szResult,sizeof(szResult));
        else if (TCPClientAppObject.TCPClientAppType.IsWindows32s())
            LoadString(TCPClientAppObject.hInstApp,IDS_WINTYPE_32S,szResult,sizeof(szResult));
        else if (TCPClientAppObject.TCPClientAppType.IsWindows16())
            LoadString(TCPClientAppObject.hInstApp,IDS_WINTYPE_16,szResult,sizeof(szResult));
        else
            LoadString(TCPClientAppObject.hInstApp,IDS_WINTYPE_XX,szResult,sizeof(szResult));
        SetDlgItemText(hDlg, IDC_WINDOWSTYPE, szResult);


        // Get version information from the application
        GetModuleFileName (TCPClientAppObject.hInstApp, szFullPath, sizeof(szFullPath));
        dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
        if (dwVerInfoSize) {
                // If we were able to get the information, process it:
                LPSTR   lpstrVffInfo;
                HANDLE  hMem;
                hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
                lpstrVffInfo  = (char *)GlobalLock(hMem);
                GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpstrVffInfo);
                lstrcpy(szGetName, TEXT("\\StringFileInfo\\040904e4\\"));
                wRootLen = lstrlen(szGetName);

                // Walk through the dialog items that we want to replace:
                for (i = IDC_FILEDESCRIPTION; i <= IDC_LEGALTRADEMARKS; i++) {
                            GetDlgItemText(hDlg, i, szResult, sizeof(szResult));
                            szGetName[wRootLen] = (char)0;
                            lstrcat (szGetName, szResult);
                            uVersionLen   = 0;
                            lpVersion     = NULL;
                            bRetCode      =  VerQueryValue((LPVOID)lpstrVffInfo,
                                (LPSTR)szGetName,
                                (LPVOID *)&lpVersion,
                                (PUINT)&uVersionLen); // For MIPS strictness

                            if ( bRetCode && uVersionLen && lpVersion) {
                                // Replace dialog item text with version info
                                lstrcpy(szResult, lpVersion);
                                SetDlgItemText(hDlg, i, szResult);
                            }
                }

                GlobalUnlock(hMem);
                GlobalFree(hMem);
        } // if (dwVerInfoSize)
    return TRUE;
}

//Message cracker OnCommand which is for WM_COMMAND
//
//This routine is used to handle the about dialog box
//
void    About_OnCommand(HWND hDlg,int wmID, HWND /* hWndCtl */, UINT /*wmEvent*/)
{
       if (wmID == IDOK || wmID == IDCANCEL)
         EndDialog(hDlg, TRUE);
}

⌨️ 快捷键说明

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