|
Rage wrote:
m_ChildWin.CreateWindow(...);
Hmmm. I'd have thought you'd be better off using Create(). In fact neither CDialog nor CWnd has a member function called CreateWindow.
Rage wrote:
How do I update m_MainList from here ?!
In this particular case since the CMainDlg object is your main window [this being a dialog based app], you can use AfxGetMainWnd() to get a pointer to your CMainDlg object [cast it] and now you have access to m_MainList.
Regards
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
While Nish's answer is strictly correct, I would suggest (from an OO point of view) that this might be a bit safer:
In the CChild class, add a member function called Create, for example, which takes all of the parameters that you would normally need for a Create call and then a CListCtrl pointer as well:
BOOL CChild::Create(CListCtrl *apListCtrl, UINT nIDTemplate, CWnd *pParentWnd)
{
if (CDialog::Create(nIDTemplate, pParentWnd))
{
m_pListCtrl = apListCtrl;
return TRUE;
}
return FALSE;
}
where m_pListCtrl is a CListCtrl * member variable. You can then use this at will without having to rely on calls to AfxGetMainWnd(). Not only does this ensure that the correct list control is used, it means you don't have to make the CListCtrl public in your main dialog class.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
first, thanks for your answer...
Of course, it was Create and not CreateWindow ... sorry ..
Derek Waters wrote:
In the CChild class, add a member function called Create, for example, which takes all of the parameters that you would normally need for a Create call and then a CListCtrl pointer as well:
Sorry, i do not see the point in this, since the dialog is called in CMainDlg with m_ChildWin.Create(nIDTemplate,pParentWnd). Maybe I did not get the thing ?
RaGE
|
|
|
|
|
Basically, I was just using the Create call as a way to pass in the extra parameters you need:
m_ChildWin.Create(&m_MyListCtrl, IDD_MY_CHILD_DIALOG, this)
if:
BOOL CChildDlg::Create(CListCtrl *apListCtrl, UINT nIDTemplate, CWnd *pParentWnd)
{
m_pMyListCtrlPtr = apListCtrl;
return CDialog::Create(nIDTemplate, pParentWnd);
}
so you're intercepting the Create call (but still calling the dialog Create function) to pass in your extra parameters.
As I said, this is just my opinion of how it should be done, feel free to use Nish's method, or any other you can think of.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
I've tried to implement my own message filter (IMessageFilter) in a client that talks to a COM server.
It works if I test it in a simple dialog app, but when I implement it in an SDI app, the filter is never used.
Anyone got any ideas?
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
Funny, it works in the SDI app if I call AfxOleInit() first.
In the dialog app there is no need for that.
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
Hi,
I have a dialog based application with the standard "Ok" and "Cancel" buttons at the bottom. After the dialog app loads, if I press the 'enter' key, the app closes (the Dialog::OnOK() Event Fires). How can I override this action? In other words, I want to be able to press the 'enter' key and not close the application (not fire the OnOK() event method). How do I do this?
Thanks.
|
|
|
|
|
There are two ways to do this -
1. You can do this by overriding the OnOK function in your dialog class and do NOT call the base class OnOK in that function.
2. In the dialog editor remove the default button property of the OK button.
Hope this helps
Krishnan
|
|
|
|
|
|
Put in your own OnOK(0 for the dialog, and have code liek this:
CMyDialog::OnOK()
{
if (GetFocus() != GetDlgItem(IDOK))
return ;
}
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
Please step to the rear of the car and make room for more victims. - John Simmons the Outlaw programmer, 1st Feb 2002, in the lounge
|
|
|
|
|
works perfectly!
|
|
|
|
|
Hi,
How can I make the edit control of a CRichEditView read-only? Setting ES_READONLY flag does the job but messes up at other places.
Thanks,
Krishnan
|
|
|
|
|
try this:
CRichEditCtrl &rich=GetRichEditCtrl();
rich.SetReadOnly(true);
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 found that the OLE DB provider for jet (aka access databases) does not correctly bind string columns to PropVariants. Upon return, the type is set "VT_BSTR", but the string is empty (but allocated).
Findings:
Jet 3.51: binds correctly to DBTYPE_BSTR, _VARIANT, _PROPVARIANT
Jet 4 SP3: binds correctly to DBTYPE_VARIANT, but not to DBTYPE_BSTR or DBTYPE_PROPVARIANT.
Anybody has an idea of an workaround?
Peter
|
|
|
|
|
One thing that came to mind was an old problem with Unicode and Jet. You had to use VT_BSTRT instead of VT_BSTR to get anything - VT_BSTR is Unicode and if ANSI is expected the string will be empty (or only contain one letter). However, I'm not sure this is the problem, and it doesn't give any explanation for the DBTYPE_PROPVARIANT thing.
Just my $0.02
Steen.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I have a CString ,and I want to put it (or convert it) into variant type.
What is the code?
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
|
|
|
|
|
CString val("hi");
COleVariant var(val);
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
Thanks ,that's work.Now can you tell me how can I convert this
variant to CString or int or another type?
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
|
|
|
|
|
CString var = "1.3";
COleVariant val( var );
var = V_BSTR( &val );
double junk = atof( var );
val.ChangeType( VT_R8 );
junk = val.dblVal;
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
thanks,I'll check 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
|
|
|
|
|
I compil on XP with VC++6 SP5 and it works on XP
...
Bitmap.LoadBitmap(IDB_BITMAP);
m_StaticBitmap.SetBitmap(Bitmap);
...
BUT, the bitmap doesn't show on 98 SE
WHY???
|
|
|
|
|
Is this bitmap of yours any rare? There are exceptional cases where a bitmap is correctly handled by NT/2000/XP and not by 98/ME (see MSDN info <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_1rw2.asp">BITMAPINFOHEADER</a> ). If you suspect this to be the case, try replacing IDB_BITMAP with any other, standard bitmap.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
On 98
m_StaticBitmap.RedrawWindow();
it's necessary,but not on XP
|
|
|
|
|
Simplest things often are the most elusive
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Can anyone tell me the main difference between class and structure.
Like class we can also inherit one structure from other.
Like class we can also add public/private/protected members in struct.
Like class we can also insert both data and functions in struct.
SO WHAT IS THE MAIN DIFFERENCE BETWEEN CLASS AND STRUCTURE ?????????
Samad khan
|
|
|
|