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
J

jimjim733

@jimjim733
About
Posts
22
Topics
10
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • assigning string table element to char* variable
    J jimjim733

    hi there, I have compiled a string table and some of the strings I need to assign to a char* variable, how can I do it? Thanks Jim

    C / C++ / MFC question

  • stopping an exe
    J jimjim733

    Hi there, I have in my application a button that launches another application such as the on-screen keyboard using the createprocess function. If the button is pressed again I want to close the application. How can I do this safely? Many thanks Jim

    C / C++ / MFC question

  • Finding status of On screen keyboard
    J jimjim733

    Hi all, Within my application I have a button that launches the windows XP OSK which works fine. The problem lies in the fact that this application is to operate on a touchscreen and being fullscreen restricts the user from accessing the taskbar. If the user minimises the OSK I cannot get it back without closing the application to gain access. So my question is this, can I get the status of the OSK, that is, minimised, running etc? so I can maximise it again from my application? The button in my application at the moment just opens the OSK but if it is already open (minimised) I cannot get it back..... Hopefully someone can help with this? Cheers Jim :confused:

    C / C++ / MFC help question

  • Serial coms worker thread not working
    J jimjim733

    Hi Cedric, Thanks for your help, that worked straight away.....I realised I had not set the timeouts :doh: Jim

    C / C++ / MFC help question com debugging

  • Serial coms worker thread not working
    J jimjim733

    Hi All, I wondered if someone can shed some light on what might be going on here. I have created the worker thread (code below) and when my system first boots up and I run through debug I find that the thread doesn't fire off the PostMessage(UWM_DATA_READ) until the buffer is full up....what I want it to do is fire it off when ever it reads in something. The interesting part is that if I stop the application and open Hyperterminal on the same com port then close it and then rerun the application it works as I intended???? Does anyone have any ideas what is going on?????? Cheers Jim

    UINT CMyDlg::monitorThread(LPVOID pParam)
    {
    DWORD dwRead;
    DWORD dwRes;
    BOOL fWaitingOnRead = FALSE;
    OVERLAPPED osReader = {0};
    struct PTZCommStruct *pPTZStruct = (struct PTZCommStruct *)pParam;

    // Create the overlapped event.
    osReader.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    
    if(osReader.hEvent == NULL)
    {
    	// Error creatiing overlapped event, abort.
    	DWORD err = ::GetLastError();
    	pPTZStruct->pWnd->PostMessage(UWM\_READER\_SHUTTING\_DOWN, (WPARAM)err);
    	return 0;
    } 
    
    
    while(pPTZStruct->nPTZCommTerminate == 0)
    {
    	if(!fWaitingOnRead)
    	{
    		// Issue read Operation.
    		BOOL tmp = ReadFile(m\_hPTZCtrlPort, PTZbuffer, MAX\_BUFFER\_SIZE, &dwRead, &osReader);
    		if(!tmp)
    		{
    			if(GetLastError() != ERROR\_IO\_PENDING) // read not delayed
    			{
    				// Error in comms - report!!!
    				return 0;
    			}
    			else
    			{
    				fWaitingOnRead = TRUE;
    			}
    		}
    		else
    		{
    			// \*\*\*Read the data
    			pPTZStruct->pWnd->PostMessage(UWM\_DATA\_READ);
    		}
    	}
    	else
    	{
    		dwRes = WaitForSingleObject(osReader.hEvent, READ\_TIMEOUT);
    		switch(dwRes)
    		{
    			// Read Completed
    		case WAIT\_OBJECT\_0:
    			if(!GetOverlappedResult(m\_hPTZCtrlPort, &osReader, &dwRead, FALSE))
    			{
    				DWORD dwError = GetLastError();
    				switch(dwError)
    				{
    					case ERROR\_HANDLE\_EOF:
    						return 0;
    						break;
    					case ERROR\_IO\_PENDING:
    						return 0;
    						break;
    					case ERROR\_IO\_INCOMPLETE:
    						return 0;
    						break;
    					case ERROR\_OPERATION\_ABORTED:
    						return 0;
    						break;
    					default:
    						// error in comms - report
    						Dump1("Serial Read Error %d\\r\\n", ::GetLastError());
    						return 0;
    						break;
    				}
    			}
    			else
    			{
    				// \*\*\*Read the Data 
    		        pPTZStruct->pWnd->PostMessage(UWM\_DATA\_READ);
    			}
    			fWaitingOnRead = FALSE;
    			break;
    
    		case WAIT\_TIMEOUT:
    
    C / C++ / MFC help question com debugging

  • ERROR_OPERATION_ABORTED with serial comms
    J jimjim733

    Hi there, I have created a thread that just monitors the serial port, but as soon as the com port receives any data, the GetOverlappedResult issues an ERROR_OPERATION_ABORTED error. Please can you take a look at my code, I cannot see what is going on. Thanks Jim :confused:

    #define READ_TIMEOUT 500 // Milliseconds

    UINT CPageOneDialog::monitorPTZThread(LPVOID pParam)
    {
    DWORD dwRead, dwRes;
    BOOL fWaitingOnRead = FALSE;
    OVERLAPPED osReader = {0};
    char ptzControlCommPort[14];
    struct PTZCommStruct *pPTZStruct = (struct PTZCommStruct *)pParam;

    // Open the comm port.
    sprintf(ptzControlCommPort,"\\\\\\\\.\\\\COM%d",PTZCTRLPORT+1);
    pPTZStruct->hPTZSerial = CreateFile( ptzControlCommPort,
    			  GENERIC\_READ | GENERIC\_WRITE,
    			  0,    // must be opened with exclusive-access
    			  NULL, // no security attributes
    			  OPEN\_EXISTING, // must use OPEN\_EXISTING
    			  FILE\_FLAG\_OVERLAPPED,    // overlapped I/O
    			  NULL  // hTemplate must be NULL for comm devices
    			  );
    
    
    // Create the overlapped event.
    osReader.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    
    if(osReader.hEvent == NULL)
    {
    	// Error creatiing overlapped event, abort.
    	pPTZStruct->pWnd->PostMessage(UWM\_READER\_SHUTTING\_DOWN);
    	return 0;
    } 
    
    while(pPTZStruct->nPTZCommTerminate == 0)
    {
    	if(!fWaitingOnRead)
    	{
    		// Issue read Operation.
    		if(!ReadFile(pPTZStruct->hPTZSerial,PTZbuffer, MAX\_BUFFER\_SIZE, &dwRead, &osReader))
    		{
    			if(GetLastError() != ERROR\_IO\_PENDING) // read not delayed
    			{
    				// Error in comms - report!!!
    				return 0;
    			}
    			else
    			{
    				fWaitingOnRead = TRUE;
    			}
    		}
    		else
    		{
    			// \*\*\*Read the data
    		}
    	}
    	else
    	{
    		dwRes = WaitForSingleObject(osReader.hEvent, READ\_TIMEOUT);
    		switch(dwRes)
    		{
    			// Read Completed
    		case WAIT\_OBJECT\_0:
    			if(!GetOverlappedResult(pPTZStruct->hPTZSerial, &osReader, &dwRead, FALSE))
    			{
    				DWORD dwError = GetLastError();
    				switch(dwError)
    				{
    					case ERROR\_HANDLE\_EOF:
    						return 0;
    						break;
    					case ERROR\_IO\_PENDING:
    						return 0;
    						break;
    					case ERROR\_IO\_INCOMPLETE:
    						return 0;
    						break;
    					case ERROR\_OPERATION\_ABORTED:
    						return 0;
    						break;
    					default:
    						// error in comms - report
    						Dump1("Serial Read Error %d\\r\\n", ::GetLastError());
    						return 0;
    						break;
    				}
    			}
    			else
    			{
    				// \*\*\*Read the Data 
    			}
    			fWaitingOnRead = FALSE;
    
    C / C++ / MFC help com security question

  • Button control
    J jimjim733

    Thanks for the help. That's all running now. Jim :-D

    C / C++ / MFC help question

  • Button control
    J jimjim733

    Hi there, Can someone please help me. I am programming a dialog GUI for a touch screen interface to control a motor and I want it to run the motor when someone presses the button and holds it and then the motor is stopped when it button is released. Can I use BN_PUSHED and BN_UNPUSHED? or is there another way. Does anyone have any examples that I could reference? Cheers Jim :confused:

    C / C++ / MFC help question

  • Unhandled Exception on CreateFile
    J jimjim733

    Hi there, I am trying to populate a combo box of available com ports. I call my openSerialport function from my init dialog function but as soon as CreateFile is executed I get an Unhandled Exception error which has the info 0xC0000005 : Access Violation. Can anyone help??????? Code Below InitDialog call

    BOOL CPTZControlDlg::OnInitDialog()
    {
    int i, j, hr;
    char portStr[7];

    CDialog::OnInitDialog();
    
    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m\_hIcon, TRUE);			// Set big icon
    SetIcon(m\_hIcon, FALSE);		// Set small icon
    
    // construct a list of available COM ports and put into combo box
    j=0;
    for (i=0 ; i<PORTNUM ; i++) 
    {
    	hr = m\_serialCtrl->OpenSerialPort(i,0);
    	if (hr == 0) 
    	{
    		g\_exists\[i\] = 1;
    		g\_nComPortInd\[j\] = i;
    		g\_comport\[i\] = j;
    		j++;
    		sprintf(portStr,"COM%d",i+1);
    		m\_comPort.AddString(portStr);
    
    	} 
    	else 
    		g\_exists\[i\] = 0;
    }
    
    return TRUE;  // return TRUE  unless you set the focus to a control
    

    }

    Open Serial port function

    int CSerialControl::OpenSerialPort(int pcCommPortInd,int radd)
    {
    DCB dcb;
    BOOL fSuccess;
    char pcCommPort[14];
    int m_nComPort;

    m_nComPort = pcCommPortInd;

    sprintf(pcCommPort,"COM1",pcCommPortInd+1);

    m_hCom = CreateFile( "COM1",
    GENERIC_READ | GENERIC_WRITE,
    0,
    NULL,
    CREATE_ALWAYS,
    FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED,
    NULL
    );

    if (m_hCom == INVALID_HANDLE_VALUE)
    {
    m_hCom = NULL;
    return COMMSERROR;
    }

    if (radd==0)
    {
    CloseSerialPort();
    return COMMSGOOD;
    }

    Cheers Jim :confused:

    C / C++ / MFC help com question

  • control of serial port handshaking lines
    J jimjim733

    Thanks for that, I'll give it a go. I'll let you know how I get on. Cheers Jim ;)

    C / C++ / MFC help

  • control of serial port handshaking lines
    J jimjim733

    Hi, I need to be able to toggle the handshaking lines on the serial port. Can anyone help with this. I am using vc6 on XP. Cheers Jim :confused:

    C / C++ / MFC help

  • Changing the IP address of PC from my application
    J jimjim733

    Hi all, I am developing a portable system and want to be able to change the IP address of the PC from my application. I am using VC6, does anyone have any ideas of how to do this? Cheers Jim :confused:

    C / C++ / MFC tutorial question

  • WSAStartup generates unhandled exception
    J jimjim733

    One thing I have tried is moving the WSAStartup to the main initDialog function and the app goes through. Any ideas???? jim:confused:

    C / C++ / MFC graphics help question

  • WSAStartup generates unhandled exception
    J jimjim733

    okay, can you help? I am not sure how to do this:~ Below are the only references I have for UnitInfoStruct

    struct UnitInfoStruct *pUnit = NULL;

    	pUnit = new struct UnitInfoStruct;
    
    vector<struct UnitInfoStruct \*> m\_vszIPAddr;
    

    struct UnitInfoStruct {
    char szIPAddr[16];
    char szSer[9];
    };

    As you can tell, I am struggling with this a bit. Jim

    C / C++ / MFC graphics help question

  • WSAStartup generates unhandled exception
    J jimjim733

    Okay, thanks.....i'll take a look

    C / C++ / MFC graphics help question

  • WSAStartup generates unhandled exception
    J jimjim733

    Sorry, just thought that might have fixed it. :(

    C / C++ / MFC graphics help question

  • WSAStartup generates unhandled exception
    J jimjim733

    here's a copy of the stack not sure what I am looking for??? Jim

    std::vector<UnitInfoStruct *,std::allocator<UnitInfoStruct *> >::size() line 114 + 15 bytes
    CAlinksRemoteControl::ScanForUnits() line 480 + 14 bytes
    CMultiVueDlg::OnInitDialog() line 130
    AfxDlgProc(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, unsigned int 3081096) line 35 + 14 bytes
    USER32! 7e418734()
    USER32! 7e42413c()
    USER32! 7e423b30()
    USER32! 7e43e599()
    USER32! 7e418734()
    USER32! 7e418816()
    USER32! 7e42a013()
    USER32! 7e42a998()
    CWnd::DefWindowProcA(unsigned int 272, unsigned int 3081096, long 0) line 1000 + 32 bytes
    CWnd::Default() line 249
    CDialog::HandleInitDialog(unsigned int 3081096, unsigned int 3081096) line 624 + 8 bytes
    CWnd::OnWndMsg(unsigned int 272, unsigned int 3081096, long 0, long * 0x0012f800) line 1815 + 17 bytes
    CWnd::WindowProc(unsigned int 272, unsigned int 3081096, long 0) line 1585 + 30 bytes
    AfxCallWndProc(CWnd * 0x0012fc08 {CMultiVueDlg hWnd=???}, HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 215 + 26 bytes
    AfxWndProc(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 368
    AfxWndProcBase(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 220 + 21 bytes
    USER32! 7e418734()
    USER32! 7e418816()
    USER32! 7e42927b()
    USER32! 7e42651a()
    USER32! 7e42683e()
    USER32! 7e439b43()
    CWnd::CreateDlgIndirect(const DLGTEMPLATE * 0x0042b540, CWnd * 0x00000000 {CWnd hWnd=???}, HINSTANCE__ * 0x00400000) line 327 + 36 bytes
    CDialog::DoModal() line 531 + 32 bytes
    CMultiVueApp::InitInstance() line 71 + 11 bytes
    AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0c, int 1) line 39 + 11 bytes
    WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0c, int 1) line 30
    WinMainCRTStartup() line 330 + 54 bytes
    KERNEL32! 7c817067()

    C / C++ / MFC graphics help question

  • WSAStartup generates unhandled exception
    J jimjim733

    No, that didn't work :confused:

    C / C++ / MFC graphics help question

  • WSAStartup generates unhandled exception
    J jimjim733

    ok, so what do I need to do? :~

    C / C++ / MFC graphics help question

  • WSAStartup generates unhandled exception
    J jimjim733

    Sorry, not sure I follow....that is the base class of the project....isn't it? Am I missing something here?:confused:

    C / C++ / MFC graphics help question
  • Login

  • Don't have an account? Register

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