|
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.
![Cry | :((](https://www.codeproject.com/script/Forums/Images/smiley_cry.gif)
|
|
|
|
|
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.![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
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! ![Wink | ;-)](https://www.codeproject.com/script/Forums/Images/smiley_wink.gif)
|
|
|
|
|
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! ![Wink | ;-)](https://www.codeproject.com/script/Forums/Images/smiley_wink.gif)
|
|
|
|
|
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?
|
|
|
|
|
in the press handle function of the button 1 you have to put code like this:
SetFocus( GetDlgItem( hDlg, IDC_COMBO1 ) );
Don't try it, just do it! ![Wink | ;-)](https://www.codeproject.com/script/Forums/Images/smiley_wink.gif)
|
|
|
|
|
You can have problems calling SetFocus() when you click on button or some other control is getting focus. The way to resolve this is to use pTargetControl->PostMessage( WM_SETFOCUS, ... ).
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Anyone have any experience with printing Gdiplus::Image bitmaps? I can print ellipses and other objects no problem, but when it comes to printing bitmaps, they come out approx 10 times too big.
I'm using a Graphics.SetTransform() call to try to coax them to the correct size, but it is always off when printed, but correct in the view or in print preview.
Any help would be muchly appreciated.
Thanks,
swine
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Looking for a VC++ source code to create a Client & Server using TCP protocol (Microsoft Winsock).
If I want to know the socket state in VB, I just gonna use a timer and look at the winsock.state.
This is an exemple in VB6 with winsock
[code]
Private Sub Timer1_Timer()
If Winsock1.State = sckClosed Then
Winsock1.Connect 'Connect to the host
ElseIf Winsock1.State = sckConnected Then
Winsock1.SendData Time ' Send the current time
ElseIf Winsock1.State = sckClosing Then
Winsock1.Close ' Close the connection
End If
End Sub
[/code]
Now someone told me in VC++ you can only know the state of your socket after transmitting.I mean to know if the socket is closed you need to transmit a packet.
I would like to verify the socket state in VC++ without to transmit any data.It is possible ?
Anyway I'm looking after some good source code to start my investigation.
Johnny
|
|
|
|
|
>> to know if the socket is closed you need to transmit a packet.
I think even a recv() will return an error which can indicate the socket is closed.
>> I'm looking after some good source code to start my investigation.
www.sockets.com
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|