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
jimjim733
Posts
-
assigning string table element to char* variable -
stopping an exeHi 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
-
Finding status of On screen keyboardHi 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:
-
Serial coms worker thread not workingHi Cedric, Thanks for your help, that worked straight away.....I realised I had not set the timeouts :doh: Jim
-
Serial coms worker thread not workingHi 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:
-
ERROR_OPERATION_ABORTED with serial commsHi 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;
-
Button controlThanks for the help. That's all running now. Jim :-D
-
Button controlHi 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:
-
Unhandled Exception on CreateFileHi 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:
-
control of serial port handshaking linesThanks for that, I'll give it a go. I'll let you know how I get on. Cheers Jim ;)
-
control of serial port handshaking linesHi, 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:
-
Changing the IP address of PC from my applicationHi 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:
-
WSAStartup generates unhandled exceptionOne thing I have tried is moving the WSAStartup to the main initDialog function and the app goes through. Any ideas???? jim:confused:
-
WSAStartup generates unhandled exceptionokay, 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
-
WSAStartup generates unhandled exceptionOkay, thanks.....i'll take a look
-
WSAStartup generates unhandled exceptionSorry, just thought that might have fixed it. :(
-
WSAStartup generates unhandled exceptionhere'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() -
WSAStartup generates unhandled exceptionNo, that didn't work :confused:
-
WSAStartup generates unhandled exceptionok, so what do I need to do? :~
-
WSAStartup generates unhandled exceptionSorry, not sure I follow....that is the base class of the project....isn't it? Am I missing something here?:confused: