sizeof( m_szPanelNames ) will be 4 (it's the size of a char * pointer),
not 1. Try the ARRAY_SIZE() macro instead :)

- Alfred

----Original Message----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of John Sheu
Sent: Wednesday, July 13, 2005 11:04 PM To:
[email protected] Subject: [hlcoders] PostMessage()

> Having some issues with PostMessage().  Application crashes with
> complaint about calling a pure virtual function; I think it's
> localized to the message system because (1) the crash does not occur
> when the PostMessage(...) call is commented, and (2) a breakpoint set
> on the recipient function never triggers.
>
> Relevant code:
>
> * The PostMessage(...) call:  (yeah, I know, it's ugly)
>
> PostMessage( (Panel *)(gViewPortInterface->FindPanelByName(
> PANEL_BASE )), new KeyValues( "SetShowPanel", "panel", PANEL_CLASS )
> );
>
> * The message handler declared: (in the header file of recipient
> object)
>
> MESSAGE_FUNC_CHARPTR( SetShowPanel, "SetShowPanel", panel );
>
> * A section of relevant code from the implementation:
> static char *m_szPanelNames[] = { PANEL_CLASS };
>
> void CBaseMenu::SetShowPanel( const char *panel ) {
>       for ( int i = 0; i < sizeof( m_szPanelNames ); i++ ) {
>               if ( Q_strcmp( panel, m_szPanelNames[i] ) )  //  No
match
>                       PostMessage( (Panel
*)(gViewPortInterface->FindPanelByName
> (m_szPanelNames[i] )), new KeyValues( "SetShade", "state", 0 ) );
>               else
>                       PostMessage( (Panel *)
> (gViewPortInterface->FindPanelByName( m_szPanelNames[i] )), new
>       KeyValues ( "SetShade", "state", 1 ) ); }
> }
>
> ---------------
>
> Please excuse the poor formatting.  Any obvious problems with the
> code?
> Thanks.

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to