真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

WIN32一些文件及窗口操作-創(chuàng)新互聯(lián)

0,獲取指定的系統(tǒng)路徑:WIN32一些文件及窗口操作

    #include
    #pragma comment(lib, "shell32.lib")

創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),新泰企業(yè)網(wǎng)站建設(shè),新泰品牌網(wǎng)站建設(shè),網(wǎng)站定制,新泰網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,新泰網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

    TCHAR szPath[MAX_PATH];
  ::SHGetSpecialFolderPath(NULL, szPath, CSIDL_PERSONAL, FALSE);

1,打開文件或選中文件:

BOOL OpenDownFile(const TCHAR* pFilePath, BOOL bOpenCatalogue)
{
    std::wstring wstrPath;
    if (bOpenCatalogue)
    {
        wstrPath.append(L"/n,/select,");
        //打開文件所在目錄,選中指定文件
    }

    wstrPath.append(pFilePath);//沒有/n,/select,參數(shù)的話是直接打開指定文件或目錄
  ShellExecute(NULL, L"open", L"Explorer.exe", wstrPath.c_str(), NULL, SW_SHOWDEFAULT);

    return TRUE;
}

2,文件另存為:
BOOL SaveFileAs(const HWND hWnd, const TCHAR* pDefaultFileName)
{
    std::wstring FileSavePath;
    std::wstring fileNameAll;
    std::wstring wstrPostfix;

    fileNameAll = pDefaultFileName;
    size_t ipoint = fileNameAll.rfind(L".");
    if(ipoint == fileNameAll.npos)//無后綴名
    {
        wstrPostfix.clear();
    }
    else
    {
        wstrPostfix = fileNameAll.substr(ipoint+1);
    }

    TCHAR filename[MAX_PATH] = {0};
  TCHAR pstrFilter[MAX_PATH] = {0};
  wsprintf(pstrFilter,L"%s Files(*.%s)|*.%s|All Files(*.*)|*.*||",wstrPostfix.c_str(),wstrPostfix.c_str(),wstrPostfix.c_str());

    OPENFILENAME ofn;
    ZeroMemory(&ofn, sizeof(ofn));
  wcscpy_s(filename,_countof(filename),fileNameAll.c_str());
  ofn.lpstrFile        = filename;
    ofn.nMaxFile        = MAX_PATH;
    ofn.lpstrFilter        = L"*.*";
    ofn.lpstrDefExt        = wstrPostfix.c_str();
    ofn.lpstrTitle        = L"另存為";
    ofn.Flags        = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
    ofn.FlagsEx     = OFN_EX_NOPLACESBAR;
    ofn.lStructSize        = sizeof(OPENFILENAME);
    ofn.hwndOwner        = hWnd;
    ofn.hInstance        = NULL;

    if (::GetSaveFileName(&ofn))
    {
        FileSavePath = filename;
    }
    else
    {
        return FALSE;
    }

    return TRUE;
}

3,選擇文件
#include
BOOL SelectFile(std::wstring& strSelectFile )
{
    OPENFILENAME opfn;
    TCHAR strFilename[MAX_PATH];
    ZeroMemory(&opfn, sizeof(OPENFILENAME));
    opfn.lStructSize = sizeof(OPENFILENAME);
    opfn.lpstrFilter = L"pdf Files(*.pdf) *.pdf";//設(shè)置過濾
    opfn.nFilterIndex = 1;
   opfn.lpstrFile = strFilename;
    opfn.lpstrFile[0] = '';
    opfn.nMaxFile = sizeof(strFilename);
    opfn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
    if (::GetOpenFileName(&opfn))
    {
        strSelectFile = strFilename;
    }
    return TRUE;
}

4,文件拖拽

DragAcceptFiles(hWnd, TRUE);

case WM_DROPFILES:
{
  HDROP hDrop = (HDROP)wParam;
  TCHAR szFileName[MAX_PATH];
  int count = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
  if(count)
  {
    for(int i=0; i        {
      int pathLen = DragQueryFile(hDrop, i, szFileName,MAX_PATH);
      //Do(szFileName); 

    }
   }
}

 break;

5,透明窗口

SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(m_hwnd, GWL_EXSTYLE) ^ 0x80000);
HINSTANCE hInst = LoadLibrary(L"User32.DLL"); 
if (hInst)
{
    typedef BOOL(WINAPI *MYFUNC)(HWND, COLORREF, BYTE, DWORD);
    MYFUNC fun = NULL;
    fun = (MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes");
    if (fun)
        fun(hWnd, 0, 255 / 2, LWA_ALPHA); //半透明
    FreeLibrary(hInst);
}


當(dāng)前文章:WIN32一些文件及窗口操作-創(chuàng)新互聯(lián)
文章URL:http://weahome.cn/article/dcpohc.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部