none
A question about developing a desktop application RRS feed

  • 问题

  • I wrote a simple dialog based MFC application. and load ico and png files,show them on the dialog.

    the application runs well when I double click the exe file.

    Then I wrote a bat file to run the application when The windows system startup(in user's startup folder).
    then the ico and png would not show(occationally on different pc, but once it occured , it alway occurs, on the other way, double click would always run well).

    the bat file way would be ok, when I do logoff operate, but reboot will go bad.

    could any body explain the reason for me?

    Thanks a lot!!!!

    running system is windows 10 x64;
    dev system is windows 7 x64;
    IDE vs2017 community.

    2020年7月13日 1:14

全部回复

  • 你好,

    感谢您在MSDN中文论坛发帖提问。

    因为这是中文论坛,所以我将用中文回复你。你也可以将问题发布到英文论坛,获得更好的帮助:https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vcgeneral

    >>Then I wrote a bat file to run the application when The windows system startup(in user's startup folder).
    then the ico and png would not show(occationally on different pc, but once it occured , it alway occurs, on the other way, double click would always run well).

    我尝试复现你的问题。但是并没有出现你遇到的这个问题。

    首先编写了一个基于对话框的简单MFC应用程序。并加载ico和png文件,在对话框中显示它们。以下是我的代码:

    void CMFCApplication72Dlg::OnBnClickedButton1()
    {
    
        CString pngPath = L"c:\\test.png";
        CImage pngImage;
        CBitmap pngBmp;
        CDC bmDC;
        CBitmap *pOldbmp;
        BITMAP  bi;
        UINT xPos = 100, yPos = 100;
    
        CClientDC dc(this);
    
        pngImage.Load(pngPath);
        // new code
    
        pngBmp.Attach(pngImage.Detach());
    
        bmDC.CreateCompatibleDC(&dc);
    
        pOldbmp = bmDC.SelectObject(&pngBmp);
        pngBmp.GetBitmap(&bi);
        dc.BitBlt(xPos, yPos, bi.bmWidth, bi.bmHeight, &bmDC, 0, 0, SRCCOPY);
        bmDC.SelectObject(pOldbmp);
        // TODO: Add your control notification handler code here
    }

    然后我编写了一个bat文件来运行应用程序。运行结果良好,.png可以正常显示。

    你能否提供更多的细节,来帮助我们复现出这个问题。我们将为您提供更好的帮助。

    Best Regards,

    Jeanine Zhang


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2020年7月13日 3:32
    版主