|
In your previous example, 'Bitmap' variable was local. And CBitmap destructor deletes the bitmap, so handle passed to m_Image becomes invalid.
What happens on W2K when you invalidate the static window? Does it still show the picture?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
You are right! But I found this solution on my own when I remembered that it helped a time ago when I was trying to set icons in a CTreeCtrl (of course it was your hint if I remember well, thanks once again). After invalidation picture dissapears on Win2000. When I made Bitmap global on win98 finally bitmap works properly. Thanks anyway, but do you know why this problem occurs (I mean why Win98 behaves different from Win2000 in such basic thing in my opinion).
Greetings
Mariusz Popiolek
|
|
|
|
|
Mariusz Popiolek wrote:
mean why Win98 behaves different from Win2000 in such basic thing
Probably W2K invalidates/updates window right after STM_SETIMAGE.
So you were able to fix the problem with clipboard as well?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Yes, after a long period of time (I noticed this issue on previous sunday I suppose), but I wasn't really trying to solve it (I was doing more urgent things, but finally I had to fix it). Now my VBA program works correctly on Win98 and Win2000 (I'm using clipboard to create custom toolbar icons in MSOffice, as far as I know that's the only way and the first thought which came to my mind was to do this in dll, so I can combine bitmaps in one dll).
Greetings
Mariusz Popiolek
|
|
|
|
|
I defined 2 classes - A and B;
class A {
public:
B GetB() {
return B();
}
};
class B {
public:
A GetA() {
return A();
}
};
since both classes make use of eachother, i get an "error C2501: 'A::B' : missing storage-class or type specifiers" when I try to compile.
Is this sort of thing supported with C++?
|
|
|
|
|
Someone else may give a better example but this is possible through inheritance.
class A
{
protected:
int Age;
int GetAge()
{
return Age;
}
};
class B:A
{
int f;
void Foo();
};
Access to the variable Age is available as B inherits A
B b;
b::A.Age;
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
use a forward declaration:
class B;
class A
{
public:
B GetB();
};
class B
{
public:
A GetA();
};
and put implementation in the .cpp file
|
|
|
|
|
The class B isn't defined at the point you're trying to use it:
class A {
public:
B GetB() { return B(); } <font color=red>
}; thus you get the error. Add a forward declaration of B so the compiler knows what it is:
class B;
class A { ...
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
use a forward declaration of class B.
class B;
class A
{
public:
B GetB() {
...
}
class B
{
A GetA () {
...
}
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
At the point where you define class A compiler knows nothing about identifier B, that's why error occurs. Put this before declaration of A:
class B;
Now compiler knows that B is a class, but that's not all. To return B from function compiler must know declaration of B, so you have to return pointer to B, not object B(when compiler see pointer to class, it doesn't have to know declaration of this class). Also you can't call constructor of B at this point, so just declare function in a class A and make a definition after a declaration of class B.
Greetings
Mariusz Popiolek
|
|
|
|
|
LOL!
It's like a whole class full raising their
hands all at once 'cause it's one of the
answers everyone has just waiting for an
opportunity to get out.
|
|
|
|
|
Yeah well, what can I say. It was an easy question and I need to get my post count up a little
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
When I have seen this question there wasn't any answers, but when I finished answering the post(I tried the code in VC to be sure if it's working), there was already plenty of answers .
Greetings
Mariusz Popiolek
|
|
|
|
|
To avoid this error, you can 'forward declare' class B.
class B;
class A
{
public:
B GetB() { return B(); }
};
class B
{
public:
A GetA() { return A(); }
};
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
|
I have listctrl with rows(vary) and 3 column
let say first column is a,second is b, third is c;
I want the data of a, b, and c of the row.
so i tried the following ways
<br />
for(int i=0;i<numberOfRow;i++)
{<br />
CString dataA = myListCtrl.GetItemText(i,0);<br />
CString dataB = myListCtrl.GetItemText(i,1);<br />
CString dataC = myListCtrl.GetItemText(i,2);<br />
<br />
LV_ITEM lvitem;<br />
ZeroMemory(&lvitem, sizeof(lvitem));<br />
lvitem.mask = LVIF_TEXT | LVIF_STATE;<br />
lvitem.iItem = nIndex[i]; <br />
lvitem.iSubItem = 1; <br />
myListCtrl.GetItem(&lvitem); <br />
<br />
dataA = lvitem.pszText;<br />
}<br />
both ways gave me let say dataA value as junk. How can I get back my item text???
Thanks
|
|
|
|
|
Can't say why the first way is failing, but the second doesn't work because you're not providing a buffer for the control to store the text in. You need to set pszText and cchTextMax to the address and size of the buffer before calling GetItem().
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
let me try
Thanks Michael
|
|
|
|
|
If theres a problem with file strFile0 and an exception is thrown, I want the error message to have the name of the faulty file. This name is gotten in the try block. I dont think I can pass it in the catch argument:
catch(CFileException e, strFile0)
{
CString temp;
temp.Format("Error opening file : %d", e.m_cause);
AfxMessageBox(temp);
return -1;
}
}
So how do I communicate it to my messagebox in the catch block?
Appreciate your help,
ns
|
|
|
|
|
catch(CFileException e, strFile0)
{
CString temp;
temp.Format("Error opening file : %d ", e.m_cause);
AfxMessageBox(temp + e.m_strFileName);
return -1;
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thats convenient! You did however mean to remove the strFile0 argument I was trying to pass in, right ? I am off to look up CFileException and see what all it exposes...
Many thanks,
Appreciate your help,
ns
|
|
|
|
|
Yeah that way, i mean if u correct ur own mistakes u wont ever make them again For ur own good (ok, i forgot )
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
CFileException has m_strFileName member which contains file name.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Is it possible to perform development in Visual Studio by having the libraries of a third-party component on a remote machine?
Any suggestions?!
|
|
|
|
|
Aehm, add the path to the library folder on the remote machine to your LIB path?
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|