Hello All I am accessing DB using user defined message handler. Due to more number of threads i have avoided using one more thread. But thanks for your solution. Have nice time Ravi
Ravi Sankar S
Posts
-
Doubt about which message handler to use -
Doubt about which message handler to useHello All I am developing an SDI application in VC++ 6.0 on WIndows 2000. I want to read some settings from Database when application comes up. I wrote DB access code in "CMyView::OnInitialUpdate()". It is working fine when DB is accessable. If DB is not accessable due to some problem, my application waits in the starting itself until the DB connection is timed out... after that application displays the Error MessageBox and then the main window is launched. User is unable to know what is going on until he gets the Error Message. I want my application to comeup first and then I want to try to access the DB and I want to put periodic status message to the user to know about what is going on in backend. Please let me know where I can write the code for DB accesss in order to get executed after the main window is displayed. Please note that it is SDI application. Thanks for your time Ravi
-
Free BMP / ICO Downloadable sites....Thanks for your help.... I found one more site. http://www.glyfx.com/ which gives the BMP / GIF / ICO / PNG of different sizes (16 * 16 / 24 * 24) which can be used directly MFC application. Thanks for your time Ravi
-
Free BMP / ICO Downloadable sites....I tried and end up with lot of tools to create / modify the images But not really the image collection. - Ravi
-
Free BMP / ICO Downloadable sites....Hello All Can any one suggest free "BMP /ICO collection" downloadable sites for the using in my application. Thanks for your time Ravi
-
Command for executing files.....It is working fine... Thank you all... -Ravi
-
Command for executing files.....Hello All Is there any command in SDK / MFC on passing the file name can execute with appropriate application. For Example command ("a.wav") should open "a.wav" file in Real Player or what user has installed / configured to open the *.WAV files. I can use, WinExec but it needs the executable path to be passed. User can install any type of player and configure different type of file format to open in different players. One Clue is in the Command Prompt if we type the file name it automatically finds the application to be used and opens the file. If the file extension is not mapped with any applicaiton it automatically open the "Open With" dialog box. So I there is any command which executes the string passed as in command line it will do. Is There any command? Thanks for your time Ravi
-
Is it better solution for Refreshing Problem in List Control...Hello All I am using List control on my Form View (VC 6.0 on Windows 2000). I have derived my own class from CListCtrl and overwritten "OnCustomDraw" to draw my own List Control. I have placed the control on top of the Tab Control. When I switch from my application to another application and come back, repainting is not happening properly. I am seeing the tab control and the list control is not visible. After some time it appears automatically or if i go to some other tab and come back it appears. I have not overloaded OnDraw in my View Class.If I use CListCtrl without using my own class then repainting happens properly. As a solution for above problem I overloaed OnDraw in my view class and i painted the list controls.
void CMyView::OnDraw(CDC* pDC) { if (m_oTabCtrl.GetCurSel () == 0) { m_oMyListCtrl1.Invalidate (); } else { m_oMyListCtrl2.Invalidate (); } }
After this I am not getting any painting problem. Please let me know what was the cause for above problem and whether is there any better solution than this? Thanks for your time Ravi -
Adding new column dynamically in CXListCtrl adds progress control and check boxs...Hello All I am using "CXListCtrl" in my application. I want to hide and show columns depending on the user selection, with some data (5 rows of data) present in the list control. I am using "DeleteColumn" and "InsertColumn" to remove and add column When I do "InsertColumn" a new column is added in the Header Control, in the location what i specify. When I tried to update the data for newly inserted column, progress bar is displayed and not my data. If I try to insert 2 new columns, Columns are getting added in Header Control but in the Column values "Progress Bar" and "Check Box" are shown. When I debugged I see the code where I update the data to corresponding new columns are getting executed correctly. After this code the following fucntion is getting called
CXListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
inside the function "(pXLCD && (pXLCD[nSubItem].bShowProgress))" is true so the following portion of the code gets executed, so Progress control is displayed!if (pXLCD && (pXLCD[nSubItem].bShowProgress)) { DrawProgress(nItem, nSubItem, pDC, crText, crBkgnd, rect, pXLCD); *pResult = CDRF_SKIPDEFAULT; // We've painted everything. }
Any Idea what is the problem? Thanks in advance - Ravi -
Problem with Coordinates....Hello All, I am having a List control in my [B]Form View[/B]. I want to create it dynamically by calling "CreateEx". My problem is when I am creating it is creating in different location than where I placed in the form. The code ( VC++ 6.0 / Windows 2000) is given below
DWORD dwStyle = LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP; CRect rect; GetDlgItem (IDC_LIST1)->GetWindowRect(&rect); VERIFY(m_oTabList.CreateEx(WS_EX_CLIENTEDGE, _T("TestControl"), _T(""), dwStyle, rect, this, IDC_LIST1, NULL));
GetWindowRect returns values {104, 400, 27, 498}. The Control is placed much below the location where i created. Then I tried to use GetClientRect instead of GetWindowRect. At this time the value returned {0, 292, 0, 467} This time it draws at the top of the client area. How to get the control location with respect to client area? Thanks in Advance Ravi -
Access Violation During adding items in List Control ( CXListCtrl )....Hello All, I am developing a sample SDI application in VC++ 6.0 on Windows 2000 Professional. My view class is derived from "CFormView". I am using this List control taken from http://www.codeproject.com/listctrl/xlistctrl.asp on my Form. Creation and initial display are proper and when i try to add an Item it gives access violation. Here is the code used to update the List control.
BOOL CMyView::UpdateList (int l_iRow, CInfo *l_oInfo) { CString l_strTemp; int l_iRowCount = 0; // ID l_strTemp.Format ("%d", l_oInfo->m_lID); if (l_iRow == -1) { // add at the end of the list l_iRow = m_oTabList.GetItemCount (); m_oTabList.InsertItem(l_iRow, l_strTemp, RGB(255, 0, 0), RGB(255, 255, 255)); } else { l_iRow--; m_oTabList.SetItemText (l_iRow, l_iRowCount, l_strTemp); } l_iRowCount++; ....
If I debug and see the above function is executing fine. but it fails while drawing the items in Line Number 842 of XListCtrl.cpp in Function "DrawTextm_HeaderCtrl.GetItem(nSubItem, &hditem);
In the GetItem the m_hWnd is NULL so code in AFXCMN.INL gives Access Violation_AFXCMN_INLINE BOOL CHeaderCtrl::GetItem(int nPos, HDITEM* pHeaderItem) const { ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, HDM_GETITEM, nPos, (LPARAM)pHeaderItem); }
Since ASSERT won't execute in Release mode it is working fine in Release mode. The code used to insert column is belowm_oList.SetExtendedStyle(m_oList.GetStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); // Insert the columns for the list control m_oList.InsertColumn (0, _T("ID"), LVCFMT_CENTER, 40); m_oList.InsertColumn (1, _T("No"), LVCFMT_CENTER, 80); m_oList.InsertColumn (2, _T("Time"), LVCFMT_CENTER, 120);
After this code I am inserting new items. Can any one suggest what may be the problem. Thanks in Advance Ravi -
How to extract integer value from CStringHello All, I have to get integer value which is stored in a CString object. My code
CString str = "-123"; int i; sscanf (str, "%d", &i);
This is what i followed. Is there any better approach than this? Thanks for your time Ravi -
Clarification regarding memory management in multi threadHello All, There is a basic doubt in multi threading. I want to allocate memory in one thread and i want to use that memory in other thread and free in that thread. Threoritically memory allocated in one thread using malloc / new function can not be freed using free / delete in other thread. It it correct? The code I have given below Language VC++ 6.0 OS: Windows 2000
typedef struct CapturedData { long m_lLength; char *m_pData; }NewCapturedData; // Global variable to store the data CTypedPtrList g_oCapDataList; // First Thread Function LRESULT OnCaptureAddData (WPARAM wParam, LPARAM lParam) { NewCapturedData *l_pCapData; l_pCapData = new NewCapturedData; l_pCapData->m_lLength = (long) lParam; l_pCapData->m_pData = (char*) calloc (sizeof (char), (long)lParam); if (!l_pCapData->m_pData) { return FALSE; } memcpy (l_pCapData->m_pData, (char*) wParam, (long)lParam); EnterCriticalSection (&m_oCapDataCriticalSession); g_oCapDataList.AddTail (l_pCapData); LeaveCriticalSection (&m_oCapDataCriticalSession); PostThreadMessage (WM_CAPTURE_PROCESS_DATA, 0, 0); return TRUE; } // Second Thread Function LRESULT OnProcessDataMsg (WPARAM wParam, LPARAM lParam) { CapturedData *l_pCapData = g_oCapDataList.GetHead (); // Do some ananlysis with data. free (l_pCapData->m_pData); l_pCapData->m_pData = NULL; free (l_pCapData); l_pCapData = NULL; }
NOTE: Above code is part of code i have given, but orginal code is compiling and linking and executing. The project is dealing with packet capturing and it has to take minimum memory and really fast. Is it better idea to free in the second thread? If the memory has to be freed in first thread? I am planning to post a message to first thread, to intimate first thread from 2nd thread when ananysis is complated to remove the memory!!!! For this approach i have to add "GetMessage" in First thread and depending on the message free the memory. Can you please suggest which design is better? Thanks for your time Ravi -
How to store RTP payload (G.711) to file?Thanks Alex.... Thanks for ur suggestion. Let me explain the application bit more detail. It is recording application. the functionality is to record the VoIP calls going on in a LAN. So application can receive multiple VoIP call data. For each call there are sending and receiving ports. Since the packets are targetted to my system, I can not use normal socket for receiving the paceket I have to receive the packet using promisious more using any packet capture library. I am using WinPCap used which is widely used. When I receive the packet in promisious mode i am able to capture the packet, i am able to parse it and store the packet. The codec in which i receive the packet is G.711. When i store the pay load with proper WAVE file header and specify that it is G.711 format i am unable to get the replaying properly. I use Etherial for cross checking the packets received. The payload is correct and codec type is also G.711. When I tried to store the payload using the statistics option provided by Etherial i am able to replay the voice perfectly. In my application the procedure what i followed is here until RTP BYE / RTCP BYE packet get the RTP packet retrive the payload dump into a file end until add the WAVE header and store the file. I tried with DirectShow it is very slow... So I could not use that I have to go for very low level programming since the number of packets and number of VoIP calls are more.... I feel after receiving the RTP packet and before storing whether i need to do any convertion? is the procedure followed is correct? Please clarify Thanks Ravi
-
How to store RTP payload (G.711) to file?Hello All, I am writing a small RTP recorder application. I am receiving the audio in RTP packets and I have to store the audio data to a .wav file. The payload type is G.711 PCMA 8000 KHz (Value - 8). I extract the payload and stored it in a file ("test.wav"). When i tried to play the file in "Media Player" and "Real Player" says the file is corrupted. Since it is raw PCM data i expected saving the payload in .wav file directly will play the audio. Can any one suggest, whether the procedure followed is correct? Storing the payload with out any conversion / decoding? Is there any site or document which tells about the procedure to be followed Note: I may start start recording in the middle of audio file playing also. Thanks in Advance Ravi