Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ CustomDraw中的SetWindowLong导致未处理的异常_C++_Mfc_Custom Draw - Fatal编程技术网

C++ CustomDraw中的SetWindowLong导致未处理的异常

C++ CustomDraw中的SetWindowLong导致未处理的异常,c++,mfc,custom-draw,C++,Mfc,Custom Draw,我正在使用自定义绘图对CSliderCtrl进行一些更改,该控件将在对话框中使用。结构如下: 在我的MessageMap中,我有:ON\u NOTIFY\u REFLECT\u EX(NM\u CUSTOMDRAW,OnNMCustomdraw) OnNMCustomdraw方法如下所示: BOOL CCustomSliderCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) { *pResult = CDRF_DODEFAULT;

我正在使用自定义绘图对CSliderCtrl进行一些更改,该控件将在对话框中使用。结构如下: 在我的MessageMap中,我有:
ON\u NOTIFY\u REFLECT\u EX(NM\u CUSTOMDRAW,OnNMCustomdraw)

OnNMCustomdraw方法如下所示:

BOOL CCustomSliderCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
    *pResult = CDRF_DODEFAULT;
    LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);

    switch(pNMCD->dwDrawStage)
    {
        case CDDS_PREPAINT:
        {
            //Dialogs don't receive CDRF_NOTIFYITEMDRAW notifcations by returning it as part of pResult, we must
            //use the following so we ensure we receive the msg
            SetWindowLong(pNMHDR->hwndFrom, DWL_MSGRESULT, CDRF_NOTIFYITEMDRAW);
            return TRUE;
        }
        case CDDS_ITEMPREPAINT:
            if(pNMCD->dwItemSpec == TBCD_CHANNEL)
            {
                ...SNIP...
                SetWindowLong(pNMHDR->hwndFrom, DWL_MSGRESULT, CDRF_SKIPDEFAULT);
                return TRUE;
            }
    }
    return FALSE;
}
那么,有人对这件事有什么见解吗?如果你需要更多信息,请告诉我



更新:我现在已经找到了一个解决方法,而不是使用SetWindowLong,我只是将结果分配给pResult,然后返回。我通过调用SetRangeMin(GetRangeMin(),TRUE);,强制重新绘制子项;,虽然不太优雅,但很管用

您在错误的窗口中调用了
SetWindowLong
SetWindowLong
的第一个参数是处理消息的对话框,而不是发送消息的窗口<代码>设置窗口长(m_hWnd、DWL_MSGRESULT、CDRF_NOTIFYITEMDRAW)


您的代码正在更改“发件人”窗口上的窗口长度,这最终会损坏该窗口的私有数据。

提示:要获得更好的堆栈跟踪,请配置一个“谢谢”,我现在就开始玩这个。添加了一个更好的堆栈跟踪,谢谢提示。
comctl32.dll!_TrackBarWndProc@16()  + 0x551 bytes   
user32.dll!_InternalCallWinProc@20()  + 0x28 bytes  
user32.dll!_UserCallWinProcCheckWow@32()  + 0xb7 bytes  
user32.dll!_CallWindowProcAorW@24()  + 0x51 bytes   
user32.dll!_CallWindowProcW@20()  + 0x1b bytes  
mfc90ud.dll!CWnd::DefWindowProcW(unsigned int nMsg=15, unsigned int wParam=0, long lParam=0)  Line 1043 + 0x20 bytes    C++
mfc90ud.dll!CWnd::WindowProc(unsigned int message=15, unsigned int wParam=0, long lParam=0)  Line 1756 + 0x1c bytes C++
mfc90ud.dll!AfxCallWndProc(CWnd * pWnd=0x0012fdbc, HWND__ * hWnd=0x000308fe, unsigned int nMsg=15, unsigned int wParam=0, long lParam=0)  Line 240 + 0x1c bytes C++
mfc90ud.dll!AfxWndProc(HWND__ * hWnd=0x000308fe, unsigned int nMsg=15, unsigned int wParam=0, long lParam=0)  Line 403  C++
mfc90ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000308fe, unsigned int nMsg=15, unsigned int wParam=0, long lParam=0)  Line 441 + 0x15 bytes C++
user32.dll!_InternalCallWinProc@20()  + 0x28 bytes  
user32.dll!_UserCallWinProcCheckWow@32()  + 0xb7 bytes  
user32.dll!_DispatchClientMessage@20()  + 0x4d bytes    
user32.dll!___fnDWORD@4()  + 0x24 bytes 
ntdll.dll!_KiUserCallbackDispatcher@12()  + 0x13 bytes  
user32.dll!_NtUserDispatchMessage@4()  + 0xc bytes  
user32.dll!_DispatchMessageW@4()  + 0xf bytes   
mfc90ud.dll!AfxInternalPumpMessage()  Line 183  C++
mfc90ud.dll!CWinThread::PumpMessage()  Line 900 C++
mfc90ud.dll!AfxPumpMessage()  Line 190 + 0xd bytes  C++
mfc90ud.dll!CWnd::RunModalLoop(unsigned long dwFlags=4)  Line 4386 + 0x5 bytes  C++
mfc90ud.dll!CDialog::DoModal()  Line 584 + 0xc bytes    C++
SetSelection.exe!CSetSelectionApp::InitInstance()  Line 64 + 0xb bytes  C++
mfc90ud.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020a84, int nCmdShow=1)  Line 37 + 0xd bytes C++
SetSelection.exe!wWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020a84, int nCmdShow=1)  Line 34  C++
SetSelection.exe!__tmainCRTStartup()  Line 578 + 0x35 bytes C
SetSelection.exe!wWinMainCRTStartup()  Line 403 C
kernel32.dll!_BaseProcessStart@4()  + 0x23 bytes