|
Hi everybody,
Can you tell me how to get the index of the current hot item(under the mouse) of the CListCtrl. I used the member function "GetHotItem", but it always return -1, why
Thanks!
HuChJ
|
|
|
|
|
|
Hi guys,
Last friday I posted a question about a strange exception that was thrown (when I called a messageBox in the OnNewDocument)! With the help of some guys here (thanks to RaGe, Neville Franks, FranzKlein and basementman ), I finally solved the problem !
In fact, when I call MessageBox in the OnNewDocument function, the Framework make a call to the GetMessageString(UINT nID, CString& rMessage) function (from CMainFrame). In my case, this function was overloaded to support multiple languages for help text for the toolbar buttons (text in the status bar). I was then calling a funtion from a class that hasn't been instancied (the class for language texts).
void CMainFrame::GetMessageString(UINT nID, CString& rMessage) const
{
if (ID_SAVE <= nID <= ID_SELECTTV)
{
rMessage.Format(localtext->nr(nID));
}
else
CFrameWnd::GetMessageString(nID,rMessage);
}
The function was called with an nID equal to 57345 wich isn(t corresponding to any of my buttons (range from 20 to 33). So the error was in the line:
if (ID_SAVE <= nID <= ID_SELECTTV)
wich has to be replaced by:
if ( (ID_SAVE <= nID) && (nID <= ID_SELECTTV) )
otherwise, I call localtext->nr(nID); and this class hasn't been instancied for now !!
So again, a big big thanks to all the guys who help me to solve this problem that was wrecking my mind !
|
|
|
|
|
Glad to hear you have finally found out ... very tricky, this one bug
~RaGE();
|
|
|
|
|
Great to hear you found it. Thanks for letting us know. Now you can take it easy for the rest of the week.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Dear All,
I am developing an application (using VC++ Version 6 for Windows 2000/XP/NT) in which I want to retrieve the list of all the "File type extenstons" present in my system.
I suppose that there must be some API for retrieving this list.
To see the list go to:--
Start=>Settings=>Control Panel=>Folder Options.
Then select File Type to get list all file type extenstions
Thanks in advance.
Rohit Dhamija
|
|
|
|
|
This is stored in the registry under HKEY_CLASSES_ROOT.
So Open this key using registry functions (RegOpenKey ) and then you can enumerate the subkeys with RegEnumKey . In these, look for the ones starting with a point '.' and there you have your file extensions. In the key are stored the associated application, usually in shell\command\open.
For example, under HKEY_CLASSES_ROOT\.txt is stored Text Files .
And under HKEY_CLASSES_ROOT\.txt\Text Files [edit] Sorry, it is HKEY_CLASSES_ROOT\Text Files [/edit] is stored Shell\Command\Open\"Notepad %1"
~RaGE();
|
|
|
|
|
Hi Rage,
Thanks a lot. That was very useful.
Rohit
|
|
|
|
|
Hi,
Have anyone ever played D&D games? I want to write a
program(in console mode) that will give you a random
number, so I write the Die class. But I have tons of
errors even I have debugged it so many times.(still
tons of) I hope some of you would help me out here.
There are 18 errors, 1 warning
This is how I did that:
I use VS.Net, Visual C++ => Win32 Project => console
application => empty project.
I divided it into three files, the driver, the implementation
and the header. Here is the code:
<br />
<br />
#include "Die.h"<br />
#include < iostream ><br />
using namespace std;<br />
<br />
void main()<br />
{<br />
Die d1, d2;<br />
Die d3(10), d4(100);<br />
<br />
cout << "d1\td2\td3\td4" << endl;<br />
<br />
for (int i=0; i<10; ++i)<br />
{<br />
d1.roll();<br />
d2.roll();<br />
d3.roll();<br />
d4.roll();<br />
<br />
cout << d1.getValue() << '\t';<br />
cout << d2.getValue() << '\t';<br />
cout << d3.getValue() << '\t';<br />
cout << d4.getValue() << '\t';<br />
}<br />
}<br />
<br />
<br />
#include <cstdlib><br />
#include <ctime><br />
#include "Die.h"<br />
<br />
Die::Die()
{<br />
nSides = DEFSIDES;<br />
value = 1;<br />
}<br />
<br />
Die::Die(int sides)<br />
{<br />
nSides = sides;<br />
value =1;<br />
srand (unsigned (time null)));<br />
<br />
}<br />
<br />
void Die::roll()
{<br />
value = (srand()%nSides)+1);<br />
}<br />
<br />
<br />
#ifndef DIE_h<br />
#define DIE_h<br />
<br />
const int DEFSIDES = 6;<br />
<br />
class Die<br />
{<br />
public:<br />
Die();<br />
Die(int);<br />
<br />
void roll();<br />
<br />
int getValue() const ( return value; )<br />
<br />
Private:<br />
int nSides;<br />
int value;<br />
<br />
};<br />
<br />
#endif<br />
<br />
|
|
|
|
|
|
I've changed a few things in youre code. Does this work???
// DieTest.cpp
// the driver
#include "Die.h"
#include <iostream.h>
void main()
{
Die d1, d2;
Die d3(10), d4(100);
cout << "d1\td2\td3\td4" << endl;
for (int i=0; i<10; ++i)
{
d1.roll(); // roll() is modifier
d2.roll();
d3.roll();
d4.roll();
cout << d1.getValue() << '\t'; // getValue() is asscessor
cout << d2.getValue() << '\t';
cout << d3.getValue() << '\t';
cout << d4.getValue() << '\t';
}
cin.get();
}
// Die.cpp
// the implementation
#include <stdlib.h>
#include <time.h>
#include "Die.h"
Die::Die() // Die() is a constructor
{
nSides = DEFSIDES;
value = 1;
}
Die::Die(int sides)
{
nSides = sides;
value = 1;
srand( (unsigned)time( NULL ) );
}
void Die::roll() // roll() is a modifier
{
value = (rand()%nSides)+1;
}
int Die::getValue()
{
return value;
}
//Die.h
// the header
#ifndef DIE_h
#define DIE_h
const int DEFSIDES = 6;
class Die
{
public:
// constructor
Die();
Die(int);
void roll(); // modifier
int getValue(); // asscessor
private:
int nSides;
int value;
};
#endif
|
|
|
|
|
It reduces the error number from 18 to 10. I think there
are newer errors in those 10 errors.
One think I don't understand is why did you add
cin.get();
at the end of the driver?
But thanks for your reply. If you have more time,
can you please check it once more. If you can
actually copy the code and work in you VS.net would
be greatly appreciated. I just started learning
C++ and I'm exhausted now. (But I will be working
till the problems are solved) Hope you would help me.
Thanks.
|
|
|
|
|
Code posted above works fine for me, so I do not know why you still have 10 errors.
cin.get() is just waiting for a key to be pressed, so that the app does not exit right away. This is done by default in VC6++, so it is not useful.
I put it here once again (I did not change anything in the .h):
#include "stdio.h"
#include "stdlib.h"
#include <iostream.h>
#include "time.h"
void main()
{
Die d1, d2;
Die d3(10), d4(100);
cout << "d1\td2\td3\td4" << endl;
for (int i=0; i<10; ++i)
{
d1.roll();
d2.roll();
d3.roll();
d4.roll();
cout << d1.getValue() << '\t';
cout << d2.getValue() << '\t';
cout << d3.getValue() << '\t';
cout << d4.getValue() << '\t'<<endl;
}
}
~RaGE();
|
|
|
|
|
I got it, I see what's wrong.
I used <iostream> instead of <iostream.h> as posted.
So I have to include using namespace std;
After that, all those 10 errors are gone. Thanks.
|
|
|
|
|
VW_Red_Jetta wrote:
I used instead of as posted.
You probably mean <iostram> instead of <iostream.h>
Use the formatting < and > from the formatting bar under the text window, when replying / posting code, otherwise they will be interpreted as html tags. Or simply write < > directly.
~RaGE();
|
|
|
|
|
|
whenever i use goback() and goforward();i get empty dialogbox when i complete navigation.
|
|
|
|
|
Web Crawler or Web Spider Books
I am looking for any books on writing web crawlers or web spiders and maybe someone knows the difference between the 2. If you know of any good books please let me know also if possible I am looking for books with c++. Thanks for your time.
|
|
|
|
|
how to navigate bakward and forward in a webbrowser control.
|
|
|
|
|
|
how can I use "switch" statement in mfc applications, spcially in the toolbars, where the user can press
one toolbar->circle icon->draw circle. user can repeat or select new retangle/shape
same toolbar->rectangle icon->draw recnagle. user can repeat or select new circle/shape
same toolbar->particualr shape icon->draw that shape. user can repeat or select new retangle/circle
e.g.
switch(toolbar){
case(circle)
{
//draw it}
case (retangle)
{
//draw it
}
case(paricular shape)
[
//draw it
}
}
thanks
shanila
|
|
|
|
|
I would use the class wizard to generate indiviual handlers for the buttons pressd on the tool bar:
OnCirclePressed() {...;} OnRectanglePressed() {...;}.
If you want to pass it on to another function to handle the command in switch statement then create something like this:
void CMyWnd::DrawShape(UINT ctrlID)
{
.....
switch(ctrlID)
{
case IDCIRCLE:
break;
case IDRECTANGLE:
break;
case IDPACULARSHAPE:
break;
}
}
Trust in the code Luke. Yea right!
|
|
|
|
|
1. MFC dialog app is created
2. 2nd modeless dialog is created with extended style WS_EX_APPWINDOW, it's then shown and updated. The parent is set to null or desktop with SetParent(NULL) or SetParent(GetDesktopWindow())
3. Main dialog window is minimized, and as it is, the taskbar space for the non-modal disappears and the non-modal dialog is also minimized
4. NO, i repeat NO messages at all are sent to the non-modal dialog such as you would expect (ex. WM_SIZE message).
My Question is simple, what the heck is going on? How does one stop MFC from stealing the non-modal dialog's messages and reducing it automatically and removing it's taskbar space?
So far no one has been able to answer this
hey
|
|
|
|
|
Hi,
I have a MFC application that contains a recursive function. After going in approx 4500 - 4900 levels deep the application crashes without an error. It just disappears from the screen. I am assuming that the recursion is going so deep that it is killing the stack.
Is there a way to check for this and return before the stack overflows?
Here is my code.
void CMyAppDlg::DoWork(int i)
{
if(i == 4900)
return;
DoWork(i+1);
}
void CMyAppDlg::OnButton1(int i)
{
AfxMessageBox("Starting work!");
DoWork(0);
AfxMessageBox("Done working!");
}
I can probably implement my method without recursion (its a tree parse) but I'd like to know if there is a solution to this. Any help will be appreciated.
Cheers,
Rahul
http://www.cs.cmu.edu/~kingtiny
|
|
|
|
|