|
Hi.
I'm writing an app which can show more instances of 'CMyDlg' class.
void CMainFrame::OnSomething()
{
CMyDlg *m_Dlg = new CMyDlg();
...
m_Dlg->Create(...);
m_Dlg->ShowWindow(...);
m_DlgPtr.AddHead(m_Dlg);
}
When App is about to close I clean out CPtrList:
void CMainFrame::OnClose()
{
POSITION pos = m_DlgPtr.GetTailPosition();
while(pos != NULL)
{
CMyDlg *m_Dlg = (CMyDlg *)m_DlgPtr.GetPrev(pos);
m_Dlg->CloseWindow();
delete m_Dlg;
}
CFrameWnd::OnClose();
}
When user closes the dialog manually (on cancel), I was thinking to send message to main frame on which I'll find appropriate dialog pointer among m_DlgPtr and delete it. My concern is how to send pointer trough message?
void CGrafQueueDlg::OnCancel()
{
...
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd( );
pMainFrame->PostMessage(WM_DLG_CLOSE,?,?);
CDialog::OnCancel();
}
Thanks in advance.
|
|
|
|
|
josip cagalj wrote: m_DlgPtr.AddHead(m_Dlg);//add to CPtrList member
Instead of adding the dialog pointer add m_hWnd member since sometimes there can be a mismatch between windows pointers and internal handles. For eg: CWnd::FromHandle can just create a temporary CWnd for wrapping around a window handle.
A better option will be to keep a map, look ups will be faster. As a key let every dialog create a unique index for itself and map this to the window handle.
josip cagalj wrote: pMainFrame->PostMessage(WM_DLG_CLOSE,?,?);//how to pass pointer to this?
You can pass window handle in WPARAM or LPARAM parameter of ::PostMessage.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Thanks for yours replay.
You mean I should use:
m_DlgPtr.AddHead(m_Dlg->m_hWnd);
and m_DlgPtr should be A map object. Did you mean CMapPtrToPtr?
Could you please provide some brief code as I did in my first post?
Thanks!
P.S.
Post message should be like this:
pMainFrame->PostMessage(WM_DLG_CLOSE,(UINT)this->m_hWnd,0);
?
|
|
|
|
|
Another option which I use myself is to pass the modeless dialog a pointer to itself. When the dialog is destroyed it nulls the pointer.
|
|
|
|
|
First and foremost, does it run?! If not, would it run on a 32-bit XP VM in VMWare server under 64-bit Vista?
I'm trying to avoid keeping a legacy machine to run older programs on...
TIA.
|
|
|
|
|
|
Hi Friends,
My program has a code which calculates time passed for a perticular opertion like
Total time = End time - Start time
Here I am using _ftime() function which says that it will provide me time since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC).
Now my programs keeps running on a machine which uses Network Time Protocol. Here NTP is compatible of leap seconds adjustment.
I heard that leap second will be inserted on Dec 31 23:59:60(GMT).
Now will this break my above expression?
|
|
|
|
|
If extra time is added in between start and end, then the total time may be skewed.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
hi to all,
i could find my local pc system IP Address and MAC Address by using gethostbyname().Now i want to find what are system connect in the Network and its MAC Address also IP Address. This is possible to get all system IP Address and MAC Address in VC++6.0.
can anyone help me.........
Regards
Muthukkumaran
|
|
|
|
|
See this link, maybe it can give you a starting point:
http://www.codeproject.com/KB/IP/enetstatasp.aspx[^]
I think it is not possible to get the MAC address of a remote computer thorough nothing more than its IP. As far as i know for example when a packet arrives at your ISP it will know that the IP addressed in that packet belongs to your modem's/computer's MAC address and will "relay" the packet to it, but on the other side of the ISP i doubt there is a way to ask the ISP what MAC address has been assigned to a certain IP address. It might be possible on a local network though.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
hi,
Thanks for your reply........
Regards
Muthukkumaran.S.A
|
|
|
|
|
Member 4708676 wrote: Now i want to find what are system connect in the Network...
See NetServerEnum() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
hi DavidCrow,
Thanks for reply.........
Local system only connect to Hub.Four system connected through Hub.
Regards
Muthukkumaran.S.A
|
|
|
|
|
I.e. can I tell the system to stop sending WM_PAINT messages in response to UpdateWindow() or InvalidateRect()?
My problem is this - I post a message to the open files dialog displayed by the function GetOpenFileName to make it switch to displaying thumbnails mode, which works. However, the dialog first displays in list mode, and then switches to thumbnails mode, and so a flicker is produced. That's why I need to disable repainting. I tried using ShowWindow(SW_HIDE), but it doesn't work.
Thanks.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
modified on Tuesday, November 25, 2008 8:26 AM
|
|
|
|
|
|
Thanks
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi all,
I am using CreateFile API and was having access denied problem in uac enable(VC 2008), so i modified my manifest file and it started working correctly for hard disk(basically i m enumerating my disk), but my problem still persist with removable media...
How can i remove this??
Thanks in advance
|
|
|
|
|
hi everyone,
my application will be getting UDP packets from a number of ports each port will have a throughput of 50 hz. ( an UDP packet for each 20ms ).
- Reliability is of no importance for my case so TCP is disregarded.
so, what should i do to prevent possible UDP buffer overruns and stabilize processing performance of packets?
Should i use individual worker threads for each UDP Socket (WinSocket) in blocking recv() in thread loop?
Should i use implement each UDP socket as CAsyncSocket and override OnReceive()?
In Asynchronous receiving i think framework uses a thread from internal thread pool and assigns it to call OnReceive whenever socket gets remote data? am i right? So what is the difference to implement our worker thread and using MFC CAsyncSocket in terms of performance or data?
Should i immediately put received bytes in a thread-safe queue or some sort of array and leave the overriden function in OnReceive() case?
What do u offer that will work practically and in reliable/good performance?
Thanks in advance for your replies..
|
|
|
|
|
atillaselem wrote: so, what should i do to prevent possible UDP buffer overruns and stabilize processing performance of packets?
There is an internal socket buffer which can be set with the setsockopt Function[^] which I think defaults to 8 kilobytes on Win2k and above with adequate RAM. The buffer size can be increased by setting the SO_RCVBUF[^] option. The socket buffer can be increased up to 64K. You wrote in your opening statement that Reliability is of no importance so this implies that you do not care if there is slight packet loss. If this is the case then the default socket buffer may suffice.
atillaselem wrote: Should i use individual worker threads for each UDP Socket (WinSocket) in blocking recv() in thread loop?
Should i use implement each UDP socket as CAsyncSocket and override OnReceive()?
Its hard to say what your requirements are without knowing what type of data your packets contain and how long it takes to process the data. CAsyncSocket has fairly good performance for client applications.
atillaselem wrote: In Asynchronous receiving i think framework uses a thread from internal thread pool and assigns it to call OnReceive whenever socket gets remote data?
Yes somewhat, OnReceive is implemented as a callback function.
atillaselem wrote: Should i immediately put received bytes in a thread-safe queue or some sort of array and leave the overriden function in OnReceive() case?
If you will be recieving the datagrams from over the internet and have an estimated low throughput then there is no reason why you shouldn't immediately update your application variables with the datagram values by first locking with multiple-readers single-writer synchronization objects.
atillaselem wrote: What do u offer that will work practically and in reliable/good performance?
Only some advice with an estimated value of 0.02 dollars USD.
Best Wishes,
-David Delaune
|
|
|
|
|
|
atillaselem wrote: UDP packets are consist of ints & floats variables and a few char[] put into a Structure total is not more than 200 bytes. If nothing change to block and use recv() when compared OnReceive in terms of getting and pushing data into a thread-safe buffer should i stick with CAsyncsocket OnReceive()?
With a tiny 200 byte struct I would recommend directly updating/assigning the values. The time it takes for you to copy the data into a thread-safe buffer is nearly equal to the time it takes to directly assign the values. Make sure to use synchronization objects so the renderer does not attempt to access during the update.
atillaselem wrote: these packets live on a dedicated LAN for our project.
It sounds like we have both worked on very similar projects.
atillaselem wrote: i consider using a thread safe queue to put/write all packet in one go and fetch/read at one go. The point is which is more effective? To do processing with data in a seperate worker thread or OnReceive()?
Your datagram is very small. Once the data has arrived into OnReceive() I recommend process the data immediately with direct assignment and no buffering. It takes a very small amount of time to process 200 bytes. You will not gain anything by buffering this data at 20 hertz.
A very recent project I worked on was processing very much larger datagrams and I was also using direct assignment with zero buffering. My project also was over LAN with near zero packet loss and zero out-of-sequence. The update rate on my project was 10 Hz related to ocean marine vessels.
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: A very recent project I worked on was processing very much larger datagrams and I was also using direct assignment with zero buffering. My project also was over LAN with near zero packet loss and zero out-of-sequence. The update rate on my project was 10 Hz related to ocean marine vessels
i'm wondering that if i do not use a storage mechanism like queue or whatever how i can achieve to use all incoming packets with 50 hz (my case) while my drawing frame rate is 30 hz or less? someone gives your left hand every 20 ms and you deliver it to your next with 30 ms or more? there naturally happens a queue at your left side..
But if you get with a lower rate probably without putting them into a buffer makes sense.
pls think this situation with higher rates than 10 hz..
|
|
|
|
|
Hi All
How can i convert CString to TCHAR AND "[260]"?Plz help me
|
|
|
|
|
What do you want to do, exactly?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i am getting applcation path in CString a, and i want to set SetFileAttributes(a,FILE_ATTRIBUTE_NORMAL).And SetFileAttributes parrameter is TCHAR.So i want to use like this TCHAR m[Max]=a.Plz help me how can i get it.
|
|
|
|