|
no, GetLastError() work for the system, not for your own error codes.
if you want to catch an error ans determine which one has been thrown, the throwing function must send a class per exception...
this way, you test the class, and so determine which exception was thrown...
TOXCCT >>> GEII power
|
|
|
|
|
Hi!
i'm used to sending messages from a view class (in mfc), so first i get the window
HWND *viewhandle = new HWND;
*viewhandle = GetSafeHwnd();
copy the viewhandle to a variable of the object, and in a function, when i want to send a message, i call:
::PostMessage(*viewhandle, WM_ONWHATEVER, 0, 0);
That works fine. Now, i want to send a message from a class to another, and there are no windows involved.
I want to do this: class AA includes class BB. And i want to use a function of class AA from class BB, but class BB doesn't see class AA. So i want to send a message
But now i can't use GetSafeHwnd. How could i do that?
thanks!
|
|
|
|
|
First of all you should just be able to do
HWND viewhandle = GetSafeHwnd();
I don't see the need for the "new HWND;" line.
Second. If you want to send a message from one class to another, you will need to have a message loop somewhere to capture the message.
What exactly are you trying to do? Can you not get a pointer to the other object and call a function?
|
|
|
|
|
Yes, the new line was useless.
I can't do
HWND viewhandle = GetSafeHwnd();
it gives me this error: 'GetSafeHwnd' : undeclared identifier
even though i include <afxwin.h>
.
What i'm trying to do is, from an object(O1), with new, create an instance of an object(O2). And from that object(O2), i want to send a message to the O1 so it can delete the O2 which was a member of O1.
|
|
|
|
|
alright,
that sounds a little bizarre. Is the source in O2 running in another thread?
If you call a function O1::SomeFunc()
and it create the object of type O2,
then do you call a function O2::OtherFunc from a function of O1 ??
If so your return value frmo OtherFunc can tell O1 to delete the O2 object.
Otherwise you could post a message to the applications main thread handle, and capture it there, and call a function that tells O1 to delete O2.
|
|
|
|
|
Maybe you can create a custom message && || custom message handler?
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
how could i create a custom message?
|
|
|
|
|
#ifndef WM_LOCK<br />
#define WM_LOCK WM_APP + 0x100<br />
#endif<br />
<br />
#define MY_LOCKMESSAGE(message, memberFxn) \<br />
{ message, 0, 0, 0, AfxSig_lwl, \<br />
(AFX_PMSG)(AFX_PMSGW) \<br />
(static_cast< LRESULT (AFX_MSG_CALL CWinApp::*)(WPARAM, LPARAM) > \<br />
(memberFxn)) },
OK first note, I do not understand everything they did here.
I normally copy/paste a bit and adapt it a little.
The first #indif is a custom message. The #define is a custom message handler. Read first some stuff about messages and handling them before you try to do something!!!!
(WM_APP was last message so + 0x100 if you want another again last message + 0x100 ...)
Good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
|
Hi,
I've got this code for the OnSetcursor function:
BOOL CVentanaPizarra::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
BOOL resultado=TRUE;
if (this->m_MouseManoMover)
{
if (SetCursor(CursorManoMover))
resultado=TRUE;
}
else
resultado = CDialog::OnSetCursor(pWnd, nHitTest, message);
return resultado;
}
the following function changes the boolean which is seen to change the cursor in the abovementioned function.
LONG CVentanaPizarra::MouseManoMoverTrue(WPARAM wParam, LPARAM lParam)
{
this->m_MouseManoMover=true;
return 0;
}
I call this function from a 'CWnd derived' custom control in the dialog (that i use for drawing). The message works, when i click on something on the control , the message is sent, but the OnSetCursor function doesn't get called, perhaps because i'm hovering the mouse over the custom control, and not over the dialog. But the custom control is in the dialog.
Any ideas?
thanks!!
|
|
|
|
|
You are not handling WM_SETCURSOR in the child window, I suppose? That would otherwise be the reason for your problem. Is the cursor changed when you move the mouse, that is, if you do the action leading to MouseManoMoverTrue , will the cursor stay as it was, but change as soon as you move it? If that is the case, you might want to call SetCursor with the special cursor in MousManoMoverTrue as well.
|
|
|
|
|
Johan Rosengren wrote:
You are not handling WM_SETCURSOR in the child window
that was the problem. Solved it. thanks!!
|
|
|
|
|
Hi,all
I am a newcomer here, would you like tell me what problem is? When i download some source codes here, I can not always compile or link them successfully. it always tells me some errors like this:
:\program files\microsoft visual studio\vc98\mfc\include\afx.h(1483) : error C2629: unexpected 'class CTimeSpan ('
c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(1483) : error C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(1527) : error C2146: syntax error : missing ';' before identifier 'm_timeSpan'
........
How can i deal with it?
Thanks very much
henry
|
|
|
|
|
Maybe you have not include some header files.
|
|
|
|
|
Yes, I just downloaded from here:
http://www.codeproject.com/bitmap/tonyjpeglib.asp
But I can not compile and link it sucefully. Would you like do me a favor and try it see what is the problem?
Thanks
david
|
|
|
|
|
give us the erroring line 1483...
TOXCCT >>> GEII power
|
|
|
|
|
Thanks, the code as follow, but I do not think the code has any problem because it is standard and other source codes use it well. it is inside the AFX.H file.
class CTimeSpan
{
public:
// Constructors
CTimeSpan();
CTimeSpan(time_t time);
CTimeSpan(LONG lDays, int nHours, int nMins, int nSecs);
CTimeSpan(const CTimeSpan& timeSpanSrc);
const CTimeSpan& operator=(const CTimeSpan& timeSpanSrc);
|
|
|
|
|
and did you try to include time.h yourself ?
TOXCCT >>> GEII power
|
|
|
|
|
Thanks, I did not find time.h file in the fold I have downloaded. where can i find the time.h file. I think these time.h files are different from different sources. right?
thanks
|
|
|
|
|
just #include <time.h>
it is in the compiler includes folder...
TOXCCT >>> GEII power
|
|
|
|
|
Thanks
I have included the time.h file inside .cpp files. but still errors over there.
I just downloaded source codes from here:
http://www.codeproject.com/bitmap/tonyjpeglib.asp
But I can not compile and link it sucefully. Would you like do me a favor and try it see what is the problem?
Thanks
david
|
|
|
|
|
i would do it if i had time, but at the moment, i already take on my time to post on codeproject, but i'm sorry, i cannot do this for you at the moment...
TOXCCT >>> GEII power
|
|
|
|
|
Thanks Geii power
I wait for your reply when you are availiable.
Thanks again
|
|
|
|
|
wow, GEII is the studies i am currently on... it's not me
call me toxcct, i'll be fine for me
TOXCCT >>> GEII power
|
|
|
|
|
Sorry, toxcct;P
I will wait
|
|
|
|