|
Aaaahh... I'm a moron (but not moron enough not to write under anonymous
1st: status bar has this default feature to show "ready" or tooltip on it. I forgot that.
I had made my own simple status bar, and I mixed on the way SetMessageText
and SetPaneText.
2nd: I couldn't get my hands on the CMainFrame object. Thanks to the
replies, now I could!
3rd: (back to the being stupid) When I was instructed to use pFrame->UpdateStatus(1, "1st panel message...")
I was just baffled ".. but there is no UpdateStatus in CFrameWnd class..."
Ok, here is how it works now, in case this helps someone else. I am NOT
updating the default message text on the status bar, I have created my own
pane with a text:
in MainFrm.h must be lines
public:
void UpdateStatusBar(CString sMessage = "");
- - - - - -
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
UpdateStatusBar();
return 0;
}
- - - - - -
void CMainFrame::UpdateStatusBar(CString sMessage)
{
CWinApp* pApp = AfxGetApp();
// the values are read from the registry
CString strValue, strValue2;
strValue = pApp->GetProfileString("Latest update","Date");
strValue2 = pApp->GetProfileString("Latest update","State");
if (strValue.IsEmpty()) {
m_sPaneText = "Data saved: n/a"; }
else {
m_sPaneText.Format("Data saved: %s, %s", strValue, strValue2); }
CStatusBarCtrl &stCtrl = m_wndStatusBar.GetStatusBarCtrl();
// Let's keep it simple...
stCtrl.SetSimple();
// in case you want send a different message to the status bar
// m_sPaneText is a member of CMainFrame
if (sMessage.IsEmpty())
stCtrl.SetText(m_sPaneText,255,0);
else
stCtrl.SetText(sMessage,255,0);
}
- - - - - -
...and then at the same in another class...
In AppDoc.cpp must be line
#include "MainFrm.h"
- - - - - -
void CAppDoc::SaveDataToServer()
{
// blah blah blah... save data and other dull jobs...
// in my case write to registry. The values are read in
// UpdateStatusBar later on and displayed.
// update the status bar from CDocument class object
CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;//pointer to mainframe object
pFrame->UpdateStatusBar();
return;
}
- - - - - -
|
|
|
|
|
Hi again everyone,
Does anyone know of a good web resource or a book where I can find information regarding vtables and how to manipulate them with C++.
Thanks,
Pankaj
|
|
|
|
|
pankajdaga wrote:
where I can find information regarding vtables and how to manipulate them with C++.
What do you mean by 'manipulating vtables'?
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
I was just wondering if it is possible to directly access the contents of a vtable.
Pankaj
Without struggle, there is no progress
|
|
|
|
|
pankajdaga wrote:
if it is possible to directly access the contents of a vtable
It isn't possible in portable manner. Why do you want to do this?
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Just for educational reasons. I am a student at a university. Just wanted to know if it was possible to access the vtable pointer from the C++ code.
Pankaj
Without struggle, there is no progress
|
|
|
|
|
The main topic is not vtables, but there is very nice code, i like this link
http://www.codeproject.com/atl/atl_underthehood_.asp
regards
-----
Mit freundlichen Grüssen/Best Regards/Un cordial saludo.
Ing. José Manuel Hostalet Wandosell, Fraunhofer IPA, Abt.323/Robotersysteme
Nobelstrasse 12, D-70569 Stuttgart (Germany)
mailto:jose.hostalet@ipa.fhg.de, http://www.ipa.fhg.de
|
|
|
|
|
pankajdaga wrote:
vtables and how to manipulate them with C++.
You are one courageous programmer!
Jeremy Pullicino
Professional C++ Developer
Done any hacking lately?
|
|
|
|
|
Take a look at Jan Gray's article C++: Under the Hood[^] (warning, hardcore stuff).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
No I don't, but it's pretty easy for plain (non-MI and non-virtual-baseclass) classes with virtual functions.
Basically it looks like:
classA* pClass points to memory like:
pclass+0: vfptr
pclass+4: reast of classA data
The at what the vfptr points to you have
addr+0: vfunc1 (often scalar d'tor IIRC)
addr+4: vfunc2
addr+8: vfunc3
...
This is for MSVC6. I don't know if it's incompatible for MSVC7.
|
|
|
|
|
I have an MDI with a property sheet embedded into a CFormView. I have two pages CPage1 and CPage2 in my property sheet.
I want a pointer in CPage2 to access data in CPage1.
Any suggestions?
|
|
|
|
|
When you add pages to the propertysheet can't you add a pointer to the CPage1 to CPage2?
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
In CPage1:
((CMyPropertySheet*)GetParent())->m_page2
Pavel
Sonork 100.15206
|
|
|
|
|
I am openeing a file using fopen and FILE*.
I am getting problems with this structure later It seems to think the FILE is a
_FILEX structure?!?!?!
When I open the file the call stack is.
fopen
_fsopen
_getstream
and the _getstream function definately returns a FILE object in the line
stream.c >>>>>>
retval = (FILE *)__piob[i];
but later it tries to read from the FILE stream using fgets. The call stack here
is
fgets
_lock_file
There is an exception in _lock_file I've figured out what it is and basicaly the
system thinks the FILE structure is a _FILEX structure and tries to access a non
existant member variable so it asserts.
void __cdecl _lock_file (
void *pf
)
{
if ( (pf >= (void *)_iob) && (pf <= (void *)(&_iob[_IOB_ENTRIES-1])) )
_lock( _STREAM_LOCKS + ((FILE *)pf - _iob) );
else
EnterCriticalSection( &(((_FILEX *)pf)->lock) );
}
An exception is raised at
EnterCriticalSection( &(((_FILEX *)pf)->lock) );
I have a STRONG suspision its a simple project settings or maybe library linkage
problem since I have the exact same code in another application and it works
fine....
Working on VC6 SP5
Windows 2000 SP2
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Seems like you're mixing code using single-threaded and multi-threaded CRT. FILEX is just FILE in single-threaded CRT. In MT version, FILEX aggregates FILE with critical section.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Thats a bit weird.
I had another look at my settings and changed from Static Linkage to Dynamic Linkage, In statis linkage it was using the Debug Multithreaded Archive and having the problems and in the dynamic linked build its using the Dynamic Multithreaded DLL and now it works?
Is this an issue with the Archive vs the DLL ? As I would really like to finaly make a static build and stop with all the installation problems i have.
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Jawache wrote:
Is this an issue with the Archive vs the DLL
I'm not sure what are you talking about here. By 'archive' you mean 'static library' or something else?
Your app is single .exe, or you have .exe and your own .dlls? Are you using 3rd party libraries?
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Yeah i think i know whats going on now.
Yes i am using a third party library thats been dynamicaly linked and i had my application statically linked. So the object code to create the FILE object was staticaly linked in my app. Whereas the code to access the FILE object was in the shared DLL version of the library.
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Hi,
We have an application which connects to a database across a network and
want to prevent machines from hibernating.
We can catch the WM_POWERBROADCAST message and check for the PBT_APMQUERYSUSPEND message in the WParam and display a message. So something like this:-
ON_MESSAGE( WM_POWERBROADCAST, OnHibernate )
LRESULT CMainFrame::OnHibernate(WPARAM WParam, LPARAM LParam)
{
if( WParam == PBT_APMQUERYSUSPEND )
{
AfxMessageBox( _T("About to hibrenate or standby!"), MB_OK );
return BROADCAST_QUERY_DENY ;
}
return WParam;
}
The first time we run the app and select hibernate or suspend it is fine and the message pops up correctly however thereafter the screen goes greyed as usualy on a shutdown and the message is not displayed until I give my application focus. Obviously there is something else I need to do to handle the message.
Any suggestions?
Thanks
Dave
|
|
|
|
|
From MSDN docs on PBT_APMQUERYSUSPEND:
lParam: A DWORD value that specifies action flags. If bit 0 is 1, the application can prompt the user for directions on how to prepare for the suspension; otherwise, the application must prepare without user interaction. All other bit values are reserved
...
The system allows approximately 20 seconds for an application to remove the WM_POWERBROADCAST message that is sending the PBT_APMQUERYSUSPEND event from the application's message queue. If an application does not remove the message from its queue in less then 20 seconds, the system will assume that the application is in a non-responsive state, and that the application agrees to the sleep request
Maybe you should check this lParam bit?
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Thanks,
I had tried checking that bit and only displaying the message then but made no difference.
But now have found the problem is due to showing the warning message box as part of the message handler. If I process the message first and return BROADCAST_QUERY_DENY and then display my message box it all works fine
Dave
|
|
|
|
|
Dave Merrifield wrote:
If I process the message first and return BROADCAST_QUERY_DENY and then display my message box it all works fine
It makes perfect sense, since you have only 20 seconds to process the message. If user doesn't close the msgbox quite fast, Windows will ignore returned value.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Yep does make sense now it was when you reminded me of the 20 second time limit it occured to me.
Thanks for your help Tomasz.
Dave
|
|
|
|
|
I've spotted this in one of the files I'm maintaining:
#ifdef AFX_COLL_SEG
#pragma code_seg(AFX_COLL_SEG)
#endif A quick look on MSDN tells me that the code_seg part "specifies a code section where functions are to be allocated". What does that actually mean, what's happening here? MSDN also says I can reset allocation with #pragma code_seg() - do I need to do this, as it's not allready done?
Dylan Kenneally
London, UK
|
|
|
|
|
Comments in MFC source (afxver_.h) suggest that this is 'swap tuning'. Using code_seg changes the ordering of the functions in resulting executable; by placing commonly used functions together you may get some performance boost.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|