CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2012
    Posts
    13

    MFC help in visual basic 2008

    hi,
    i am developing a GUI for my project through MFC using visual basic 2008. down below is a part my code that i have written. the purpose of this code is to get GPS data (using marshallsoft GPS component) from serial port, display, and keep on updating the data. i am facing problem using While (1) loop to update GPS data continuously. implementing while loop (as shown in my code) causes the dialog box disappear, although mydialog.exe is shown running at background in the task bar.
    any kind of help is appreciated.
    thanks
    Code:
    //Variables CTextFile
            int Code;
    		int LinesRX;
    		char Temp[256];
            int decimal, precision = 12, sign;
    		//CString sDataBuffer(DataBuffer);
    		//LPCTSTR lpszDataBuffer = sDataBuffer;
        	CString str, Lat, Long, Alt, Azi, Dist;
        	CStringArray sensorval;
        	double Latgcs, Longcs, Altgcs, Compgcs;
        	double Distance, Azimuth, Angle;
    		double Latitude, Longitude, Altitude;
        	CTextFile Sensor;
    	    BOOL res;
    		str=_T("E:\\sensorfile.txt");
    
    	    Code = mgcAttach(MGC_KEY_CODE);                          // attach MGC component
             if (mgcOpen(MGC_COM2)== 0)
                 SetDlgItemText(IDC_GPSPORT, (LPCTSTR) L"OK");
    		 else 
    			 SetDlgItemText(IDC_GPSPORT, (LPCTSTR) L"Port Error");
    	    
    	    res = Sensor.ReadTextFile(str, sensorval);
            Latgcs = wcstod(sensorval[0], NULL);
    	    SetDlgItemText(IDC_LATITUDE, sensorval[0]);
    	    Longcs = wcstod(sensorval[1], NULL);
    	    SetDlgItemText(IDC_LONGITUDE, sensorval[1]);
    	    Altgcs = wcstod(sensorval[2], NULL);
    	    SetDlgItemText(IDC_ALTITUDE, sensorval[2]);
    	    Compgcs = wcstod(sensorval[3], NULL);
    	    SetDlgItemText(IDC_NORTH, sensorval[3]);
    				
    		while (1)
    	        {
    	    Code = mgcSetInteger(MGC_SET_SENTENCE_TYPE, MGC_SENTENCE_GPGGA);
    
    		
    		mgcLockData(1);
    	    
    		
    		Latitude = mgcLatitude();
    		Lat = _ecvt( Latitude, precision, &decimal, &sign );	
    		SetDlgItemText(IDC_ACLAT, Lat);
    		
    	    Code = mgcGetData(GPGGA_LONGITUDE,(LPSTR)DataBuffer);
    		Longitude = atof (DataBuffer);
    		Long = _ecvt( Longitude, precision, &decimal, &sign );
    	    SetDlgItemText(IDC_ACLONG, Long);
    	    
    	    Code = mgcGetData(GPGGA_ALTITUDE,(LPSTR)DataBuffer);
    		Altitude = atof(DataBuffer);
    		Alt = _ecvt( Altitude, precision, &decimal, &sign );
    	    SetDlgItemText(IDC_ACALT, Alt);
    	    
    	    Distance = mgcGreatCircle(IDC_LATITUDE, IDC_LONGITUDE, IDC_ACLAT, IDC_ACLONG);
    	    Dist = _ecvt( Distance, precision, &decimal, &sign  );
    	    SetDlgItemText(IDC_ACDIST, Dist);
    	    
    	    Angle = mgcBearing (IDC_LATITUDE, IDC_LONGITUDE, IDC_ACLAT, IDC_ACLONG);
            Azimuth = Angle / 60000.0;
            Azi = _ecvt( Azimuth, precision, &decimal, &sign );
            SetDlgItemText(IDC_ACBEAR, Azi);
    		
    		mgcLockData(0);
    		}
    		
    	return TRUE;  // return TRUE  unless you set the focus to a control
    	
    }
    Last edited by Cimperiali; March 30th, 2012 at 03:10 AM. Reason: added [code][/code] tags

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: MFC help in visual basic 2008

    Please note that this is the area for VB6 questions. VB2008 is 10 years newer. There is another section for VB.Net which would cover VB 2003, 2005, 2008, 2010. Also note that when you post code you should use the code tags so that the code retains formatting and is more readable.

    That said the code you posted is not VB at all. VB does not use that type of syntax. If you are working in VS 2008 then most likely you are coding C#. There is a section here for that too. First thing you need to know in order to get help is what language you are using and then where to post questions related to the language you need help with. Posting C# questions in a VB6 area will likely yield little or no help.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: MFC help in visual basic 2008

    Quote Originally Posted by jawadali477 View Post
    hi,
    i am developing a GUI for my project through MFC using visual basic 2008.
    Seems as if there is a bit of confusion here: the code you posted is not vb 2008. Did you mean you are trying to make mfc using Visual Studio 2008?
    I moved your question to visual C++ forum, but if you think it should be moved to a Dot Net forum, let us know.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured