|
Here's one way (I assume you want to load from a file):
1. Add a picture control to the dialog, be sure to set its type to "bitmap". Change to ID to something meaningful.
2. Using the ClassWizard add a member variable of type CStatic for the control, call it m_Picture .
3. Add the following to your class declaration:
HBITMAP m_hBM;
4. Add the following code to the dialog's OnInitDialog handler:
HBITMAP m_hBM = reinterpret_cast<HBITMAP>(
LoadImage(
NULL,
_T("C:\\130x130.bmp"),
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE
)
);
m_Picture.SetBitmap(m_hBM);
5. Add the following in a WM_DESTROY handler:
DeleteObject(m_hBM);
Steve
Steve
|
|
|
|
|
Hi Guys,
In "File View" of my visual studio's work space when i "Right Click->Add Files to Folder" its giving me one error like "Microsoft Developer(R) Studio has encounted a problem and you need to close it..............." When i am closing it then its not even closing rather the hour glass comes and it's taking too much time. For your information i am working on a visual c++ project.I will appreciate if any one can tell what is the cause and how to fix it.
|
|
|
|
|
This seems to be a application bug. Try this: open the file in your Visual Studio and rightclick in the file window. There is also a menuitem 'Add to project' (or similar). If this doesn't work you have possible to reinstall your DevStudio.
|
|
|
|
|
Thanks a lot. Have a nice day.
|
|
|
|
|
I want to use my exe (installed in someone's computor) to forbid someone printing by his local printer or network printer!
how to implement?
thanks
|
|
|
|
|
Hi,
I have an MFC application in which I take records from a table in one database (Let's say database A, table A), and insert them into a table in another database (Let's say database B, table B). This is a sort of "database conversion".
The thing is, that in database A the record numbers are not necessarily consecutive (for instance there could be records #1,2 and 4), But in database B the records are inserted to table B with an automatic record number.
For instance:
Table A (Database A) Table B (Database B)
-------------------- --------------------
record #1 ------------> record #1
record #2 ------------> record #2
record #4 ------------> record #3
My problem is that I need to save the record numbers of the records in database/table A, in order to use them later (for database relationship purposes).
(For instance - i need to know that record #3 in database B was actually record #4 in database A).
I used a CArray object to keep the indexes of the records of database/table A, but after I do the "database conversion" I need to use the indexes (of database A) in another application. how can I do this?
By the way, I am using C++ (and MFC) in .Net 2003.
|
|
|
|
|
May be you can add an extra field in the table in database B to save the index?
|
|
|
|
|
yeah - that's the solution I wanted to avoid..
|
|
|
|
|
Can you not turn off the "auto increment" property of the one column in table B, and just make it a number-type column?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
hi,
i've 2 classes .......
class1
{
public:
CString str1;
get();
put();
}
class2
{
public:
CString str2;
class2(CString str)
{
str2 = str;
}
}
when i'm calling constructor of class2 in put function of class1 str2 gets set ... but when i access str2 in a function of class2, it is blank .... can't we use a constructor to set values of members in this way?
Thanks,
Kranti
|
|
|
|
|
What you are actually doing is to construct an object of class2 in class1. class1's object is initializing the class2's objects's variable to a certain value. But any more objects of class2 which you create outside will not be affected by that.
Unless you are using a hierarchy, like class1 is derived from class2. So now you could create an object of class1, and it will contain all non-private members of class2 as well.
this is this.
|
|
|
|
|
Kranti1251984 wrote: but when i access str2 in a function of class2, it is blank ....
Where is the object of class2 created? Are you using the same class2 object to access the member function?
Vini
|
|
|
|
|
object of class1 is being created inside a function of class2 to set the value of a member of class1 thru' a parameterized constructor of class2 as
class1
{
public:
CString str1;
get();
{
//get str1
}
put()
{
class2 c2(str1);
}
}
class2
{
public:
CString str2;
class2(CString str)
{
str2 = str;
}
}
Thanks,
Kranti
|
|
|
|
|
Kranti1251984 wrote: put()
{
class2 c2(str1);
}
If you are using the same c2 object to access the member function, you will get the value of the variable str2. The object c2 is destroyed once you exit the put() function of class1.
Vini
|
|
|
|
|
In ur case lifetime of the object of class2 is within the class1::put().To check this u can define the destructor of class2 and check it
never say die
|
|
|
|
|
Within class1::put, c2.str2 will be equal to str1, what is the problem again?
|
|
|
|
|
i wanted to use str2 thruough out. It's ok now, solved it by using a member function to set the value in class1.
Thank you all!
Kranti
|
|
|
|
|
Hello,
I have an unmanaged document class in my code, that looks like this
class MyDocument
{
public:
MyDocument()
{
}
~MyDocument()
{
this->CleanUp();
}
bool CleanUp()
{
}
};
Then I have a pointer to it in my Form (that is a .NET managed class, a Form object).
MyDocument *document;
Inside the Constructor of the form, I initialize the document with
this->document = new MyDocument();
The Dispose() function of the Form has the code:
if(disposing && document)
delete document;
During the lifetime of the program, several time i need to free the resouces of the document class and allocated new ones, like this:
document->CleanUp();
However when I close the application (i.e. the destructor of the form runs), I get an error that CleanUp() can't access the memory (because it is not accessible, may be it has been cleaned already).
Could any one please explain why I can call CleanUp() anywhere in my program and I get no error (the memory gets cleaned as expected), and I get a 'Memory Not Accessible' error when I call it from the destrcutor. (I tried to comment out the code in the destructor, and the application gets cured i.e. It produces no errors/exceptions etc.
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
signbit wrote: bool CleanUp() { // Clean all the memory using 'delete' operator }
Make sure you set all pointers to NULL after deleting them.
For eg:
<font color=blue>delete</font> pointer;
pointer = NULL;
Nibu thomas
Software Developer
|
|
|
|
|
Yeah, I always set the pointer to NULL after it's been deleted to avoid confusion, my code looks like:
if(NULL != pointer)
{
delete pointer;
pointer = NULL;
}
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
signbit wrote: Yeah, I always set the pointer to NULL after it's been deleted to avoid confusion, my code looks like:
Try to debug and find out. You should find something interesting.
Set a breakpoint inside CleanUp , and step through.
Nibu thomas
Software Developer
|
|
|
|
|
Pointed Noted I'm trying it out...
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
Why do you need such a code? As far as I remember "delete NULL;" is a valid instruction, that is delete knows about NULL and know how to handle it. Basically, there is something similar to your "if(NULL != pointer)" within implementation of delete, so there is no need for extra one.
|
|
|
|
|
No need to check for NULL before deleting a pointer - it's a benign operation, as free(...) in C.
--
The Blog: Bits and Pieces
|
|
|
|
|
In C++ delete NULL is a NOP - It does nothing. You don't need the if statement in the code above, the following is equivalent:
delete pointer;
pointer = NULL;
If you put the if you're checking twice and the code is longer then need be (more chance of making a mistake).
Steve
|
|
|
|