|
|
Hello - thanks for the reply.
Yes the error comes up as
X Debug Assertion Fault
file: afxcmn.inl
By putting the code inside the new dialog class - I have solved the problem.
But even so - I would like to know if it is possible to work as I stated above.
|
|
|
|
|
Are you sure m_tree is valid?
|
|
|
|
|
sofa_2006au wrote: I am trying to access the tree control in the new dialog from the parent(root) dialog program.
Why are you wanting to do that? The child dialog should communicate with its parent via messages.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DeleteAllItems won't work because the dialog window doesn't exist yet. Your assertion is probably something about a window handle being invalid?
Controls do not go active until OnInitDialog() is called -- which doesn't happen until DoModal() is called.
The reason the other one works -- is that xxx.Format is only acting on a CString which is bound to the edit control.
Why do you need to DeleteAllItems() anyhow -- trees default to empty.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Wow
Thank you - for the reply and detailed information.
Very much appreciated
( Shows how little I know about c++ )
I kind of accidently figured this out and fixed the problem indirectly then.
Question then is:
--------------------
Can the parent setup or add/change the tree control of the child dialog.
Seems like the answer is no ?
I needed to do that as I wanted the parent to feed the tree with data.
But I think that is the wrong way to do it now?
Should the child merely be able to access some public member variable of the parent's class to access the data?
|
|
|
|
|
You know, it all depends what you want it to do.
If you just want to populate it with data, then you can pass in that data to the dialog's constructor. And then in your OnInitDialog() method, populate the controls with data.
If you want to update the dialog with "live data", then something fancier is needed.
I am no MFC whiz! I've muddled through this MFC experience with the rest of the world... I am good at answering the questions, because I have made the same mistakes... and learned a lot along the way.
Just take your time.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Hi,
I want to close the dialog in a certain time interval automatically after displaying it. Any ideas? Please excuse me if the question is very basic..
With Regards,
Sangeetha.
|
|
|
|
|
You can use of WM_TIMER and after a time send WM_CLOSE to your program.
|
|
|
|
|
Hi Whitesky,
Its working.. Thank you very much..
With Regards,
Sangeetha.
|
|
|
|
|
|
In Windows' Drawing Tool,there is a funtion that is we can select the discretioal part of the image.How can it realize?
Have I make a clear expression?;P
I appreciate your hint.
|
|
|
|
|
Do you want to select sections of an image and cut or other actions on the it?
|
|
|
|
|
Yes,I want to cut the section I select from the image.
|
|
|
|
|
Check this code:
BOOL CDialogDlg::OnInitDialog()
{
m_Image.Load("c:\\123.jpg");
}
void CDialogDlg::OnPaint()
{
CPaintDC dc(this);
m_Image.BitBlt(dc.m_hDC,0,0,800,600,0,0);
CDialog::OnPaint();
}
void CDialogDlg::OnBnClickedOk()
{
int x,y;
x=200;
y=200;
HDC dc;
HBITMAP hbit;
dc=CreateCompatibleDC(GetDC()->m_hDC);
hbit=CreateCompatibleBitmap(GetDC()->m_hDC,x,y);
SelectObject(dc,hbit);
BitBlt(dc,0,0,x,y,GetDC()->m_hDC,100,100,SRCCOPY);
CImage m_Image33;
m_Image33.Attach(hbit);
m_Image33.Save("d:\\22.bmp");
m_Image33.Detach();
DeleteDC(dc);
DeleteObject(hbit);
}
|
|
|
|
|
But the section was selected by the mouse,so the section is not a rect.
|
|
|
|
|
You want to select an area with mouse ok,its easy you have a click when you click mouse you must save start position with CPoint point;GetCursorPos(&point); that is x and y and when you free mouse its height,width thus you can select an area.
|
|
|
|
|
But the area is not a regular one...
|
|
|
|
|
I create a stream socket and start listening immediately.
But when I use "netstat -a" command in the cmd window,the socket's port would not be shown in the list.The sample code only like below:
CSocket listenSocket;
if(listenSocket.Create(0,SOCK_STREAM)==TRUE)
{
SOCKET port=listenSocket.m_hSocket;
if(listenSocket.Listen(10)==FALSE)
cout<<"Listen Failed!"<
|
|
|
|
|
Is your listenSocket variable going out of scope?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No,the socket is the member of the class
|
|
|
|
|
because you use listenSocket.Create(0,SOCK_STREAM) create listen socket, "0" means the server listen port is random number. this random number is also shown in the "netstat -a" list.
If you use listenSocket.Create(8000,SOCK_STREAM), the listen socket port will be fixed 8000. try "netstat -a" command you will find the listen port is 8000.
|
|
|
|
|
But,if I change to Create() and listen,the problem remain so.
Thanks
|
|
|
|
|
kcynic wrote: But,if I change to Create() and listen,the problem remain so.
Try something like Create(2500, SOCK_STREAM) and see if there's a socket listening on port 2500.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
But my real work is to create a listen socket and report the listening port to others then other client can to connect to the listening socket.
Thanks.
GOOD LUCK
|
|
|
|