Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

manoharbalu

@manoharbalu
About
Posts
162
Topics
84
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Transfer data between MFC Application and c# application using NamedPipe
    M manoharbalu

    I have to transfer data from MFC Application to C# application every 1 second Please find below the MFC Application (Server) and c# application (Client). I have a issue. Both the application's memory keeps increasing in task manager every 1 or 2 seconds. Please help me to figure out the issue in my code. Server Code in MFC applicationvoid SendDataToNamedPipe(CString sData) { char czVal[PIPEMAXSIZE]; //PIPEMAXSIZE = 10000 memset(czVal,0,PIPEMAXSIZE); strcpy(czVal, sData /*buffer*/); CString sPipeName = "\\\\.\\pipe\\" + "Pipe"; LPCTSTR lpszPipename = (const char*) sPipeName; hNamedPipe = CreateNamedPipe( lpszPipename, // Name of the pipe PIPE_ACCESS_OUTBOUND, // Pipe access type PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, // Maximum number of instances 0, // Out buffer size 0, // In buffer size 0, // Timeout NULL ); if (hNamedPipe != INVALID_HANDLE_VALUE) { BOOL fConnected,fSuccess; fConnected = ConnectNamedPipe(hNamedPipe, NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED); //// Assuming 'dataToSend' contains the data to send WriteFile(hNamedPipe, czVal, PIPEMAXSIZE /*(DWORD)sizeof(czVal)*/, NULL, NULL); DisconnectNamedPipe(hNamedPipe); CloseHandle(hNamedPipe); } } Client Code C# Applicaition: /////////////////// public void RecivePipeClient() { NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", "Pipe", PipeDirection.In, PipeOptions.None); pipeClient.Connect(); StreamReader reader = new StreamReader(pipeClient); string dataValue = reader.ReadLine(); } //Calling Thread function in MFC Application (Server) void ThreadNamedPipeTagLiveValue(LPVOID) { CString strValue= ""; while( 1 ) { POSITION pos1 = OLivePointList.GetHeadPosition(); while(pos1 != NULL) { CTagBase* OTemp = (CTagBase*) OLivePointList.GetAt(pos1); CTime TNow; TNow = CTime::GetCurrentTime(); strTime=TNow.Format("%m/%d/%Y %H:%M:%S"); CString strTemp; strTag = OTemp->GetTagName(); if((OTemp->GetTagType() == CONTROLLER)) { OTemp->GetTagValues(OLivePoints); sTempValue.Format("%5.2f", OLivePoints.PV); strValue = strValue + sTempValue + ","; } } SendDataToNamedPipe(strValue); Sleep(1000); } }

    C# help csharp c++ sysadmin performance

  • How to create Shared memory between C# application and VC++ console application
    M manoharbalu

    This gives details for creating and opening shared memory between 2 C# application processes. Please help me to share memory between 2 applications, one in C# and other VC++ console application to open the share memory created in C# application. Is it possible of doing this? Please advise

    C# csharp c++ visual-studio performance tutorial

  • How to create Shared memory between C# application and VC++ console application
    M manoharbalu

    But I didnt get a solution. Please provide me some details and hints how to share memory between C# application and VC++ console application

    C# csharp c++ visual-studio performance tutorial

  • How to create Shared memory between C# application and VC++ console application
    M manoharbalu

    I want to create shared memory in a C# windows application. And a second console application in visual studio has to share the same memory using OpenFileMapping function. Is it possible to share memory as I mentioned between one application in C# and other application in Visual C++ console application. Please advise and suggest the ways of doing this

    C# csharp c++ visual-studio performance tutorial

  • Shared memory
    M manoharbalu

    Is it possible that the 2 applications that share the memory (File mapping) be developed in C# and C++ respectively. Example: One application in C# to create shared memory Other application 2 in C++ opens and shares the memory file mapping.

    C# csharp c++ wpf performance

  • Shared memory
    M manoharbalu

    I have an application in MFC which creates shared memory using CreateFileMapping where I share a Struct object. In another console application in C++, I am accessing the shared memory using OpenFileMapping function and so the struct object is changed/accessed in both the applications. Now, I want to redevelop my MFC Application in WPF C#. Is it possible to share the memory with the same console application as I have done earlier in MFC. Please advise

    C# csharp c++ wpf performance

  • How to convert my MDI Application to open each window as a separate instance of the application
    M manoharbalu

    Thanks that you got my requirement correctly. All I need... is a single application in which all the opened documents looks like in MS Office (Word, Excel). There is already an option in MFC to create application type as "multiple top level documents" which meets my requirements. Can you please suggest how to convert my existing MDI application from "Multiple Document Interface" type to "multiple top level documents" type. Please help.

    C / C++ / MFC c++ tutorial

  • How to convert my MDI Application to open each window as a separate instance of the application
    M manoharbalu

    There is an option in MFC to create application type as "multiple top level documents" which meets my requirements. Can you please suggest how to convert my application from "Multiple Document Interface" type to "multiple top level documents" type. Please advise.

    C / C++ / MFC c++ tutorial

  • How to convert my MDI Application to open each window as a separate instance of the application
    M manoharbalu

    My Application takes very less data (configuration) from text files, rest are all calculations done every second for around 20000 tags or values. If I do it using TCP/IP Sockets that my application may be overloaded for each window. Is there any other option in MFC?

    C / C++ / MFC c++ tutorial

  • How to convert my MDI Application to open each window as a separate instance of the application
    M manoharbalu

    I need my existing MDI application in MFC to be transformed with the below requirement. Every window should look like a completely separate instance of the application – with its own button in the Windows Taskbar. However the windows should be still part of the single application. If there are multiple monitors used, each window of my application can be viewed in the various montitors Please give your suggestions how to convert

    C / C++ / MFC c++ tutorial

  • Efficient way to read/write file
    M manoharbalu

    I have a MFC Application, where I am creating a new feature. The new feature is to write a structure around size 900 KB to a file on disk every second. Similarly, my another application will read the same file every second after some time. My questions are: 1. How to save the structure (900 KB) to the file in reduced size format, such that the file size doesn't become too big? 2. Saving the structure every second data as an individual file for reading and writing (there will be 60 files for 60 seconds) or saving the structure sequentially in the same file(only one file)...Which is efficient for reading and writing Please note that I am going to write the structure to the file for 4 days as a maximum period.

    C / C++ / MFC c++ tutorial question

  • How to draw a realtime XY plot in MFC
    M manoharbalu

    How to draw a realtime XY plot in MFC. I have an existing MFC application in which there are many tags that changes continuously. I have to show the value of 2 tags which changes dynamically. I have to plot an XY plot for the tags in a separate dialog or window in the existing MFC application. Please suggest me some easiest or quickest ways of doing the above task.

    C / C++ / MFC c++ tutorial

  • Reading a text file from a remote machine in LAN using c, c++, vc++
    M manoharbalu

    Using C/C++ code, How to read a text file (approx size 100GB) line by line from a remote machine in LAN directly without downloading or copying the file

    C / C++ / MFC c++ tutorial

  • "Debug Assertion Failed at line: 252 in viewcore.CPP"
    M manoharbalu

    I have used a tabcontrol which should show different views for each tabs. As a trial, I have created a CView class and tried to show it for the first tab. When I select the tab, the appropriate view ( white screen view) is showing. The problem is when I click on the view, it throws an assertion "Debug Assertion Failed at line: 252 in viewcore.CPP". I have added the below code for selection of tabs. if (nTab == 0) { CRect clientRect; m_cTabCtrl.GetClientRect(&clientRect); clientRect.DeflateRect(5, 18); CTrendview *m_pNewView = new CTrendview(); // Creation of the view window if(! m_pNewView->Create(NULL, NULL, WS_VISIBLE | WS_CHILD, clientRect, &m_cTabCtrl, 1)) { TRACE( "Failed view creation\n" ); } m_pNewView->ShowWindow(SW_SHOW); } Please help me to find a solution for this problem.

    C / C++ / MFC debugging help c++

  • How to stop flickering of controls in my Dialog window
    M manoharbalu

    Yes. done that. But still its flickering. It seems the problem is in the thread which calls the Invalidate for the Dialog. Please help to find out what is wrong or how to correct the problem

    C / C++ / MFC graphics c++ tutorial question

  • How to stop flickering of controls in my Dialog window
    M manoharbalu

    A seperate thread function created already which calls a function UpdateAllViews() as shown below every half a second which in turn calls Invalidate the CFP Dialog. This is done to continuously update some real time numerical values on the dialog. When I remove this line pFPlate->Invalidate(FALSE); then there is no flickering on the dialog. But the values are not updated. How to avoid this flickering without affecting the value updation. void tUpdateAllViews( CMainFrame *pMainFrm ) { while( 1 ) { pMainFrm->UpdateAllViews(); Sleep(500); } } void CMainFrame::UpdateAllViews() { if(pFPlate->GetSafeHwnd()) //CFP Dialog member variable { if(pFPlate->IsWindowVisible()) { pFPlate->Invalidate(FALSE); } } }

    C / C++ / MFC graphics c++ tutorial question

  • How to stop flickering of controls in my Dialog window
    M manoharbalu

    In my MFC application, I am doing a custom drawing in my dialog class OnPaint(). I have also created a few controls in dialog template. I have also resized and repositioned some of the controls in the dialog code. When I run my application, the controls are flickering. Please suggest me how to avoid this? BOOL CFP::OnInitDialog() { CDC *pDC = GetDC(); //Get DC for Dialog's Client Area pDCTmp->CreateCompatibleDC(pDC); //Create Compatible DC(pDCTmp) for Dialog's Client Area(pDC) //pDCTmp is a member Variable pBgBitmap->CreateCompatibleBitmap (pDC, 800, 640 ); //Create Compatible Bitmap(pBgBitmap) for Dialog's Client Area(pDC) //pBgBitmap->LoadBitmap(IDB_FORESTIMAGE); pDCTmp->SelectObject(pBgBitmap); ReleaseDC(pDC); } void CFacePlate::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here CRect rect; rect = rScreen; //rScreen is Client rect pDCTmp->FillRect(rect,&CBrush(RGB(152, 185, 192))); //pDCTmp member variable is used to draw . . . . //Custom drawings using the pDCTmp }

    C / C++ / MFC graphics c++ tutorial question

  • How to change the background color of checkbox in CListCtrl?
    M manoharbalu

    The complete background is not changing

    C / C++ / MFC tutorial question

  • How to change the background color of checkbox in CListCtrl?
    M manoharbalu

    How to change the background color of checkbox in CListCtrl? The checkbox appears before the 1st column. if I change the background using m_cLstCtrl.SetBkColor(RGB(0,0,0)); the background of the entire control is changed. If I change it inside OnCustomDraw as below: void CSysWindow::OnCustomDrawAlarmLine ( NMHDR* pNMHDR, LRESULT* pResult ) { NMLVCUSTOMDRAW *pCD = (NMLVCUSTOMDRAW*)pNMHDR; // By default set the return value to do the default behavior. *pResult = CDRF_DODEFAULT ; //obtain row and column of item int iRow = pCD->nmcd.dwItemSpec; int iCol = pCD->iSubItem; //Remove standard highlighting of selected (sub)item. pCD->nmcd.uItemState = CDIS_DEFAULT; switch( pCD->nmcd.dwDrawStage ) { case CDDS_PREPAINT: // First stage (for the whole control) { *pResult = CDRF_NOTIFYITEMDRAW; } break; case CDDS_ITEMPREPAINT: { *pResult = CDRF_NOTIFYSUBITEMDRAW; } break; case CDDS_ITEMPREPAINT | CDDS_SUBITEM : // Stage three { if ((iCol != 0) || (iCol != 1)) { pCD->clrText = RGB(255,0,0); pCD->clrTextBk = RGB(0,0,0); } if ((iCol == 0) || (iCol == 1)) { pCD->clrText = RGB(255,0,0); pCD->clrTextBk = RGB(0,255,0); } //if (sub)item is of interest, set custom text/background color //if( 1 == iRow && 3 == iCol ) //{ // pCD->clrText = RGB(255,0,0); // pCD->clrTextBk = RGB(210,245,245); //} //else //{ // pCD->clrText = RGB(0,0,0); // pCD->clrTextBk = RGB(255,255,255); //} *pResult = CDRF_NOTIFYPOSTPAINT; } break; case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM: // Stage four (called for each subitem of the focused item) { } break; default:// it wasn't a notification that was interesting to us. { *pResult = CDRF_DODEFAULT; } break; } } The background of the other column gets changed. but not the Checkbox. So...How to change the background of the checkbox column alone?

    C / C++ / MFC tutorial question

  • Subclassing a listcontrol in dialog bar
    M manoharbalu

    I have to display a Customized list control in a dialog bar and update it frequently. I am subclassing a custom list control in my application using: m_cLstCtrl.SubclassDlgItem(IDC_LSTCTRL_ALARM,this); CSysWindow is the dialog bar class and have created in CMainFrm using: if (!m_SysWnd.Create(this, IDD_DLGBAR_APPBAR, WS_CHILD | WS_VISIBLE | CBRS_GRIPPER |CBRS_FLYBY|CBRS_TOOLTIPS | CBRS_SIZE_DYNAMIC, IDD_DLGBAR_APPBAR)) { TRACE0("Failed to create DlgBar\n"); return -1; // fail to create } void CSysWindow::RecentAlarms() { //I am testing my List control using the below code: m_cLstCtrl.SetColumnHeader(_T("Student ID, 100; Enroll Date, 150; Score, 80, 2")); for (int i = 0; i < 10; i++) { const int IDX = m_cLstCtrl.InsertItem(0, _T("")); m_cLstCtrl.SetItemText(IDX, 0, ""); m_cLstCtrl.SetItemText(IDX, 1, "testDate"); m_cLstCtrl.SetItemText(IDX, 2, (rand() % 51) + 50); for (int j = 0; j < 2; j++) m_cLstCtrl.SetItemImage(IDX, j, rand() % 5); // subitem images } } When I call this function inside a thread, the application crashes by triggering a breakpoint. void tUpdateAllViews( CMainFrame *pMainFrm ) { while( 1 ) { pMainFrm->UpdateAllViews(); pMainFrm->m_SysWnd.RecentAlarms(); Sleep(500); } } void CMainFrame::UpdateAllViews() { //It also crashes when I call here as below. m_SysWnd.RecentAlarms(); } Whereas when I Call this function inside OnUpdate, its working void CMainFrame::OnUpdate() { // TODO: Add your command handler code here m_SysWnd.RecentAlarms(); } which is the proper way to call this function that is in the dialog bar class "m_SysWnd.RecentAlarms();" where to call this function? Please advice.

    C / C++ / MFC testing debugging beta-testing question announcement
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups