|
Well, it didn't work for me. The app description wasn't changed until I booted my machine. After that it started working properly again.. Weird stuff
-Antti
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
a class "CMyTreeCtrl" derived from CTreeCtrl, I want to get a pointer to CMainFrame in this derived class! some people told me that I could use :
<br />
((CMainFrame *)AfxGetMainWnd())->m_wndTreeCtrl.GetSelectedItem();<br />
but there is an error!
: error C2065: 'CMainFrame' : undeclared identifier
please tell me how to solve this problem! thanks~!
|
|
|
|
|
Make sure you have included CMainFrame's header file (Usually MainFrm.h)
|
|
|
|
|
if I include CMainFrame's Header, 5 errors occur.
:\program files\microsoft visual studio\myprojects\adbook\mainfrm.h(65) : error C2146: syntax error : missing ';' before identifier 'm_wndTreeCtrl'
e:\program files\microsoft visual studio\myprojects\adbook\mainfrm.h(65) : error C2501: 'CXTTreeCtrl1' : missing storage-class or type specifiers
e:\program files\microsoft visual studio\myprojects\adbook\mainfrm.h(65) : error C2501: 'm_wndTreeCtrl' : missing storage-class or type specifiers
E:\Program Files\Microsoft Visual Studio\MyProjects\adbook\XTTreeCtrl1.cpp(50) : error C2039: 'm_wndTreeCtrl' : is not a member of 'CMainFrame'
e:\program files\microsoft visual studio\myprojects\adbook\mainfrm.h(20) : see declaration of 'CMainFrame'
E:\Program Files\Microsoft Visual Studio\MyProjects\adbook\XTTreeCtrl1.cpp(50) : error C2228: left of '.GetSelectedItem' must have class/struct/union type
|
|
|
|
|
You need some other includes that MainFrm.h also need. You can find them in MainFrm.cpp. They are possibly included right before MainFrm.h
|
|
|
|
|
It sounds like you end up with circular references, and a mess just waiting.
To come at this from another tack. Do you actually need a pointer to your
CMainFrame oject, or just to your main window? Its unlikely the a sub-control
needs specific access to a member function in the MainFrame.
If you use
CWnd *pMainWnd = AfxGetMainWnd ();
ASSERT(pMainWnd);
if (pMainWnd)
pMainWnd->SendMessage (WM_NOTIFY, ....);
or
pMainWnd->SendMessage (WM_A_MESSAGE_OF_SOMEKIND, ...);
and install an appropriate notification handler in your CMainFrame then you
lose the current problem. It would also mean you could use your C TreeCtrl
in other projects more easily.
I hope this helped,
Iain.
|
|
|
|
|
clack234 wrote:
I want to get a pointer to CMainFrame in this derived class! some people told me that I could use :
((CMainFrame *)AfxGetMainWnd())->m_wndTreeCtrl.GetSelectedItem();
that won't get you a pointer to CMainFrame! instead AfxGetMainWnd() will get you the pointer to a CWnd object that can be type-casted to CMainFrame!
hope this helps...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
hello friends,
i just wanted to know How can i show The treectrl of a BrowseDlgBox with checkBox.
I mean i wanted to show the CheckBox in the treectrl that is shown in an Browse Dlgbox.
I am using the DlgBox for Folder selection every subfolder i.e when ever we see a + sign there should also be a check box and if this check box is selected then the internal folders will be automatically selectde...
If anyone can help !!!!!
I am working in MFC
Thanx
TAKE CARE
|
|
|
|
|
Hi try this solution
Open Tree Control Properties->More Styles->And check boxes. Make sure this property is set, and u will get check boxes on u r tree control.
To Mark check/uncheck child CheckBox , on can write handler for OnClickTree...
All the Best
--KK
|
|
|
|
|
Yes my dear friend u r right
but We cant see the Tree ctrl in a BrowseDlg box
how acn we change the properties of TreeCtrl
cause The Browse dialogBox is a commonDlg control and not the
one which we have designed by myself
Thanx
TAKE CARE
|
|
|
|
|
Hi all,
Today, I installed glut.dll, glut.lib etc. and tried to create a new project. But when I tried to "new" a .cpp file, VC told me "unspecified error".
Then I tried to open one of my old .cpp file, I found same error message popped up, why? How can I handle it?
Thanks a lot.
|
|
|
|
|
Hi. I wanted to create a locking program. When the person enters all the information needed and selects the file that he/she wants to "lock", the exe file will create another exe file that stores all the information being typed previously and also the file. When the user double click on the exe, the exe will need the user to enter the required information before it lets the user use the file.
Is it possible to let the exe file create another exe which has a file in it?
|
|
|
|
|
You could use the UpdateResource function to add / change a custom resource in the target
exe. I say custom resource, as you presumably don't want this information casually play withable by
outside influences. And add a checksum at the end of your resource so tampering can be detected and
punished by flogging...
Iain.
|
|
|
|
|
ok. Can u give mi some examples?
|
|
|
|
|
Hi ppl
I have a problem with my MDI windows. When i start my program and opens a child window, it is automaticaly maximized. But when this is done the "maximize", "minimize" and "close" buttons are gone. But if i maximize the window manually they stay. Also when i create two child windows and use the menu to cheange between the two child windows, the buttons reappear.
I'm using normal MDI view without the Doc part.
|
|
|
|
|
As far as I understand from M$ help, they prefer me to use IDL for defining my interfaces. However, if I have a Visual C++ V6.0 Project for an EXE, which has Automation enabled, then an ODL is produced and I cannot automatically use an IDL file. Should I worry about this?
The real problem is that I will have to mail the type library to others who want to use my EXE rather than just a neat IDL file. Is there a better way of doing this?
Any comments will be really appreciated.
|
|
|
|
|
Hi All...
Im using MFC and VC++6.
I have a class that i want to be able to pass and store a pointer to a member function of anther class so that i can call it at intervals of execution and pass status info back
How the hell to i get this right ?
Thanks in advance.
|
|
|
|
|
store the pointer to the second class instead of the pointer to the member function!
you cant get a pointer to a member function, which is not static, and static means, that the function is not assigned to a special class instance(no "this" ptr exists)!
Don't try it, just do it!
|
|
|
|
|
OK... Thanks Alexander.
I dont understand how that would help tho.
I have a Dialog Class, and a FTP class. I dont want the ftp class to know about the Dialog as i plan to use it again later for something else (a service)
So i have
class cMyDialog
{
private:
cMyFTP MyFTP;
}
class cMyFTP
{
public:
//Some how i know this decl is wrong
void SetStatusHandler(SOME THING HERE)
privte:
SOMEPOINTER pHandler
}
Am i doing about it the wrong way ?
Thanks again Cliff
|
|
|
|
|
this will only work, if the function pointer points to a static function!
i don't know what class the member function should be in, i assume it's CMyDialog...
So i have
class cMyDialog
{
public:
void Notify();
private:
cMyFTP MyFTP;
}
class cMyFTP
{
public:
void SetStatusHandler(CMyDialog *pDialog);
privte:
CMyDialog *pHandler;
}
void CMyFTP::SetStatusHandler(CMyDialog *pDialog)
{
...
pHandler = pDialog;
}
this is the only way if you want it to do it as u described!
Don't try it, just do it!
|
|
|
|
|
You could do something like the following...
class CFtpClass
{
....
public:
class CNotifyClass
{
public:
BOOL TellMeSomethingIDontKnow (DWORD dwFwibble) = 0;
};
BOOL RegisterNotification (CFtpClass::CNotifyClass *pNotify);
BOOL UnRegisterNotification (CFtpClass::CNotifyClass *pNotify);
....
};
class CMyDialog : public CDialog, CFtpClass::CNotifyClass
{
....
BOOL TellMeSomethingIDontKnow (DWORD dwFwibble);
}
BOOL CMyDialog::CMyDialog (....)
{
....
m_pFtp->RegisterNotification (this);
....
}
This may look suspiciously like INotifySink, for a good reason.
Or just have the Ftp class have a function to which you send a HWND of a dialog, and a message to
post when relevant. This means the dialog can go up in puff of smoke without risking crashing the
FTP class.
Did this help?
Iain.
|
|
|
|
|
YES !!!
Im gonna try something like this now.
Many thanks Iain.
|
|
|
|
|
Ian thanks again.
All works fine if i do it that way in a single thread.
But if i try run it in a thread started by AfxBeginThread the virtual function that is overloaded in the dialog class causes an execption tying to call UpdateDate(FALSE) to update the dialog class.
Any ideas ?
TIA.
|
|
|
|
|
HI
Folks i want to ask about setting Focus on a dialog box.
suppose i have set focus priority of dialog as follows
prority # 1 = combo 1
prority # 2 = combo 2
prority # 3 = button 1
prority # 4 = ok button
what i want is to
"setFocus to combo 1 when i press button 1"
on the form. i have tried setFocus() but it does not work.
Tell me how to do it ?
Thanx in Advance
|
|
|
|
|
Show us the code in the BN_CLICKED handler for "button 1."
jinbabaj wrote:
i have tried setFocus() but it does not work.
What is the return value?
|
|
|
|