Prev: Runtime error-help plz.
Next: uafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined
From: David Ching on 1 Jul 2007 16:32 "Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message news:1h3g835dotcvenq0pkun2qtbq1uvdlf87p(a)4ax.com... > Thanks, David, I couldn't remember that it was you who had done this. I'd > posted a > response that said it existed. I saw that, and thanks for the reference. BTW, it doesn't involve DLL injection though, which makes it very convenient to call without the trouble of creating a special DLL. -- David
From: Joseph M. Newcomer on 1 Jul 2007 17:14 I'd misremembered the thread, then. I've got to download your code...but it sounds like it is truly doing handstands to get everything to work right. I may have confused it with a solution I did see that used DLL injection. joe On Sun, 01 Jul 2007 20:32:58 GMT, "David Ching" <dc(a)remove-this.dcsoft.com> wrote: >"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message >news:1h3g835dotcvenq0pkun2qtbq1uvdlf87p(a)4ax.com... >> Thanks, David, I couldn't remember that it was you who had done this. I'd >> posted a >> response that said it existed. > >I saw that, and thanks for the reference. BTW, it doesn't involve DLL >injection though, which makes it very convenient to call without the trouble >of creating a special DLL. > >-- David > Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Headache on 2 Jul 2007 04:31 I thought Windows might marshall the simple types too. I guess I've been working too long with COM. However, I tried this in a single process and still couldn't get it to work. This time I see the message in Spy++. Looking at the MFC source code it seems to frig WM_NOTIFY messages. Anyhow here is my source. I send the message in another thread (as I guess my handler is on the main thread which is blocked waiting on a SendMessage) and I'm new'ing the structure on the heap and not even deleting it. I don't get into the MainFrame OnClick handler even though it is in the message map. It makes me think I'm missing something simple. Don't ask about where I break out the code in OnCmdMsg - it was code I wrote while looking at the framework. Once I get this going I'll have a look at the SendMessageRemote suggestion. // MainFrm.cpp : implementation of the CMainFrame class // #include "stdafx.h" #include "WmNotify.h" #include "MainFrm.h" #include ".\mainfrm.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_WM_CREATE() ON_NOTIFY(NM_CLICK, 0, OnClick) ON_COMMAND(ID_EDIT_SENDMESSAGE, OnSendMessage) END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; UINT __cdecl SendMessageToMainWnd(LPVOID pParam) { NMITEMACTIVATE *pNMIA = new NMITEMACTIVATE; ::ZeroMemory(pNMIA, sizeof(NMITEMACTIVATE)); // Set up header pNMIA->hdr.code = NM_CLICK; pNMIA->hdr.hwndFrom = ::AfxGetMainWnd()->GetSafeHwnd(); pNMIA->hdr.idFrom = 426; // Setup item and subitem pNMIA->iItem = 1; pNMIA->iSubItem = 2; //DWORD dwThreadID = (DWORD)pParam; ::AfxGetMainWnd()->SendMessage(WM_NOTIFY, pNMIA->hdr.idFrom, (LPARAM)pNMIA); return 0; } // CMainFrame construction/destruction CMainFrame::CMainFrame() { // TODO: add member initialization code here } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // TODO: Delete these three lines if you don't want the toolbar to be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE; } // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG // CMainFrame message handlers void CMainFrame::OnClick(NMHDR *pNMHDR, LRESULT* pResult) { ::AfxMessageBox(_T("Hurrah!!")); ASSERT(NM_CLICK == pNMHDR->code); NMITEMACTIVATE *pNMIA = (NMITEMACTIVATE *)pNMHDR; *pResult = 1; } void CMainFrame::OnSendMessage() { ::AfxBeginThread(SendMessageToMainWnd, (LPVOID)::AfxGetApp()- >m_nThreadID); } BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { // TODO: Add your specialized code here and/or call the base class if ( (HIWORD(nCode) == WM_NOTIFY) && (LOWORD(nCode) == NM_CLICK) ) { CString str; str.Format(_T("Msg = %d, nCode = %d\n"), HIWORD(nCode), LOWORD(nCode)); TRACE(str); } return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); }
From: Headache on 2 Jul 2007 08:40 And I've made the id in the message map entry 426 not 0 ...
From: Scott McPhillips [MVP] on 2 Jul 2007 08:51 Headache wrote: > I thought Windows might marshall the simple types too. I guess I've > been working too long with COM. However, I tried this in a single > process and still couldn't get it to work. This time I see the message > in Spy++. Looking at the MFC source code it seems to frig WM_NOTIFY > messages. Anyhow here is my source. I send the message in another > thread (as I guess my handler is on the main thread which is blocked > waiting on a SendMessage) and I'm new'ing the structure on the heap > and not even deleting it. I don't get into the MainFrame OnClick > handler even though it is in the message map. It makes me think I'm > missing something simple. I don't see anything wrong with your code, so I tried it out in a bare new project and it worked for me. -- Scott McPhillips [MVP VC++]
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Runtime error-help plz. Next: uafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined |