|
In a "class CMyCtrl : public CWnd" controller I create another controller dynamically.
Can I catch the WM_LBUTTONDOWN message that is intended for the dynamic controller in CMyCtrl instead?
/Mathias
|
|
|
|
|
<br />
<br />
(WNDPROC) gfnMyProc;<br />
gfnMyProc = (WNDPROC)SetWindowLong(listview, GWL_WNDPROC,(LONG)MyProc);<br />
<br />
LRESULT CALLBACK MyProc(HWND hwnd, UINT uiMsg,WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (uiMsg)<br />
{<br />
case WM_LBUTTONDOWN:<br />
{<br />
<br />
break;<br />
}<br />
}<br />
return CallWindowProc(gfnMyProc, hwnd, uiMsg, wParam, lParam);<br />
}}<br />
Pain is a weakness living the body
|
|
|
|
|
This should work
<br />
<br />
(WNDPROC) gfnMyProc;<br />
gfnMyProc = (WNDPROC)SetWindowLong(listview, GWL_WNDPROC,(LONG)MyProc);<br />
<br />
LRESULT CALLBACK MyProc(HWND hwnd, UINT uiMsg,WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (uiMsg)<br />
{<br />
case WM_LBUTTONDOWN:<br />
{<br />
<br />
break;<br />
}<br />
}<br />
return CallWindowProc(gfnMyProc, hwnd, uiMsg, wParam, lParam);<br />
}<br />
Pain is a weakness living the body
|
|
|
|
|
I would like to do a particular operation every 1 minute.How can I set the program so that this is done automatically?Please Help!!!
|
|
|
|
|
SetTimer() is the simplest way. You can create a timer which will send a WM_TIMER message every 60000 milliseconds.
|
|
|
|
|
You could also have it notify a static function, rather than send the message through the message loop, if desired.
|
|
|
|
|
Hi,
I´m working with a CListCtrl control using a CImageList. The size of my list is limited to 200 items by using DeleteItem(0) when GetItemCount>200. Everything seems to work fine but the memory my app is taken from the system. It seems that the system does not free the memory allocated for each item when it is deleted.
Can anybody help me about this?
Thanks a lot.
|
|
|
|
|
munguia wrote:
It seems that the system does not free the memory allocated for each item when it is deleted.
If you have a delete for every new , your application is behaving properly. It's highly unlikely you'd see the memory footprint of your application decrease until the application is closed. That does not mean, however, that less memory is available. For a more detailed spin on this, read here, especially the last section.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
It should work!
if u use CListCtrl object as a data member of a view or dialog class, it is destroyed when its owner is destroyed. If you use aCListView, the framework destroys the control when it destroys the view.
lokesh
|
|
|
|
|
Hi,
Are you using SetItemData to store pointer to objects? If so, have you remembered to delete them before removing the item from the list?
Also, have you included:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
to your .cpp files so that you can track the new's and trace the leaks?
Cheers,
Andy
|
|
|
|
|
I need to put three different forms in SDI application's CView window so that user can choose which view he wants to see. If I make 3 different CFormView classes how do I select one to be shown in a CView window?
|
|
|
|
|
http://www.codeproject.com/useritems/MultiViewsMFC_MDI.asp
Hope this article will help you .
|
|
|
|
|
thanx. hopefully, it will help.
|
|
|
|
|
Hi there,
Create your first view as normal:
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CForm1));
AddDocTemplate(pDocTemplate);
Then, still in InitInstance, store an array (or obarray) to hold the other views...
CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView();
m_pViews[0] = pActiveView;
m_pViews[1] = (CView*) new CForm2;
m_pViews[2] = (CView*) new CForm3;
CDocument* pCurrentDoc = ((CFrameWnd*) m_pMainWnd)->GetActiveDocument();
CCreateContext newContext;
newContext.m_pNewViewClass = NULL;
newContext.m_pNewDocTemplate = NULL;
newContext.m_pLastView = NULL;
newContext.m_pCurrentFrame = NULL;
newContext.m_pCurrentDoc = pCurrentDoc;
UINT viewID[3];
viewID[1] = AFX_IDW_PANE_FIRST + 1;
viewID[2] = AFX_IDW_PANE_FIRST + 2;
CRect rect(0, 0, 0, 0);
for ( int nView=1; nView<NUMVIEWS; nView++ )
{
m_pViews[nView]->Create(NULL, NULL,
(AFX_WS_DEFAULT_VIEW & ~WS_VISIBLE),
rect, m_pMainWnd,
viewID[nView], &newContext);
}
((CForm2*)m_pViews[1])->OnInitialUpdate();
((CForm3*)m_pViews[2])->OnInitialUpdate();
Here's a function to help you switch dynamically between the views...
CView* CMyApp::SwitchView( UINT nIndex, BOOL bSaveData )
{
ASSERT( nIndex >=0 && nIndex < NUMVIEWS );
CView* pNewView = m_pViews[nIndex];
CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView();
if ( !pActiveView )
return NULL;
if ( pNewView == pActiveView )
return pActiveView;
if(bSaveData)
{
if (!SaveActiveViewsData() )
{
return pActiveView;
}
}
UINT temp = ::GetWindowLong(pActiveView->m_hWnd, GWL_ID);
::SetWindowLong(pActiveView->m_hWnd, GWL_ID,::GetWindowLong(pNewView->m_hWnd, GWL_ID));
::SetWindowLong(pNewView->m_hWnd, GWL_ID, temp);
pActiveView->ShowWindow(SW_HIDE);
((CFormView*)pNewView)->ResizeParentToFit(FALSE);
((CFrameWnd*) m_pMainWnd)->SetActiveView(pNewView);
pNewView->ShowWindow(SW_SHOW);
return pActiveView;
}
Any questions, I'll be happy to help.
Hope this helps,
Andy
|
|
|
|
|
Thanx for your help.
I'll try to implement this today and let you know how it works.
|
|
|
|
|
I just wanted to thank you again for your help. I applied the code you gave me in the application and it works. I had some problems with the SwitchView(), particulary this line
<br />
((CFormView*)pNewView)->ResizeParentToFit(FALSE);<br />
because it would produce strange windows sizes for the first 7-8 calls of SwitchView(), and then it would work fine.
So I put
<br />
((CFrameWnd*) m_pMainWnd)->RecalcLayout();<br />
instead. It works fine now.
And I'd like to ask you one more question. I have a button "quit" on one of CFormView's forms. What should I put in OnButtonQuit() message handler, so that the application exits after the button is pressed?
|
|
|
|
|
I gave the link for MDI
Think same thing will work for this also
|
|
|
|
|
Hello Coders,
I'm running my own Software Development Company located in India and I'm looking for a VC++/ATL/WTL programmer to do some of the extra work we have. the work will be mostly related to developing IE toolbars with Pop-up killers based on XML format and BHO (Browser Helper Objects) Development.
So, If anyone of you have required experience in these fields, skilled in VC++, ATL, WTL and XML and looking for extra money then you are most welcome to get in touch with me at ajay@chadhaajay.net
I'll pay you good if you will do excellent work. At start, I'll give you a simple project to do to check your skills and coding style. I've excellent knowledge of what I need and I can explain things pretty well to others.
So, Good Luck
Ajay Chadha (Director)
Chadha Software Technologies (INDIA)
|
|
|
|
|
I use a tab control to display several dialog, when I switch from one tab to another and click on button controls on that page, the mouse click has no response, In each of the nested dialog class, I have a pointer of the based dialog which the tab ctrl is built on, using the pointer to call tab switch function. Not all switches have this problem, only when I switch to a tab containing Directshow Video capturing/displaying tab. but after I use Alt+Tab switch to other running application and switch back, mouse works fine. Anybody knows how come?
|
|
|
|
|
Hi All
i have a Excel.csv file, and i need to import that into SQL server,
does ne1 know how to programatically DTS something ?? or can you
point me in the right direction
thanks
Si
|
|
|
|
|
Hi,
Could someone please help me, I need to make a plug-in for Outlook Express. I've heard that it may not support plug-ins, so even a way to add hooks could be very helpful.
Thanx,
robinfinity
|
|
|
|
|
Hi. Yes you wil have to use hooking try to read something about subclassing in msdn pages. Its a hard and time consuming job. Wish you luck.
Pain is a weakness living the body
|
|
|
|
|
Thank You ravjak!
|
|
|
|
|
This is the current code that is used before access to any data.
<big>bool CTestGUI1Dlg::WaitForMutex(void)<br />
{<br />
<br />
<br />
m_hMutex = ::CreateMutex( NULL,<br />
FALSE,<br />
"CSLSharedMemLock"<br />
);<br />
<br />
if(m_hMutex)<br />
{<br />
if (::WaitForSingleObject(m_hMutex,INFINITE) == WAIT_OBJECT_0)<br />
{<br />
ReleaseMutex(m_hMutex);<br />
return true;<br />
}<br />
}<br />
return false;<br />
}</big>
Note that currently I create it each time. If I dont then I never return.
If I now create the Mutex in the InitDialog() section of the program and modify the WaitForMutex as follows I get error = 6
<big><br />
bool CTestGUI1Dlg::WaitForMutex(void)<br />
{<br />
<br />
<br />
<br />
if(m_hMutex)<br />
{<br />
if (::WaitForSingleObject(m_hMutex,300) == WAIT_OBJECT_0)<br />
{<br />
ReleaseMutex(m_hMutex);<br />
return true;<br />
}<br />
}<br />
int error = GetLastError();<br />
return false;<br />
}</big>
|
|
|
|
|
Yeah that error indicates an invalid handle. Try creating (openning of already exist) the mutex in the constructor.
Kuphryn
|
|
|
|