|
Take a look at CYourApp::InitInstance() . This is the appropriate place to inject a splash window and wait for it to terminate before proceeding with the rest of the program.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You can create non-modal splash window just at very beginning.
Proceed with application initialization, and then terminate splash dialog. You can also set a timer.
This will not block application when splash screen will be displayed.
|
|
|
|
|
I think you can set timer!
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
|
|
|
|
|
I am trying to debug my program because while running my driver program i encounter a bug and the error that the computer tells me is this:
" Unhandled Exception in Tictactoe.exe: 0x000005: Access violation"
this error occurred in my destructor for my CBoard Class
CBoard::~CBoard()
{
delete mpDefaultPen; <-- what is causing a exception to be thrown?
}
oh i used this pointer in my function
// Changes the Line color to the value entered
void CBoard::SetLineColor(CDC* pDC, COLORREF color)
{
// Sets color to mLine color
mLineColor= color;
// Construct a pen
mpPen = new CPen;
VERIFY(mpPen);
VERIFY(mpPen->CreatePen(PS_SOLID,5,mLineColor));
VERIFY(mpDefaultPen = pDC->SelectObject(mpPen)); <-- rite here
}
Does anyone know whats causing this bug to occur? anyways... thank you in advance for helping me... i very much appreciate all the help
|
|
|
|
|
You shouldn't delete mpDefaultPen , but rather select it back to pDC with SelectObject once you're done with the DC object. Check your documentation for SelectObject . The general scheme is as follows:
mpDefaultPen =pDC->SelectObject(mpPen);
pDC->SelectObject(mpDefaultPen);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
oh ok thank you Joaquin for the help. i forgot, i didnt create mpDefaultPen so i shouldnt delete it or it will cause me an error (i forgot what kind of error that is -- i think its the dangling pointer problem). again thank you for your help muchas gracias para me ayudarle is what is said right??
|
|
|
|
|
muchas gracias para me ayudarle is what is said right??
It's close. The correct sentence would be "Muchas gracias por ayudarme". You are welcome.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Will MFC programs written with VC++.net work for older platforms like Windows 98? Or I would have to distribute the MFC7 libraries? I'm having trouble getting things to run. Please help a newbie
|
|
|
|
|
David Z wrote:
I would have to distribute the MFC7 libraries?
yes,you have to distribute it
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
|
|
|
|
|
Thanks for the reply! Just one last thing, will the .net Framework be enough? or i'd have to distribute the individual .dlls?
|
|
|
|
|
You don't have to distribute all .net framework always,
Only need to distribute MFC7.dll (if I don't make mistake the name)beside this if you use some .net features (for example GDI+)you also need to distribute that specific dll
hope that helps
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
|
|
|
|
|
How do you write a Driver program in MFC to test a class you have created to be used in MFC? i know to some of you this might be a very dumb question but i am just starting in programming in MFC. thank you for your help. i very much appreciate it
|
|
|
|
|
A Driver program is simply a program that uses your class. For instance, say you have a class that can set two parameters, then perform actions on these parameters, here is an example.
<br />
class Arithmatic<br />
{<br />
int m_a;<br />
int m_b;<br />
<br />
public:<br />
Arithmatic () m_a(0), m_b(0)<br />
{<br />
}<br />
<br />
void SetA (int a)<br />
{<br />
m_a = a;<br />
}<br />
<br />
void SetB (int b)<br />
{<br />
m_b = b;<br />
}<br />
<br />
int Sum ()<br />
{<br />
return m_a + m_b;<br />
}<br />
<br />
};<br />
With this class, you could write a Driver, or test program like this.
<br />
int testArithmatic ()<br />
{<br />
Arithmatic x;<br />
<br />
x.SetA(10);<br />
x.SetB(20);<br />
<br />
ASSERT(x.Sum() == 30);<br />
<br />
return 0;<br />
}<br />
In this example you know what the desired result is for the two values 10 + 20, so assert that all of your functions work properly.
|
|
|
|
|
Thanks... i got it now... oh, i am going to do that now. oh, i have another question... i dont know if i placed the assert statements right in my destructor. can you help me?
here is what i did:
// Destructor
CBoard::~CBoard()
{
// Check for Deletion of Null pointers if the object
// is NULL dont delete it, else delete each ofthe objects
ASSERT(mpDefaultPen == NULL);
if (mpDefaultPen != NULL)
delete mpDefaultPen;
ASSERT(mpDefaultFont == NULL);
if (mpDefaultFont != NULL)
delete mpDefaultFont;
ASSERT(mpPen == NULL);
if (mpPen != NULL)
delete mpPen;
ASSERT(mpFont == NULL);
if (mpFont != NULL)
delete mpFont;
for (int r = 0; r < MAXROW; r++)
for (int c= 0; c < MAXCOL; c++)
{
delete mpGrid[r][c];
}
}
Did i place my ASSET macros right? i am trying to catch errors cause by deletion of NULL pointers which probably would cause memory leak.
|
|
|
|
|
When you ASSERT, you assert for something that you think should be true, so if the assertion is false it will return an error.
In your case you stated ASSERT(x == NULL), you will only get an error when x != NULL, this is the opposite of what you want.
Anyway, it is safe to call delete on a NULL pointer, this is part of the C++ standard. So your destructor can be changed to this:
<br />
delete mpDefaultPen;<br />
delete mpDefaultFont;<br />
delete mpPen; <br />
delete mpFont;<br />
|
|
|
|
|
Oh OK... thank you very much for the help....
|
|
|
|
|
why does this generate a link error?
class DEL1_API Cdel1 {
public:
static int int1;
public:
Cdel1(void);
// TODO: add your methods here.
static void test()
{
int1 +=10;
}
};
Thanks.
Steve
Not all who wander are lost...
|
|
|
|
|
You get an error because there is no actual variable instantiated for the class. All that you need to do is declare a global variable in the namespace of you class like this:
int Cdel1::int1;
Declare this in a CPP file somewhere, where your class is imlemented, otherwise if you declare it in a header, and the header is included in more than one CPP file, you will get a multiple defined link error.
|
|
|
|
|
|
Hi all, my question is more like electronic questions but it is easy ...
I wanna send some data to LPT, directly.
I don't want to print data on printer, i just want to send data to LPT, ok ?
Well, i have not problem to sending data (I used _outp function, and my OS is Win98).
I just want to know, when i send a Byte to LPT then i send a voltage to LPT pins ???
Look, first i got the pins voltages from LPT1 by Multi Meter Digital, it is a instroment which can show the voltage to you.
It is result:
Pin 2 (data pin 1) to Pin 9 (data pin 8): voltage is variable between -0.59 to +0.60
ok ?
Then i sent a data (a Byte like 0x55) in enormouse loop ...
Then i got the pins voltage again, but i got the same result (-0.59 to +0.60) !!!
Now, i wanna know did my data send in LPT port ???
Why the pins voltage didn't change ???
Please help me ...
I need fast reply
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I don't think that your meter can read the values quick enough to measure the voltage variations of the Parallel port like that. You will probably have better luck with an oscilliscope.
|
|
|
|
|
I want to write ActiveX with MFC7,but I can't find anywhere to add any property .Does anybody write anybody write ActiveX with VC7?
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
|
|
|
|
|
Oh,never mind ,I found it,I don't know why MS changes the interface in VC7 so much
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
|
|
|
|
|
Hi,
I'm having a bit of a problem linking my application using stl.
I have a library that uses the stl string. This is also used in a header file used by the application that links to the library.
I get a bunch of linker errors LNK4006 saying that std::basic_string is already defined in the lib.
Can anyone shed any light on what I need to do to overcome this?
|
|
|
|
|
The problem is that the std:basic_string object that you have is declared twice between your lib file and your application.
Is there a variable or a typedef in your project that is the same as a variable in the lib that you are using? Possibly in the header file that you mentioned.
Did you write the LIB?
|
|
|
|