|
Hi friends,
How can I get the name of file which is opened by the user by means of open dialog box in a document/view architecture?
Thank you,
Azadeh
|
|
|
|
|
|
Thank you! It worked well.
|
|
|
|
|
I want to open it by myself to be able to read and write to and from it.
|
|
|
|
|
Does CDocument::GetPathName() help you?
< edit > OOps, did not read enough!
You are asking if you can close the file opened by the framework.
Probably the answer is 'depends'.
Cant you simply override CDocument::OnOpenDocument() with your own load code?
--
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
As you said , I overrided CDocument::OnOpenDocument() , but I simply open a text file and in that case this
function isn't been called.I think it only opens files that are saved with serilizing and using CArchive and it doesn't
open my text file.I used a text file to save graphic items that are drawn by the user in my project and I want user
can open the file in a symbolic way then I draw the items using text file.However this is enough for me that I can
get the name of file even if it hasn't opened really.I thought it opens file and I can not open it simultanously.But
even for a file that is saved with the CArchive format, it seems that it opens the corresponding file and then close
it because I can open the same file at that time.
|
|
|
|
|
Just a quick question, when I have a static member pointer var..
class Poo {
static Poo * _poo
}
-- implemented
Poo * Poo::_poo = new Poo();
Poo::Poo()......
Do I look after the destruction of the pointer or does that happen automatically
Cheers
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Jawache wrote:
Do I look after the destruction of the pointer or does that happen automatically
Typically anytime you use the new operator to allocate memory on the heap you need to handle the deletion of it when you are through.
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Here are some points to consider:
1. If the value of _poo will never change, in other words, it will never be reassigned to a different object, then:
2. If the value of _poo (as you have it) will change, then you will obviously need to free the memory that it points to before reassigning it. Otherwise you'll have memory leaks.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Hi,
I am developing an application that shows the current file path in an address bar. I am using a Cedit control to display the filename, I do not use a CComboBox as I do not want to keep a history list.
I would like to show an icon next to the full path name, just like explorer does.
Is it possible to display an icon in a CEdit control. Should I use custom drawing?
Please help,
Woody
|
|
|
|
|
Woody Green wrote:
Should I use custom drawing?
Yep!
Max.
|
|
|
|
|
If you want the icon to really be in the edit control, then you're going to have to do owner draw.
But wouldn't it be simpler to have a small static control next to the edit one, and display the icon in
that? If you had a button rather than a static control, you could add functionality (e.g. change associations)
Iain.
|
|
|
|
|
Yes, if you want to put an icon inside a CEdit you must draw yourself the control...
But I think it would be easier to use a CListCtrl and editing labels if you need it, if you need only visualization, it would become easier.
regards
|
|
|
|
|
Hi Joan,
I did as you suggested and used a CListCtrl, works perfect! It's just what I needed and indeed much easier.
THANKS!
|
|
|
|
|
i use the fucntion:
"WINOLEAPI OleCreateLinkToFile(...)" to create some file links(show the file icons just like in CListCtrl)in my CRichEditCtrl Control,The result is successful,But it takes me about 20 second(Celeron 1G + 256M SDRAM).I want to known some more quick method to do.Any help is appreciated.thanks!
C/C++ code fans
|
|
|
|
|
I'm using STL vector containing some pointers. The only changes i make to it is to add values using push_back . I also keep an iterator which starts from the beginning and only grows by ++, being checked not to pass the end .
The problem, while debugging: sometimes when i try to access the iterator , the application is blocking on that line.
Could the iterator become invalid because of the vector growing?
rechi
|
|
|
|
|
Bogdan Rechi wrote:
Could the iterator become invalid because of the vector growing?
I sure wouldn't think so, are you using something like this:
vector<int*> vect;
vector<int*>::iterator iter;
int a, b, c, d = 1;
vect.push_back(&a);
vect.push_back(&b);
vect.push_back(&c);
vect.push_back(&d);
for(iter = vect.begin();iter != vect.end(); iter++)
cout << *iter << endl;
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Nick Parker wrote:
are you using something like this
Yes, something equivalent.
The difference: int * is a MyStruct * and cout << *iter; is an (*iter)->m_member access.
What's wrong?
rechi
|
|
|
|
|
Bogdan Rechi wrote:
What's wrong?
This works for me:
struct MyStruct
{
int data;
};
void main()
{
vector<MyStruct*> vect;
vector<MyStruct*>::iterator iter;
MyStruct a, b, c, d;
a.data = 1;
b.data = 2;
c.data = 3;
d.data = 4;
vect.push_back(&a);
vect.push_back(&b);
vect.push_back(&c);
vect.push_back(&d);
for(iter = vect.begin();iter != vect.end(); iter++)
cout << (*iter)->data << endl;
}
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Solved!
Sorry, it was not quite equivalent. It's more like this:
vector<int*> vect;
vector<int*>::iterator iter;
int a, b, c, d = 1;
vect.push_back(&a);
iter = vect.begin();
vect.push_back(&b);
vect.push_back(&c);
vect.push_back(&d);
for(;iter != vect.end(); iter++)
cout << *iter << endl; The iterator becomes invalid because of the vector growing.
Thank you!
rechi
|
|
|
|
|
Bogdan Rechi wrote:
I also keep an iterator which starts from the beginning and only grows by ++, being checked not to pass the end.
What do you mean by that ? I think the iterator is simply not valid.
Max.
|
|
|
|
|
Take a look at the thread above. Indeed, the iterator was not valid.
rechi
|
|
|
|
|
How to get the HINSTANCE of a dll?
Is there a way to get the HINSTANCE from a dll,
without saving the HINSTANCE from the DllMain or
calling GetModuleHandle("DLLName")?
I want to use the HINSTANCE in a COM-Object, thus
its not elegant to hand over it from the DllMain.
Otherwise the dll should exists with different names,
witch make it inconvenient to use a filename in the code.
Thanks
Juergen
|
|
|
|
|
I have a trouble with a CButton derived class.
The code is like the following:
class CMyButton : public CButton
{
....
}
CMyButton::SetColor(...)
{
...
Invalidate();
...
}
CMyButton::OnPaint()
{
...
CPaintDC dc(this);
...
}
------------------------------------
First, I created a CDialog derived class with a "Group Box" control inside and a DDX variable associated called MyGroup. I changed the type of MyGroup variable in CMyButton. Calling the SetColor() method of MyGroup, the Invalidate() causes the OnPaint() execution and the control is successfully drawn.
Then I changed the CDialog derived class with a CDialogBar derived class.
I have the following problems:
1) The Invalidate() method doesn't causes the execution of the OnPaint();
2) If I change the Invalidate() statement with the direct call of OnPaint(), the execution of the statement "CPaintDC dc(this)" fires the following assertion of "void CWnd::AssertValid()"
ASSERT((CWnd*)p == this);
Can you help me?
Thank you.
|
|
|
|
|
Is here any API to work with WinPopup massages.
Thank you
viliam
|
|
|
|