 |
Author |
Message |
RoobyDoo

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
I seem to be having lots of problems with this, are there any examples around I can get things to work how I expect under VisualC++ 6, but under 2005, I either get ignored (dlg.DoModal() returns instantly with ID_CANCEL), or it crashes with an assertion failure.
Under 2005 I've tried two different ways so far (both using code in the overridden CFileDialog methods)
Creating a dialog resource and using SetTemplate in the dialog constructor. This reserves the space at the bottom of the dialog, but doesn't show any of the controls, so I just get a lot of blank space.
Secondly, not bothering with SetTemplate, and creating my own controls manually in OnInitDone. The controls appear and are usable, but I don't get any messages about them. I've tried writing OnWndMsg & WindowProc handlers just in case I wasn't asking for the correct message, but no messages seem to pass through these functions. With a window snooper, I can see my controls have the same parent window as the "OK" and "Cancel" buttons.
An example of my second method is as follows:
class CMyFileDialog : public CFileDialog { DECLARE_DYNAMIC(CMyFileDialog) [...]
CMyFileDialog::CMyFileDialog(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName, DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) : CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd) {
}
void CMyFileDialog::OnInitDone() { CWnd *fswin = GetParent();
CButton *bb = new CButton();
bb->Create("KK", WS_CHILD|WS_VISIBLE, CRect(0,0,24,24), fswin, 3345);
CFileDialog::OnInitDone(); }
Any clues as to why the button appears, is clickable, but doesn't generate any messages
Visual C++11
|
|
|
|
 |
kuphryn

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
essentially always keep pointer dynamic allocation
m_pBB
tried passing in second parameter Create() this
Kuphryn
|
|
|
|
 |
RoobyDoo

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
I'm not using managed C++, so the pointer is dynamic allocation (there's no GC). It's only in that place for testing, and would of course be part of the class for the real thing. I've moved it into the class anyway just in case, but it makes no difference.
If I pass 'this' instead of 'this->GetParent()', then the button doesn't even show up at all.
|
|
|
|
 |
kuphryn

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
button coordinates
MoveWindow()
Kuphryn
|
|
|
|
 |
RoobyDoo

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
I specify a CRect of 0,0,24,24 - doesn't that mean the top left corner Also, If I use the parents cwnd, it does show up, so I don't think it's that.
|
|
|
|
 |
kuphryn

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
increase height dialog
Kuphryn
|
|
|
|
 |
RoobyDoo

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
|
|
 |
kuphryn

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
no see button or no receive message
Kuphryn
|
|
|
|
 |
RoobyDoo

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
using 'this' as owner of window argument, I don't see button.
using 'this->GetParent()' as owner of window argument, I see button, but not receive any messages.
|
|
|
|
 |
kuphryn

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
visible after increase height dialog
Kuphryn
|
|
|
|
 |
RoobyDoo

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
No, not visible even after increase height dialog
|
|
|
|
 |
Brian Kramer

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
|
|
 |
Martin Richter

|
Posted: Visual C++ Language, CFileDialog subclassing |
Top |
What happensif you don't use GetParent to create the button
Why don't you use the standard way to extend your CFileDialog with a template
|
|
|
|
 |
|
|