|
I have a code statements using STL and CString of MFC:
#include <vector>
#include <afx.h>
vector<CString> strs;
vector<CString>::iterator pos;
pos = find(m_lstPy.begin() + nIndexStart, m_lstPy.end(), lpszFind); // Error line
....
The building error:
error C2440: '=' : cannot convert from 'const class CString *' to 'class CString *' Conversion loses qualifiers
|
|
|
|
|
try this:
CString temp = lpszFind;
pos = find(m_lstPy.begin() + nIndexStart, m_lstPy.end(), temp);
or
pos = find(m_lstPy.begin() + nIndexStart, m_lstPy.end(), &temp);
-c
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
the problem is exist yet!!
Please test your code befer place it here!!!
|
|
|
|
|
IMiracle wrote:
Please test your code befer place it here!!!
yes i did. here is the entire program that i used to test it:
#include "stdafx.h"
#include "mfcmfmcc.h"
#include <vector>
#include <algorithm>
#include <afx.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
vector<CString> strs;
vector<CString>::iterator pos;
const char * lpszFind = "hi";
pos = find(strs.begin(), strs.end(), lpszFind);
}
return nRetCode;
}
the problem is apparently not in the code you're showing us.
-c
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
Thank you!
What is about mfcmfmcc.h and mfcmfmcc.cpp
|
|
|
|
|
That code is in a MFC Application;
|
|
|
|
|
so was the code i posted.
Green's Law of Debate:
Anything is possible if you don't know what you're talking about.
|
|
|
|
|
Does anyone know how to retrieve the location of all the icons and shortcuts on the desktop? My program needs to change the display settings at runtime, which may cause icons to be moved around on the Desktop. Once the program is closed, I'd like to restore all the icons and shortcuts to their original locations on the Desktop.
|
|
|
|
|
Just a suggestion...
Check out Mike Dunns articles on Shell extensions...prolly a good place to start.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
how can i tell when the mouse has come over my formview? and when it goes out of the form view? basicly when the cursor is over this view i want to switch my cursor, whenever the mouse goes outside of this area i want to switch it back..
currently i am just overriding OnMouseMove(UINT nFlags, CPoint point) and setting it everytime in here.. the prob is that you can kinda see it flicker when i am running other code at the same time.. i should be able to just set it when it comes in, and set it when it comes out right?
thanks for any suggestions!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
I believe there is a message handle you could override that will update you ask the user moves the mouse into and outside the FormView.
Kuphryn
|
|
|
|
|
Consider overriding OnDragEnter(), OnDragLeave(), and OnDragOver() member functions.
Kuphryn
|
|
|
|
|
these look like they are only for dragging into or out of a view, there is no dragging involved, just coming into and out of a view. thanks for the suggestions tho!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Good point. I cannot think of a message handler that updates as the user moves the mouse into and out of a windows other than getting the update of the mouse handler.
Kuphryn
|
|
|
|
|
Check CWnd::OnSetCursor .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the suggestion! I tried to use this function but it never gets called.. this is a CFormView derived class.. here is what I added in the .h
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
here is what i added in the .cpp
BOOL CDisplayPrintTemplate::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
AfxMessageBox("hrm");
::SetCursor(AfxGetApp()->LoadCursor (IDC_HAND_OPEN));
return 0;
} but it never pops up and says 'hrm'.. any suggestions?
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
To track mouse events use _TrackMouseEvent. It sends to wnd event WM_MOUSELEAVE, when mouse goes out.
Example:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static BOOL bMouseInside;
switch (message)
{
case WM_MOUSEMOVE:
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = hWnd;
tme.dwFlags = TME_LEAVE;
_TrackMouseEvent(&tme);
if(!bMouseInside)
{
bMouseInside = TRUE;
InvalidateRect(hWnd, NULL, FALSE);
UpdateWindow(hWnd);
}
}
break;
case WM_MOUSELEAVE:
bMouseInside = FALSE;
InvalidateRect(hWnd, NULL, FALSE);
UpdateWindow(hWnd);
break;
The second approach is to use timer for periodically checking mouse position. If you received WM_MOUSEMOVE for the first time, you should enable timer, until you detect mouse absence
Example:
BOOL CMouseEvent::OnMouseMove....
{
if( m_uTimer != 0 )
return TRUE;
m_uTimer = ::SetTimer( pWnd->m_hWnd, IDS_TIMER_MOUSE_EVENT, 10, NULL );
if( m_uTimer )
{
m_hWnd = pWnd->m_hWnd;
::SendMessage( pWnd->m_hWnd, UWM_MOUSE_ENTER, 0, 0 );
}
return m_uTimer != 0 ? TRUE : FALSE ;
}
BOOL CMouseEvent::OnTimer(CWnd *pWnd )
{
CPoint pt;
::GetCursorPos( &pt );
if( pWnd != CWnd::WindowFromPoint( pt ) )
{
::KillTimer( pWnd->m_hWnd, m_uTimer );
m_uTimer = 0;
m_hWnd = NULL;
}
return TRUE;
}
|
|
|
|
|
In a thread that i've created with CreateThread i create a window. But when that thread returns the window closes, why? and how can i prevent it?
thanks
|
|
|
|
|
Windows belong to the thread where they are created. You cannot do anything to change this. If you want your window to be more long-lived than the thread, you have not other option but to delegate the creation of the window to another thread (preferrably the app main thread). If you take this approach, take into account all communication between the secondary thread and the windows must be done using SendMessage /PostMessage .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hmm, so i could just instead of createing the window, use SendMessage to my main app and handle that message and create window there... good thinking!
|
|
|
|
|
Yes, that's a solution.
One more word of caution: If your secondary thread engages in blocking calls to the main thread with SendMessage , a possibility of dead-lock exists --imagine the main thread signals the sec. thread to finish and is waiting for it to die, while the sec. thread is hopelessly waiting for the main thread to anwser to its SendMessage . To prevent this situation, use SendMessageTimeout when calling from the secondary thread to the main one.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hello @all,
is there a possibility to make a table (invisible) inside a combobox??
mfc
|
|
|
|
|
Running this inside a worker thread causes my app to crash..
CSocket sSocket;
sSocket.Create(); <-- causes the crash..
any ideas why?
|
|
|
|
|
CSocket needs to live inside a thread which has a message pump, like the main thread or (alternatively) UI threads. Worker threads, by definition, do not have such pump.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Anybody knows how solve this problem ?
When I use CListCtrl::DeleteColumn() function to delete the column with index zero (first column), it remove only the header from this column, but the items go to column one (it remove the itens from the last column).
[]'s
Cris.
|
|
|
|