|
When I used that code,there was an error return,about "GetActiveDocument()"
but I change it to this"
CMainFrame * pWnd =dynamic_cast<CMainFrame *>(AfxGetApp()->m_pMainWnd);
ASSERT_VALID(pWnd);
CMyDoc * pDoc =dynamic_cast<CMyDoc *>(pWnd->GetActiveDocument());
ASSERT_VALID(pDoc);
and it work properly.
Anyway,thanks for your help
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
Unless you have multiple inheritance somewhere in your class design, I don't see how dynamic_cast ing can make a difference (and even so I don't see it either). Would you mind elaborating a little more?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
This is my first try:
CMyDoc * pDoc=(CMainFrame*)(AfxGetMainWnd())->GetActiveDocument();
error C2039: 'GetActiveDocument' : is not a member of 'CWnd'
My second attempt:
CMainFrame * pWnd =dynamic_cast<CMainFrame *>(AfxGetApp()->m_pMainWnd);
ASSERT_VALID(pWnd);
CMyDoc * pDoc=(CMyDoc*)(pWnd->GetActiveDocument());
and work properly,it's not related to dynamic_cast .
My mistake was about convert CMainFrame to CDocument
I think you forgot one line in your answer,didn't you?;)
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
I see now... What I forgot was an extra pair of parentheses
<font color=#ff0000>(</font>(CMainFrame*)(AfxGetMainWnd())<font color=#ff0000>)</font>->GetActiveDocument(); On a side note, I'd suggest you do not use dynamic_cast when it is not strictly needed, because it incurs a run-time overhead. It is like killing flies with cannonballs, as a Spanish saying goes.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
What I forgot was an extra pair of parentheses
And also I forgot to type cast it to CMyDoc in my first try
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here."Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Is there any function that will return the current CPU speed?
If not I plan on using the number of clocks spent / Number of seconds since boot. The question then becomes, does anyone know of a function that will return the number of milli-seconds since boot???
I believe there this exact value resides in the CMOS somewheres, but I don't think in/out instructions are available in ring 3???
Any suggestions...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
HockeyDude wrote:
The question then becomes, does anyone know of a function that will return the number of milli-seconds since boot???
GetTickCount(). As for CPU info, check the System section here on CP.
--Mike--
Fetchez la vache!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
I'm already using the RTDSC instruction to find the clocks gone by. From this number i'd like to be able to calculate CPU frequency.
CPU speed = Clocks / time in seconds
What am I missing....how can I use GetTickCount to calculate CPU frequncy if i already have the clocks since boot?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
fCPU = clocks since boot / milliseconds since boot [kHz]
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Where do i get milliseconds if i already have clocks...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
GetTickCount , boy
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I use MSAccess,and I want to make connection string and it should be something like this:
(Provider=Microsoft.Jet.OLEDB.3.51;Data Source=c:vcdb.mdb;"
How can find out the last version of OLEDB provider that I have?
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
I met such an error message.What kind of error does it mean?
|
|
|
|
|
Means that pUserData does not point to a valid block of memory. That can be caused most likely by one of these reasons:pUserData has not been initialized and points to a random location.
- Your program has changed the value of
pUserData (by incrementing it, for instance), and the pointer does not refer to the proper original location.
- You ave freed the memory previously pointed to by
pUserData (with free(pUserData) , presumably) and yet you're trying to use the pointer.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes,I also think so.But usually I don't know where I change this value.For example,when I
insert a new resource and only compile(not rebuild all),sometimes I will get this error.
|
|
|
|
|
Another circumstance than can produce this kind of errors happens when you link several libraries compiled for different versions of the C run-time library.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You must also be careful of precompiled headers. They are recompiled when you do a build all, as well as when the ide recognizes a change that effects the pch. It doesn't always get this right!
Hope this helps,
Bill
|
|
|
|
|
Does anybody know where can i get an IRC demo or a way to make an IRC project under VC++ .NET?
|
|
|
|
|
I am trying to intercept some messages using OnCmdMsg. However, everywhere I look, I can not seem to find a good explanation for each variable in the function and what means what. How do these variables correspond to the actual On.... function variables once received by the view or whatever?
Is there anywhere to get more in depth info. I tried the MSDN etc but can not seem to find anything really useful unless I am looking at the wrong places.
Thanks.
|
|
|
|
|
virtual BOOL OnCmdMsg( UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo ); Overriding OnCmdMsg() lets you hook into and modify MFC's message map lookups. It's called in two instances, first when the UPDATE_COMMAND_UI logic is check to see if a handler exists for a particular command ID, and second to actually find the handler.
nID is the command ID, same as LOWORD(wParam) in WM_COMMAND. nCode is the notification code, same as HIWORD(wParam) in WM_COMMAND. pHandlerInfo is non-NULL when checking for a handler, or NULL when actually calling the handler.
I've only had to override this once, when doing a Netscape-type options dialog (tree on left, changing panels on the right). I checked for a code of CN_COMMAND (which is a special MFC constant) and called the current panel's OnCmdMsg() handler so it could handle button clicks and Enter keypresses.
--Mike--
Fetchez la vache!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Actually, what I would like to do is set a few key strokes as MASTER strokes. If pressed, it will do the same thing no matter who has the focus.
My other question is that will the messages like KeyUp etc go from the App down via the command routing. Will the Application be the first to get this message if the control DOES NOT have a message map entry for it. In the MSDN etc, it only mentions from Mainfrm, view docu ... but nothing from the controls etc.
THanks
|
|
|
|
|
Stan the man wrote:
If pressed, it will do the same thing no matter who has the focus.
Use accelerators for that.
Stan the man wrote:
Will the Application be the first to get this message if the control DOES NOT have a message map entry for it.
My MFC's a bit rusty now, but IIRC the window with the focus always gets first crack at the message. If that window doesn't handle it, then MFC takes over and routes it.
--Mike--
Fetchez la vache!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
C:\Windows\Desktop\Project2\Project.cpp(728) : error C2665: 'Stock::Stock' : none of the 3 overloads can convert parameter 1 from type 'char [30]'
Error executing cl.exe.
thanks
|
|
|
|
|
Marwan wrote:
thanks
You're welcome.
Post some relevant code, i.e., don't post the whole project.
Jon Sagara
What about ?
Sonork ID: 100.9999 jonsagara
|
|
|
|
|
Stock:: Stock()
{
}
Stock:: Stock(char*& cn, char*& st, char*& mt, char*& tom, int& iv, int& noos)
{
strcpy(companyName, cn) ;
strcpy( stockTicker , st);
strcpy( marketTraded , mt);
strcpy( typeOfManufacturing , tom);
initialValue = iv;
numOfOutShares = noos;
}
//...code
void main()
{
//...code
cin>>tempCN>>tempST>>tempMT>>tempTM>>tempIV>>tempNS;
*tempStock = Stock( tempCN, tempST, tempMT, tempTM, tempIV, tempNS); <-- the Error is here says the compiler
|
|
|
|