|
I'm trying to make my own assert and add some file logging. Looking at assert.h I see the following #define
#define assert(exp) (void)( (exp) || (_assert(#exp, __FILE__, __LINE__), 0) )
I'm a little confused with that ,0 in there. What does that expression evaluate to?
The problem I'm having is, when I call _assert myself I get an abnormal program termination when I click on Ignore in the assert dialog.
Here's the ohter part of the header
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP void __cdecl _assert(void *, void *, unsigned);
#ifdef __cplusplus
}
#endif
#define assert(exp) (void)( (exp) || (_assert(#exp, __FILE__, __LINE__), 0) )
Todd Smith
CPUA 0x007 ... shaken not stirred
|
|
|
|
|
Todd Smith wrote:
I'm a little confused with that ,0 in there. What does that expression evaluate to?
This evaluates to zero. Generally, the value of (x,y) is y. For more info, search the help for 'comma operator'.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Then it appears that the Ignore button on the assert dialog does not work.
#include <assert.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
assert(false);
printf("ignore assert works!");
return 0;
}
That just exits when I click on Ignore. *sigh*
I guess I should be using _CrtDbgReport to assert instead.
Todd Smith
CPUA 0x007 ... shaken not stirred
|
|
|
|
|
Basically, you can ignore the 'Ignore' button.
It's probably there because there's only MB_ABORTRETRYIGNORE - you'll not find MB_ABORTRETRY.
_assert() calls abort() which aborts the program (Abort/Ignore) or transfers control to the debugger (Retry).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I'm tring to make a template class as follows:
template <class t=""> class x1 : public CWinThread
{
DECLARE_DYNCREATE(x1)
.
.
.
}
In the CPP file on the IMPLEMENT_DYNCREATE( x1, CWinThread) I get the following errors:
: error C2955: 'x1' : use of class template requires template argument list
: error C2512: 'x1<t>' : no appropriate default constructor available
I've tried a few things but cant get this thing to compile. Is it futile to try and make a template on an MFC class?
Thanks.
|
|
|
|
|
Sorry - DECLARE_xxx/IMPLEMENT_xxx are not suitable for templates. These macros use ## (token paste) preprocessor operator to declare a static member of your class which has a name like classCYourClass (assuming that you've used DECLARE_DYNAMIC(CYourClass)). This approach fails for templates - you can't have a C++ identifier with a name like 'classCYourClass<X>'
So you can derive a template class from MFC classes, but you have to give up DECLARE_xxx/IMPLEMENT_xxx - which is often painless.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I'm writing an app that needs to know when someone logs on or logs off. I used GetSafeHwnd() to send WTSRegisterSessionNotification the window I was using. YOu can find all the info for it here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/tsref_8d66.asp
Now they say I can use http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/tsref_7fvp.asp WM_WTSSESSION_CHANGE
to recieve the messages through the windowproc
LRESULT CALLBACK WindowProc(
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
now, how in the world do I use this? I have absolutely no idea how to use this with windowproc
thx
I can imagine a world without war and hate, I can imagine us attacking that world because they'd never expect it.
|
|
|
|
|
This just means that your window will get WM_WTSSESSION_CHANGE. You pass its hwnd to WTSRegisterSessionNotification.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I need to know how to get the messages when they are sent out, I can see what it does I just don't know how to get or when to get the message for the notification
I can imagine a world without war and hate, I can imagine us attacking that world because they'd never expect it.
|
|
|
|
|
If you call WTSRegisterSessionNotification and window handle, this window will receive WM_WTSSESSION_CHANGE when session status changes. The message is sent by Windows Terminal Services to window you've registered with WTSRegisterSessionNotification. When window receives the message - its windowproc is called.
If you're using MFC, you'll have to add
ON_MESSAGE(WM_WTSSESSION_CHANGE, OnWtsSessionChange)
to the message map. OnWtsSessionChange is the message handler - inside this function you can do whatever you need to handle the session change notification.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
so the OnWTSsessionchange is the message? I could use something like myvariable = ON_MESSAGE(WM_WTSSESSION_CHANGE, ONWTSSESSIONCHANGE); then check for the messages?
I can imagine a world without war and hate, I can imagine us attacking that world because they'd never expect it.
|
|
|
|
|
No. The message is WM_WTSSESSION_CHANGE. OnWTSsessionchange is a member function of your CWnd-derived class. This function will be called when session status changes.
It's just like WM_SIZE and OnSize.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
ok so that calls the function when theres a session change? How do I get the message? one of these messages is supposed to be sent
WTS_CONSOLE_CONNECT A session was connected to the console session.
WTS_CONSOLE_DISCONNECT A session was disconnected from the console session.
WTS_REMOTE_CONNECT A session was connected to the remote session.
WTS_REMOTE_DISCONNECT A session was disconnected from the remote session.
WTS_SESSION_LOGON A user has logged on to the session.
WTS_SESSION_LOGOFF A user has logged off the session.
WTS_SESSION_LOCK A session has been locked.
WTS_SESSION_UNLOCK A session has been unlocked.
WTS_SESSION_REMOTE_CONTROL
I can imagine a world without war and hate, I can imagine us attacking that world because they'd never expect it.
|
|
|
|
|
The docs clearly states that WTS_xxx gets passed in wParam. lParam is the pointer to WTSSESSION_NOTIFICATION structure.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
On Windows XP Professional SP1 -FOR CERTAIN- the lParam is merely a number - the session ID. Several General Protection Faults will prove this to you.
I think the WTSSESSION_NOTIFICATION structure is passed to the HandlerEx routine in a Windows service application (have not tried that one yet...)
The wParam lets you know what is happening, and the lParam identifies the session ID.
You can use the session id in call to WTSQuerySessionInformation to get more details for a specific session identifier.
I am currently trying to get Microsoft to document specific recommendations for applications to follow in response to each of these messages. More specific than 'avoid anything troublesome'...
|
|
|
|
|
<--- dummy
I want to add the capability to connect via dial up PPP to my code.. (like MS DUN)... except I have no idea where to start. Any ideas fellas.. or anyone know of any source code sample I can peruse?
Ok.. come on you smart bastards.. help on Aussie wanker out here will ya!
Aus
|
|
|
|
|
Look at the msdn.microsoft.com for something called RASDIAL-something... Type RASDIAL and search for it.
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
Great!.. That has given me a start.. thanks mate. Have a good one.
Aus
Aus
|
|
|
|
|
You can get a good class for ras from Dundas, or use the RasApi. Look for the fuctions RasDial into Remote Access Service Functions
Best Reagars.
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Thanks mate.. appreciate it!!
Aus
Aus
|
|
|
|
|
Get the free RAS class library from Dundas Software.
This class library should do everything you need for your dialup. Plus it comes with complete source code. This class library is part of the Dundas TCP/IP product line, but was made available for free to help promote the product line.
Just to to www.dundas.com
Troy
|
|
|
|
|
Hi Chaps,
Anyone got any drag & drop code examples?
having a bit of trouble with the leftbuttonup function and the HitTest() not working properly
I did this:
void CRunEICDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
if( m_bDragging )
{
ASSERT(m_pimagelist != NULL);
m_pimagelist->EndDrag();
CImageList* pTemp = m_pimagelist;
m_pimagelist = NULL;
delete pTemp;
ReleaseCapture();
m_bDragging = false;
}
// CPoint point;
// GetCursorPos( &point );
m_cTestSeq.ClientToScreen( &point );
UINT flags;
int item;
item = m_cTestSeq.HitTest( point, &flags );
item = item;
if( LVHT_NOWHERE | flags )
{
// add to end
item = item;
}
else if( LVHT_ONITEM | flags )
{
// insert before the item
item = item;
}
// }
CDialog::OnLButtonUp(nFlags, point);
}
But it doesnt recognise when the leftbutton was let go in the listControl window
any comments greatfully received
The Wudan Master
|
|
|
|
|
|
I am updating a list control with several operations, including deleting some entries and adding others. Due to the speed at which the new entries must be made, I have found that I need to do a SetDraw(FALSE) prior to adding and removing the entries to ensure that all of the time critical messages that are the basis of the entries are entered and none are missed. Although I am now catching all of the messages, I now find that the list control constantly flickers irritatingly. Is there a way to prevent this flickering? Any ideas are appreciated.
Thanks.
|
|
|
|
|
What messages are you catching? What does it have in common with blocking the redraws of list control?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|